Commit 7a6e86fb authored by mohammed.shibili's avatar mohammed.shibili

new changes in group dashboard

parent 7afc5a71
......@@ -25,7 +25,7 @@ UPLOAD_LOG_PATH=/DATA/Config/
BASE_URL=https://staging.unifytwin.com/
USER_ID=7BYVRyxnzE4MS33Gv8Y6eB
PROJECT_ID=project_437
LOGIN_TOKEN=d102d0403da94627a812836c7e2a66f8
LOGIN_TOKEN=864d35ba4d4f4473a2abd000f5b2ec24
NEW_BASE_URL=https://staging.unifytwin.com/
NEW_USER_ID=56jyuX7Z9M4HkoeGfTNJWk
......
No preview for this file type
This diff is collapsed.
......@@ -50,7 +50,7 @@ class Dashboards:
dashboard_id = new_dashboard_list.get('dashboard_id', '')
logger.info(f'dashboard id >>>> {dashboard_id}')
if dashboard_id:
return dashboard_id
return dashboard_id, dashboard_name
else:
return False
except Exception as e:
......
......@@ -32,7 +32,7 @@ class Widgets:
logger.error(f'error while getting existing widget details {e}')
@staticmethod
def create_new_widgets(existing_widget, parameters_json, dashboard_id):
def create_new_widgets(existing_widget, parameters_json, dashboard_id, new_dashboard_details):
try:
logger.info(f'service started in creating new widgets')
count = 0
......@@ -44,7 +44,8 @@ class Widgets:
existing_widget_details = [elem for elem in existing_widget_details if elem not in group_elements]
existing_widget_details.extend(group_elements)
for widget in existing_widget_details:
new_widget_metadata, missing_tags = Widgets().create_pyload(widget, parameters_json)
new_widget_metadata, missing_tags = Widgets().create_pyload(widget, parameters_json,
new_dashboard_details)
widget_payload = {
"dashboard_id": dashboard_id,
"widget_data": new_widget_metadata,
......@@ -64,7 +65,7 @@ class Widgets:
logger.error(f'error while creating new widgets {e}')
@staticmethod
def create_pyload(widget, parameters_json):
def create_pyload(widget, parameters_json, new_dashboard_details):
try:
count = 0
logger.info(f'service started in creating payload')
......@@ -73,13 +74,13 @@ class Widgets:
new_filter_parameters = []
missing_tags = []
new_widget_payload = widget
# filter_list_old = new_widget_payload["cData"]["chartOptions"]["filter"]["filterList"][0]["value"]
new_widget_payload.pop('widget_id')
if widget["cData"]["chartOptions"]["chartType"] == "group":
Widgets().get_group_widget(widget, parameters_json)
else:
if new_widget_payload.get("editMode"):
new_widget_payload.pop('editMode')
if widget["cData"]["chartOptions"]["chartType"] == "group":
group_widget = Widgets().get_group_widget(new_widget_payload, parameters_json, new_dashboard_details)
return group_widget, missing_tags
else:
hierarchy_data, filter_data = create_hierarchy(parameters_json)
yaxis_parameters = widget["cData"]["chartOptions"]["yaxis"]
hierarchy_details_url = f'{Base_path.BASE_URL}{RequestEndpoints.hierarchy_details}'
......@@ -102,7 +103,8 @@ class Widgets:
current_site_level = {}
for select_hierarchy in filter_data:
for data_ in site_level_hierarchy_data:
if data_["name"] == select_hierarchy["filter"] and select_hierarchy["Existing Widget Name"] == \
if data_["name"] == select_hierarchy["filter"] and select_hierarchy[
"Existing Widget Name"] == \
widget["title"]:
widget_title = select_hierarchy["New widget Name"]
current_site_level = data_
......@@ -119,7 +121,8 @@ class Widgets:
flag = 0
for data in yaxis_parameters:
for tag_name in hierarchy_data:
if tag_name.get("Tag Name", "") == tags["label"] and tag_name["Existing Widget Name"] == widget[
if tag_name.get("Tag Name", "") == tags["label"] and tag_name["Existing Widget Name"] == \
widget[
"title"]:
count += 1
print(count)
......@@ -192,24 +195,38 @@ class Widgets:
for tags in hierarchy_details_list_old:
if params == tags["value"]:
params_label.append(tags["label"])
# for label in params_label:
# if label in filtered_hierarchy_data:
# changed_params_label.append(filtered_hierarchy_data[label])
if changed_params_label:
for changed_label in changed_params_label:
for tags in hierarchy_details_list:
if changed_label == tags["label"]:
new_parameters.append(tags["value"])
new_widget_payload["cData"]["chartOptions"]["xaxis"]["aggregations"][0]["parameters"] = new_parameters
new_widget_payload["cData"]["chartOptions"]["xaxis"]["aggregations"][0][
"parameters"] = new_parameters
return new_widget_payload, missing_tags
except Exception as e:
logger.error(f'error while creating payload {e}')
pass
@staticmethod
def get_group_widget(widget, parameters_json):
def get_group_widget(widget, parameters_json, new_dashboard_details):
try:
logger.info(f'service started in creating group widget')
widgets_to_add = []
widget_title = ""
for data in parameters_json:
if data["Tag Name"] == "Group Widget":
print("tbd")
widget["cData"]["widgetsList"] = "list"
widgets_to_add = data["Widget Lists"].split(',')
widget_title = data["New widget Name"]
created_widgets = Widgets().get_widget_details(new_dashboard_details)
widget_id = []
for each_widget in created_widgets["widget"]["wcData"]:
for widget_name in widgets_to_add:
if each_widget["title"] == widget_name:
widget_id.append(each_widget["widget_id"])
widget["cData"]["chartOptions"]["widgetsList"] = widget_id
widget["cData"]["chartOptions"]["grpName"] = widget_title
widget["title"] = widget_title
widget["description"] = widget_title
return widget
except Exception as e:
logger.error(f'error in creating payload for group widget {e}')
......@@ -38,10 +38,16 @@ async def create_dashboard(file: UploadFile = File(...), sheet_name: str = Form(
if existing_dashboards:
existing_widget = widget_handler.get_widget_details(existing_dashboards)
if existing_widget:
dashboard_response = dashboard_handler.create_new_dashboard(existing_dashboards, new_dashboard_name)
dashboard_response, new_dashboard_name = dashboard_handler.create_new_dashboard(existing_dashboards,
new_dashboard_name)
if dashboard_response:
new_dashboard_details = {
"dashboard_id": dashboard_response,
"name": new_dashboard_name
}
widget_response, missing_tags = widget_handler.create_new_widgets(existing_widget, parameters_json,
dashboard_response)
dashboard_response,
new_dashboard_details)
if widget_response or missing_tags:
return {
"widget": f'widget number:{widget_response} missing',
......
[{"Tag Name": "NEO>MEA Plant>Column Section>Moisture Removal Column C-1122:Running Status(P1127)", "Label": "Running Status", "Existing Widget Name": "Widget", "New widget Name": "Test 1", "Null": "Automation test KPI"}, {"Tag Name": "NEO>MEA Plant>Column Section>Moisture Removal Column C-1122:Outlet Flow(FIC11295)", "Label": "Outlet Flow", "Existing Widget Name": "Widget", "New widget Name": "Test 1", "Null": "Automation test KPI"}, {"Tag Name": "NEO>MEA Plant>Column Section>Moisture Removal Column C-1122:Bottom Temperature(TIC11225)", "Label": "Bottom Temperature", "Existing Widget Name": "Widget", "New widget Name": "Test 1", "Null": "Automation test KPI"}, {"Tag Name": "NEO>MEA Plant>Column Section>Moisture Removal Column C-1122:Middle Top Temperature(TIC11222)", "Label": "Middle Top Temp", "Existing Widget Name": "Widget", "New widget Name": "Test 1", "Null": "Automation test KPI"}, {"Tag Name": "NEO>MEA Plant>Column Section>Moisture Removal Column C-1122:Top Flow(FIC11269)", "Label": "Top Flow", "Existing Widget Name": "Widget", "New widget Name": "Test 1", "Null": "Automation test KPI"}, {"Tag Name": "NEO>MEA Plant>Column Section>Moisture Removal Column C-1122:Differential Pressure(PDI11223)", "Label": "Differential Pressure", "Existing Widget Name": "Widget", "New widget Name": "Test 1", "Null": "Automation test KPI"}, {"Tag Name": "NEO>66 TPH Boiler>Steam And Water System>Steam Prs Station 2PIC0303:Pressure(2PIC0303)", "Label": "Pressure", "Existing Widget Name": "Widget", "New widget Name": "Test 1", "Null": "Automation test KPI"}, {"Tag Name": "NEO>MEA Plant>Column Section>Vaccum Pump System S607:Current(S607_AMP)", "Label": "Current", "Existing Widget Name": "Widget2", "New widget Name": "Test 2", "Null": "Automation test KPI"}, {"Tag Name": "NEO>MEA Plant>Column Section>Vaccum Pump System S607:Pressure(PT-1)", "Label": "Pressure", "Existing Widget Name": "Widget2", "New widget Name": "Test 2", "Null": "Automation test KPI"}, {"Tag Name": "NEO>MEA Plant>Reaction Section>Catalyst Prepeartion Reactor R-1005:Inlet valve(HS10035)", "Label": "Inlet valve", "Existing Widget Name": "Widget2", "New widget Name": "Test 2", "Null": "Automation test KPI"}]
\ No newline at end of file
[{"Tag Name": "NEO>MEA Plant>Column Section>Vaccum Pump System S607:Running Status(S607)", "Label": "Running Status", "Existing Widget Name": "Widget", "New widget Name": "test Widget", "Widget Lists": NaN}, {"Tag Name": "NEO>MEA Plant>Column Section>Vaccum Pump System S607:Valve Status 1(XV-1)", "Label": "Valve Status", "Existing Widget Name": "widget 2", "New widget Name": "new test", "Widget Lists": NaN}, {"Tag Name": "Group Widget", "Label": NaN, "Existing Widget Name": "Test group", "New widget Name": "new test group", "Widget Lists": "test Widget,new test"}]
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment