{ "custom": { "api_region_name": "na", "loading": false, "operation_options": [ { "label": "Copy Single", "value": "copy_single" }, { "label": "Upload", "value": "upload" }, { "label": "Delete", "value": "delete" }, { "label": "Add New Site", "value": "add_new_site" } ], "query_params": { "bucket": null, "object_key": null, "site": null, "view": null }, "raw_data": [] }, "events": { "system": { "onStartup": { "config": { "script": "\tquery_params \u003d self.params.query_params\n\tself.custom.query_params \u003d query_params\n\tif query_params.get(\u0027bucket\u0027, None) and query_params.get(\u0027site\u0027, None) and query_params.get(\u0027view\u0027, None):\n\t\tsystem.perspective.sendMessage(\u0027refresh_version_table_data\u0027, scope\u003d\u0027view\u0027)\n\telse:\n\t\tself.custom.raw_data \u003d []\n\t" }, "scope": "G", "type": "script" } } }, "params": { "query_params": { "bucket": null, "object_key": null, "site": null, "view": null } }, "propConfig": { "custom.api_region_name": { "binding": { "config": { "path": "session.custom.aws.prefix" }, "type": "property" }, "persistent": true }, "custom.loading": { "persistent": true }, "custom.operation_options": { "binding": { "config": { "expression": "1" }, "transforms": [ { "code": "\tfrom AWS.s3 import OPERATION_MAP\n\treturn [{\u0027value\u0027:k, \u0027label\u0027:k.replace(\u0027_\u0027,\u0027 \u0027).title()} \n\t\t\tfor k,v in OPERATION_MAP.iteritems()\n\t\t\tif v.get(\u0027method\u0027, \u0027\u0027) in (\u0027PUT\u0027, \u0027POST\u0027, \u0027DELETE\u0027)\n\t\t\tand k not in (\u0027query_audit_table\u0027, )]", "type": "script" } ], "type": "expr" }, "persistent": true }, "custom.query_params": { "persistent": true }, "custom.raw_data": { "persistent": true }, "params.query_params": { "paramDirection": "input", "persistent": true } }, "props": { "defaultSize": { "width": 1200 } }, "root": { "children": [ { "meta": { "name": "Query Params" }, "position": { "shrink": 0 }, "propConfig": { "props.params.params.query_params": { "binding": { "config": { "path": "view.custom.query_params" }, "type": "property" } } }, "props": { "params": { "open_expanded": false, "params": {}, "path": "Objects/Templates/S3/Versions/Query_Options", "show_box_shadow_on_expanded": true, "title": "Query Params", "useDefaultHeight": false, "useDefaultWidth": false }, "path": "Framework/Card/Card_Collapsible_Transparent" }, "type": "ia.display.view" }, { "meta": { "name": "Log Table" }, "position": { "basis": "100%" }, "propConfig": { "props.params.table_data": { "binding": { "config": { "path": "view.custom.raw_data" }, "type": "property" } }, "props.params.title": { "binding": { "config": { "expression": "if(!isNull({view.custom.query_params.site})\u0026\u0026!isNull({view.custom.query_params.view}),\r\n\treplace(stringFormat(\u0027%s Version History - \u0027,\r\n\t\t{view.custom.query_params.object_key}),\r\n\t\t\u0027SCADA/\u0027,\u0027\u0027)+\r\n\tif({view.custom.loading}, \u0027Loading...\u0027, stringFormat(\u0027%d Record(s)\u0027, len({view.custom.raw_data}))),\r\n\t\u0027Select View to view version history\u0027)" }, "type": "expr" } } }, "props": { "params": { "NavigationSettings": { "BaseUrl": "/singleMP/main", "Column": "mp_name", "Enabled": false }, "SelectedRow": [], "filters": [], "header_order": [ { "field": "VersionId", "title": "VERSION ID", "visible": true }, { "field": "LastModified", "title": "LAST MODIFIED", "visible": true }, { "field": "Size", "title": "SIZE (Bytes)", "visible": true }, { "field": "IsLatest", "title": "IS LATEST?", "visible": true }, { "field": "Key", "title": "OBJECT KEY", "visible": true }, { "field": "StorageClass", "title": "STORAGE CLASS", "visible": false }, { "field": "ETag", "title": "ETAG", "visible": false } ] }, "path": "Objects/Templates/S3/Versions/Log_Table" }, "type": "ia.display.view" } ], "meta": { "name": "root" }, "props": { "direction": "column" }, "scripts": { "customMethods": [ { "name": "refresh_version_table_data", "params": [], "script": "\tquery_params \u003d self.view.custom.query_params\n\tif query_params.bucket and query_params.site and query_params.view:\n\t\t# refresh the audit table query\n\t\tfrom AWS.s3 import S3Manager\n\t\t\n\t\tself.view.custom.loading \u003d True\n\t\tapi_stage \u003d \u0027prod\u0027\n\t\tusername \u003d self.session.props.auth.user.userName\n\t\tapi_region_name \u003d self.view.custom.api_region_name\n\t\ts3m \u003d S3Manager(api_stage, api_region_name, username)\n\t\t\n\t\tbucket \u003d self.view.custom.query_params.bucket\n\t\tobj_key \u003d self.view.custom.query_params.object_key\n\t\tresp \u003d s3m.list_object_versions(bucket, obj_key)\n\t\tself.view.custom.raw_data \u003d resp\n\t\tself.view.custom.loading \u003d False\n\telse:\n\t\tself.view.custom.raw_data \u003d []\n\t" } ], "extensionFunctions": null, "messageHandlers": [ { "messageType": "list_versions_query_params_changed", "pageScope": false, "script": "\t# update the `view.custom.query_params` object from received payload\n\tfrom helper.helper import sanitize_tree\n\td \u003d sanitize_tree(payload)\n\tdct \u003d sanitize_tree(self.view.custom.query_params)\n\tdct.update(d)\n\tself.view.custom.query_params \u003d dct\n\tif dct.get(\u0027bucket\u0027,None) and dct.get(\u0027site\u0027,None) and dct.get(\u0027view\u0027,None):\n\t\tself.refresh_version_table_data()\n\telse:\n\t\tself.view.custom.raw_data \u003d []\n\t", "sessionScope": true, "viewScope": true }, { "messageType": "refresh_version_table_data", "pageScope": false, "script": "\t# implement your handler here\n\tself.refresh_version_table_data()\n\t", "sessionScope": true, "viewScope": true } ] }, "type": "ia.container.flex" } }