diff --git a/BNA8/com.inductiveautomation.perspective/views/autStand/PopUp-Views/Search/resource.json b/BNA8/com.inductiveautomation.perspective/views/autStand/PopUp-Views/Search/resource.json new file mode 100644 index 00000000..153e781e --- /dev/null +++ b/BNA8/com.inductiveautomation.perspective/views/autStand/PopUp-Views/Search/resource.json @@ -0,0 +1,17 @@ +{ + "scope": "G", + "version": 1, + "restricted": false, + "overridable": true, + "files": [ + "view.json", + "thumbnail.png" + ], + "attributes": { + "lastModification": { + "actor": "admin", + "timestamp": "2025-08-22T16:12:21Z" + }, + "lastModificationSignature": "cde0cd90de87671fcad4b50d5d799df59f5c2f892da2cf86344760131558c949" + } +} \ No newline at end of file diff --git a/BNA8/com.inductiveautomation.perspective/views/autStand/PopUp-Views/Search/thumbnail.png b/BNA8/com.inductiveautomation.perspective/views/autStand/PopUp-Views/Search/thumbnail.png new file mode 100644 index 00000000..0dc2bc3a Binary files /dev/null and b/BNA8/com.inductiveautomation.perspective/views/autStand/PopUp-Views/Search/thumbnail.png differ diff --git a/BNA8/com.inductiveautomation.perspective/views/autStand/PopUp-Views/Search/view.json b/BNA8/com.inductiveautomation.perspective/views/autStand/PopUp-Views/Search/view.json new file mode 100644 index 00000000..3a10c15b --- /dev/null +++ b/BNA8/com.inductiveautomation.perspective/views/autStand/PopUp-Views/Search/view.json @@ -0,0 +1,339 @@ +{ + "custom": {}, + "events": { + "system": { + "onStartup": { + "config": { + "script": "\tbuttonid \u003d self.custom.activityLogger.buttonid\n\tself.custom.activityLogger.start_time \u003d system.date.now()\n\tactivityLog.productMetrics.callLogger(self, \u0027click\u0027, buttonid)\n\t" + }, + "scope": "G", + "type": "script" + } + } + }, + "params": {}, + "props": { + "defaultSize": { + "height": 294, + "width": 500 + } + }, + "root": { + "children": [ + { + "children": [ + { + "meta": { + "name": "Label" + }, + "position": { + "basis": "77px" + }, + "props": { + "style": { + "backgroundColor": "#555555", + "color": "#FFFFFF", + "fontWeight": "bold", + "textIndent": "15px" + }, + "text": "Search" + }, + "type": "ia.display.label" + }, + { + "meta": { + "name": "Icon" + }, + "position": { + "basis": "30px" + }, + "props": { + "color": "#FFFFFF", + "path": "material/search" + }, + "type": "ia.display.icon" + } + ], + "meta": { + "name": "FlexContainer" + }, + "position": { + "basis": "45px" + }, + "props": { + "style": { + "backgroundColor": "#555555" + } + }, + "type": "ia.container.flex" + }, + { + "events": { + "component": { + "onRowDoubleClick": { + "config": { + "script": "\trow \u003d event.value\n\tsource_id \u003d row.get(\"SourceId\") \n\tconfig.project_config.source_id_lookup(self, source_id)\n\tsystem.perspective.closePopup(id \u003d \"Search\")" + }, + "scope": "G", + "type": "script" + } + } + }, + "meta": { + "name": "Table" + }, + "position": { + "basis": "294px" + }, + "props": { + "cells": { + "style": { + "textIndent": "15px" + } + }, + "columns": [ + { + "align": "center", + "boolean": "checkbox", + "dateFormat": "MM/DD/YYYY", + "editable": false, + "field": "SourceId", + "footer": { + "align": "center", + "justify": "left", + "style": { + "classes": "" + }, + "title": "" + }, + "header": { + "align": "center", + "justify": "left", + "style": { + "classes": "" + }, + "title": "" + }, + "justify": "auto", + "number": "value", + "numberFormat": "0,0.##", + "progressBar": { + "bar": { + "color": "", + "style": { + "classes": "" + } + }, + "max": 100, + "min": 0, + "track": { + "color": "", + "style": { + "classes": "" + } + }, + "value": { + "enabled": true, + "format": "0,0.##", + "justify": "center", + "style": { + "classes": "" + } + } + }, + "render": "auto", + "resizable": false, + "sort": "none", + "sortable": false, + "strictWidth": false, + "style": { + "classes": "" + }, + "toggleSwitch": { + "color": { + "selected": "", + "unselected": "" + } + }, + "viewParams": {}, + "viewPath": "", + "visible": true, + "width": 200 + }, + { + "align": "center", + "boolean": "checkbox", + "dateFormat": "MM/DD/YYYY", + "editable": false, + "field": "Page", + "filter": { + "boolean": { + "condition": "" + }, + "date": { + "condition": "", + "value": "" + }, + "enabled": false, + "number": { + "condition": "", + "value": "" + }, + "string": { + "condition": "", + "value": "" + }, + "visible": "on-hover" + }, + "footer": { + "align": "center", + "justify": "left", + "style": { + "classes": "" + }, + "title": "" + }, + "header": { + "align": "center", + "justify": "left", + "style": { + "classes": "" + }, + "title": "" + }, + "justify": "auto", + "nullFormat": { + "includeNullStrings": false, + "nullFormatValue": "", + "strict": false + }, + "number": "value", + "numberFormat": "0,0.##", + "progressBar": { + "bar": { + "color": "", + "style": { + "classes": "" + } + }, + "max": 100, + "min": 0, + "track": { + "color": "", + "style": { + "classes": "" + } + }, + "value": { + "enabled": true, + "format": "0,0.##", + "justify": "center", + "style": { + "classes": "" + } + } + }, + "render": "auto", + "resizable": true, + "sort": "none", + "sortable": true, + "strictWidth": false, + "style": { + "classes": "" + }, + "toggleSwitch": { + "color": { + "selected": "", + "unselected": "" + } + }, + "viewParams": {}, + "viewPath": "", + "visible": true, + "width": "" + } + ], + "data": { + "$": [ + "ds", + 192, + 1755879137747 + ], + "$columns": [ + { + "data": [], + "name": "SourceId", + "type": "String" + }, + { + "data": [], + "name": "Page", + "type": "String" + } + ] + }, + "filter": { + "enabled": true, + "style": { + "backgroundColor": "#2B2B2B", + "color": "#FFFFFF" + } + }, + "headerStyle": { + "backgroundColor": "#2B2B2B", + "color": "#FFFFFF", + "textIndent": "15px" + }, + "pager": { + "style": { + "backgroundColor": "#2B2B2B", + "color": "#FFFFFF", + "fontWeight": "bold" + } + }, + "rows": { + "highlight": { + "color": "#FFFFFF" + }, + "style": { + "classes": "Background-Styles/Controller" + } + }, + "virtualized": false + }, + "scripts": { + "customMethods": [], + "extensionFunctions": null, + "messageHandlers": [ + { + "messageType": "search-devices", + "pageScope": true, + "script": "\tself.props.data \u003d payload.get(\"dataset\")", + "sessionScope": false, + "viewScope": false + } + ] + }, + "type": "ia.display.table" + } + ], + "events": { + "system": { + "onStartup": { + "config": { + "script": "\tids \u003d autStand.config.project_config.global_project_page_ids\n\tsystem.perspective.print(ids)\n\tdata \u003d []\n\tfor k,v in ids.items():\n\t items \u003d [str(k),str(v)]\n\t data.append(items)\n\theader \u003d [\"SourceId\", \"Page\"]\n\tdataset \u003d system.dataset.toDataSet(header, data)\n\tself.getChild(\"Table\").props.data \u003d dataset\n\t\n\tsystem.perspective.print(\"happy end\")" + }, + "scope": "G", + "type": "script" + } + } + }, + "meta": { + "name": "root" + }, + "props": { + "direction": "column" + }, + "type": "ia.container.flex" + } +} \ No newline at end of file diff --git a/BNA8/ignition/script-python/autStand/config/project_config/code.py b/BNA8/ignition/script-python/autStand/config/project_config/code.py new file mode 100644 index 00000000..a3763317 --- /dev/null +++ b/BNA8/ignition/script-python/autStand/config/project_config/code.py @@ -0,0 +1,99 @@ +import re +import os +import json +import sys +#Stores the page configuration for the project. +#This global variable is accesible form all gateway scoped events using "." notation +#congig.project_config.global_project_page_ids +global_project_page_ids = {} + +def get_project_config(): + """ + Function searches through the project directory Detailed-Views. + It looks for all the source ids on each Detailed-View and returns a + Dict with source ids as the keys and page ids as the values. + + Args: + param1: self. refrence to the object being called. + param2: source_id. The source_id of the alarm. + + Returns: + N/A. + + Raises: + KeyError: Will log an error message to the console if the basepath is not found. + logger = {whid}_get_project_config + """ + system.perspective.print(system.util.getProjectName) + if not global_project_page_ids: + try: + basePath = os.getcwd().replace('\\','/') + '/data/projects/' + system.util.getProjectName() + '/com.inductiveautomation.perspective/views/autStand/Detailed_Views' + files = os.listdir(basePath) + files_found = True + except: + whid = system.tag.readBlocking("Configuration/FC")[0].value + logger = system.util.getLogger("%s-get_project_config" % (whid)) + exc_type, exc_obj, tb = sys.exc_info() + lineno = tb.tb_lineno +# logger.error("Error: %s, %s, %s" % (lineno, exc_type, exc_obj)) #JCM + files_found = False + if files_found: + for i in files: + jsonPath = basePath+'/'+str(i)+'/view.json' + with open(jsonPath, 'r') as f: + data= f.read() + obj = json.loads(data) + for child in obj['root']['children']: + tag_props = child.get("props",{}).get("params", {}).get("tagProps") + if tag_props: + source_id = tag_props[0] + global global_project_page_ids + global_project_page_ids[source_id] = i + + +def navigate_to_url(self, source_id, page_id): + url_to_navigate = "/DetailedView/%s/%s" % (page_id, page_id) + navigation.amzl_navigation.set_session_variables(self, source_id, False) + system.perspective.navigate(page = url_to_navigate) + +def source_id_lookup(self, source_id): + """ + This function looks for the source_id in + the global_project_page_ids variable. + If found it returns the corrresponding page id. + If no page id is found it will search up the hierachy + of the source_id until it finds a match. It will then + navigate the user to the correct page and set the session + custom variable search_id. + + Args: + param1: self. refrence to the object being called. + param2: source_id. The source_id of the alarm. + + Returns: + N/A. + + Raises: + KeyError: N/A. + """ + logger = system.util.getLogger("Naviagtion function") +# logger.info(str(global_project_page_ids)) + page_id = global_project_page_ids.get(source_id) + found = False + if page_id: + found = True + navigate_to_url(self, source_id, page_id) + else: + items = source_id.split("/") + length_of_items = len(items)-1 + while length_of_items > 0: + items.pop() + source_id = "/".join(items) + page_id = global_project_page_ids.get(source_id) + if page_id: + found = True + navigate_to_url(self, source_id, page_id) + break + length_of_items -= 1 + if not found: + open_pop_up("No page id found") diff --git a/BNA8/ignition/script-python/autStand/config/project_config/resource.json b/BNA8/ignition/script-python/autStand/config/project_config/resource.json new file mode 100644 index 00000000..cbe8898e --- /dev/null +++ b/BNA8/ignition/script-python/autStand/config/project_config/resource.json @@ -0,0 +1,17 @@ +{ + "scope": "A", + "version": 1, + "restricted": false, + "overridable": true, + "files": [ + "code.py" + ], + "attributes": { + "lastModification": { + "actor": "admin", + "timestamp": "2025-08-22T16:08:18Z" + }, + "hintScope": 2, + "lastModificationSignature": "8319c5ef11da541210529dadbabc27494bf944ad599b160c660fdeade0b8a24c" + } +} \ No newline at end of file