Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
aarti-dashboard automation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mohammed.shibili
aarti-dashboard automation
Commits
7a6e86fb
Commit
7a6e86fb
authored
Jan 24, 2024
by
mohammed.shibili
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new changes in group dashboard
parent
7afc5a71
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
341 additions
and
62 deletions
+341
-62
.env
.env
+1
-1
arti auto.xlsx
arti auto.xlsx
+0
-0
log/EMS-Automation.log
log/EMS-Automation.log
+256
-0
scripts/core/handlers/dashboard_handler.py
scripts/core/handlers/dashboard_handler.py
+1
-1
scripts/core/handlers/widget_handler.py
scripts/core/handlers/widget_handler.py
+74
-57
scripts/services/dashboards.py
scripts/services/dashboards.py
+8
-2
widget.json
widget.json
+1
-1
No files found.
.env
View file @
7a6e86fb
...
@@ -25,7 +25,7 @@ UPLOAD_LOG_PATH=/DATA/Config/
...
@@ -25,7 +25,7 @@ UPLOAD_LOG_PATH=/DATA/Config/
BASE_URL=https://staging.unifytwin.com/
BASE_URL=https://staging.unifytwin.com/
USER_ID=7BYVRyxnzE4MS33Gv8Y6eB
USER_ID=7BYVRyxnzE4MS33Gv8Y6eB
PROJECT_ID=project_437
PROJECT_ID=project_437
LOGIN_TOKEN=
d102d0403da94627a812836c7e2a66f8
LOGIN_TOKEN=
864d35ba4d4f4473a2abd000f5b2ec24
NEW_BASE_URL=https://staging.unifytwin.com/
NEW_BASE_URL=https://staging.unifytwin.com/
NEW_USER_ID=56jyuX7Z9M4HkoeGfTNJWk
NEW_USER_ID=56jyuX7Z9M4HkoeGfTNJWk
...
...
arti auto.xlsx
View file @
7a6e86fb
No preview for this file type
log/EMS-Automation.log
View file @
7a6e86fb
This diff is collapsed.
Click to expand it.
scripts/core/handlers/dashboard_handler.py
View file @
7a6e86fb
...
@@ -50,7 +50,7 @@ class Dashboards:
...
@@ -50,7 +50,7 @@ class Dashboards:
dashboard_id
=
new_dashboard_list
.
get
(
'dashboard_id'
,
''
)
dashboard_id
=
new_dashboard_list
.
get
(
'dashboard_id'
,
''
)
logger
.
info
(
f
'dashboard id >>>> {dashboard_id}'
)
logger
.
info
(
f
'dashboard id >>>> {dashboard_id}'
)
if
dashboard_id
:
if
dashboard_id
:
return
dashboard_id
return
dashboard_id
,
dashboard_name
else
:
else
:
return
False
return
False
except
Exception
as
e
:
except
Exception
as
e
:
...
...
scripts/core/handlers/widget_handler.py
View file @
7a6e86fb
...
@@ -32,7 +32,7 @@ class Widgets:
...
@@ -32,7 +32,7 @@ class Widgets:
logger
.
error
(
f
'error while getting existing widget details {e}'
)
logger
.
error
(
f
'error while getting existing widget details {e}'
)
@
staticmethod
@
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
:
try
:
logger
.
info
(
f
'service started in creating new widgets'
)
logger
.
info
(
f
'service started in creating new widgets'
)
count
=
0
count
=
0
...
@@ -44,7 +44,8 @@ class Widgets:
...
@@ -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
=
[
elem
for
elem
in
existing_widget_details
if
elem
not
in
group_elements
]
existing_widget_details
.
extend
(
group_elements
)
existing_widget_details
.
extend
(
group_elements
)
for
widget
in
existing_widget_details
:
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
=
{
widget_payload
=
{
"dashboard_id"
:
dashboard_id
,
"dashboard_id"
:
dashboard_id
,
"widget_data"
:
new_widget_metadata
,
"widget_data"
:
new_widget_metadata
,
...
@@ -64,7 +65,7 @@ class Widgets:
...
@@ -64,7 +65,7 @@ class Widgets:
logger
.
error
(
f
'error while creating new widgets {e}'
)
logger
.
error
(
f
'error while creating new widgets {e}'
)
@
staticmethod
@
staticmethod
def
create_pyload
(
widget
,
parameters_json
):
def
create_pyload
(
widget
,
parameters_json
,
new_dashboard_details
):
try
:
try
:
count
=
0
count
=
0
logger
.
info
(
f
'service started in creating payload'
)
logger
.
info
(
f
'service started in creating payload'
)
...
@@ -73,13 +74,13 @@ class Widgets:
...
@@ -73,13 +74,13 @@ class Widgets:
new_filter_parameters
=
[]
new_filter_parameters
=
[]
missing_tags
=
[]
missing_tags
=
[]
new_widget_payload
=
widget
new_widget_payload
=
widget
# filter_list_old = new_widget_payload["cData"]["chartOptions"]["filter"]["filterList"][0]["value"]
new_widget_payload
.
pop
(
'widget_id'
)
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"
):
if
new_widget_payload
.
get
(
"editMode"
):
new_widget_payload
.
pop
(
'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
)
hierarchy_data
,
filter_data
=
create_hierarchy
(
parameters_json
)
yaxis_parameters
=
widget
[
"cData"
][
"chartOptions"
][
"yaxis"
]
yaxis_parameters
=
widget
[
"cData"
][
"chartOptions"
][
"yaxis"
]
hierarchy_details_url
=
f
'{Base_path.BASE_URL}{RequestEndpoints.hierarchy_details}'
hierarchy_details_url
=
f
'{Base_path.BASE_URL}{RequestEndpoints.hierarchy_details}'
...
@@ -102,7 +103,8 @@ class Widgets:
...
@@ -102,7 +103,8 @@ class Widgets:
current_site_level
=
{}
current_site_level
=
{}
for
select_hierarchy
in
filter_data
:
for
select_hierarchy
in
filter_data
:
for
data_
in
site_level_hierarchy_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"
]:
widget_title
=
select_hierarchy
[
"New widget Name"
]
widget_title
=
select_hierarchy
[
"New widget Name"
]
current_site_level
=
data_
current_site_level
=
data_
...
@@ -119,7 +121,8 @@ class Widgets:
...
@@ -119,7 +121,8 @@ class Widgets:
flag
=
0
flag
=
0
for
data
in
yaxis_parameters
:
for
data
in
yaxis_parameters
:
for
tag_name
in
hierarchy_data
:
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"
]:
"title"
]:
count
+=
1
count
+=
1
print
(
count
)
print
(
count
)
...
@@ -192,24 +195,38 @@ class Widgets:
...
@@ -192,24 +195,38 @@ class Widgets:
for
tags
in
hierarchy_details_list_old
:
for
tags
in
hierarchy_details_list_old
:
if
params
==
tags
[
"value"
]:
if
params
==
tags
[
"value"
]:
params_label
.
append
(
tags
[
"label"
])
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
:
if
changed_params_label
:
for
changed_label
in
changed_params_label
:
for
changed_label
in
changed_params_label
:
for
tags
in
hierarchy_details_list
:
for
tags
in
hierarchy_details_list
:
if
changed_label
==
tags
[
"label"
]:
if
changed_label
==
tags
[
"label"
]:
new_parameters
.
append
(
tags
[
"value"
])
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
return
new_widget_payload
,
missing_tags
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
error
(
f
'error while creating payload {e}'
)
logger
.
error
(
f
'error while creating payload {e}'
)
pass
pass
@
staticmethod
@
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'
)
logger
.
info
(
f
'service started in creating group widget'
)
widgets_to_add
=
[]
widget_title
=
""
for
data
in
parameters_json
:
for
data
in
parameters_json
:
if
data
[
"Tag Name"
]
==
"Group Widget"
:
if
data
[
"Tag Name"
]
==
"Group Widget"
:
print
(
"tbd"
)
widgets_to_add
=
data
[
"Widget Lists"
]
.
split
(
','
)
widget
[
"cData"
][
"widgetsList"
]
=
"list"
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}'
)
scripts/services/dashboards.py
View file @
7a6e86fb
...
@@ -38,10 +38,16 @@ async def create_dashboard(file: UploadFile = File(...), sheet_name: str = Form(
...
@@ -38,10 +38,16 @@ async def create_dashboard(file: UploadFile = File(...), sheet_name: str = Form(
if
existing_dashboards
:
if
existing_dashboards
:
existing_widget
=
widget_handler
.
get_widget_details
(
existing_dashboards
)
existing_widget
=
widget_handler
.
get_widget_details
(
existing_dashboards
)
if
existing_widget
:
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
:
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
,
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
:
if
widget_response
or
missing_tags
:
return
{
return
{
"widget"
:
f
'widget number:{widget_response} missing'
,
"widget"
:
f
'widget number:{widget_response} missing'
,
...
...
widget.json
View file @
7a6e86fb
[{
"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"
}]
[{
"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
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment