From 8611c8d7994532b35c8ed02dd8afddc8d9abdd96 Mon Sep 17 00:00:00 2001 From: hyh123a Date: Fri, 30 Jul 2021 15:08:20 +0800 Subject: [PATCH 1/4] add the menu api --- myems-api/app.py | 11 +- myems-api/core/menu.py | 240 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 myems-api/core/menu.py diff --git a/myems-api/app.py b/myems-api/app.py index 0537ea8b..5f90d078 100644 --- a/myems-api/app.py +++ b/myems-api/app.py @@ -5,7 +5,7 @@ from core import energyflowdiagram, privilege, textmessage, distributioncircuit, costcenter, point, knowledgefile, meter, gsmmodem, tariff, user, storetype, timezone, \ costfile, offlinemeterfile, version, contact, emailserver, combinedequipment, datasource, equipment, tenant, shopfloor, \ webmessage, distributionsystem, store, emailmessage, tenanttype, wechatmessage, space, gateway, offlinemeter, \ - rule, energycategory, sensor, energyitem, notification + rule, energycategory, sensor, energyitem, notification, menu from reports import advancedreport from reports import distributionsystem as distributionsystemreport from reports import energyflowdiagram as energyflowdiagramreport @@ -244,6 +244,15 @@ api.add_route('/knowledgefiles/{id_}', api.add_route('/knowledgefiles/{id_}/restore', knowledgefile.KnowledgeFileRestore()) +api.add_route('/menus', + menu.MenuCollection()) +api.add_route('/menus/{id_}', + menu.MenuItem()) +api.add_route('/menus/{id_}/children', + menu.MenuChildrenCollection()) +api.add_route('/menus/web', + menu.MenuWebCollection()) + api.add_route('/meters', meter.MeterCollection()) api.add_route('/meters/{id_}', diff --git a/myems-api/core/menu.py b/myems-api/core/menu.py new file mode 100644 index 00000000..eb13e079 --- /dev/null +++ b/myems-api/core/menu.py @@ -0,0 +1,240 @@ +import falcon +import simplejson as json +import mysql.connector +import config +import uuid +from datetime import datetime +from anytree import AnyNode +from anytree.exporter import JsonExporter + + +class MenuCollection: + @staticmethod + def __init__(): + pass + + @staticmethod + def on_options(req, resp): + resp.status = falcon.HTTP_200 + + @staticmethod + def on_get(req, resp): + cnx = mysql.connector.connect(**config.myems_system_db) + cursor = cnx.cursor(dictionary=True) + + query = (" SELECT id, path, name, parent_menu_id, is_hidden " + " FROM tbl_menus ") + cursor.execute(query) + rows_menus = cursor.fetchall() + + result = list() + if rows_menus is not None and len(rows_menus) > 0: + for row in rows_menus: + temp = {"id": row['id'], + "path": row['path'], + "name": row['name'], + "parent_menu_id": row['parent_menu_id'], + "is_hidden": row['is_hidden']} + + result.append(temp) + + cursor.close() + cnx.disconnect() + resp.body = json.dumps(result) + + +class MenuItem: + @staticmethod + def __init__(): + pass + + @staticmethod + def on_options(req, resp, id_): + resp.status = falcon.HTTP_200 + + @staticmethod + def on_get(req, resp, id_): + if not id_.isdigit() or int(id_) <= 0: + raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', + description='API.INVALID_MENU_ID') + + cnx = mysql.connector.connect(**config.myems_system_db) + cursor = cnx.cursor(dictionary=True) + + query = (" SELECT id, path, name, parent_menu_id, is_hidden " + " FROM tbl_menus " + " WHERE id=%s ") + cursor.execute(query, (id_,)) + rows_menu = cursor.fetchone() + + result = None + if rows_menu is not None and len(rows_menu) > 0: + result = {"id": rows_menu['id'], + "path": rows_menu['path'], + "name": rows_menu['name'], + "parent_menu_id": rows_menu['parent_menu_id'], + "is_hidden": rows_menu['is_hidden']} + + cursor.close() + cnx.disconnect() + resp.body = json.dumps(result) + + @staticmethod + def on_put(req, resp, id_): + """Handles PUT requests""" + try: + raw_json = req.stream.read().decode('utf-8') + except Exception as ex: + raise falcon.HTTPError(falcon.HTTP_400, title='API.EXCEPTION', description=ex) + + if not id_.isdigit() or int(id_) <= 0: + raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', + description='API.INVALID_MENU_ID') + + new_values = json.loads(raw_json) + + if 'is_hidden' not in new_values['data'].keys() or \ + not isinstance(new_values['data']['is_hidden'], str) or \ + len(str.strip(new_values['data']['is_hidden'])) == 0: + raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', + description='API.INVALID_IS_HIDDEN') + is_hidden = str.strip(new_values['data']['is_hidden']) + + cnx = mysql.connector.connect(**config.myems_system_db) + cursor = cnx.cursor() + update_row = (" UPDATE tbl_menus " + " SET is_hidden = %s " + " WHERE id = %s ") + cursor.execute(update_row, (is_hidden, + id_)) + cnx.commit() + + cursor.close() + cnx.disconnect() + + resp.status = falcon.HTTP_200 + + +class MenuChildrenCollection: + @staticmethod + def __init__(): + pass + + @staticmethod + def on_options(req, resp, id_): + resp.status = falcon.HTTP_200 + + @staticmethod + def on_get(req, resp, id_): + if not id_.isdigit() or int(id_) <= 0: + raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', + description='API.INVALID_MENU_ID') + + cnx = mysql.connector.connect(**config.myems_system_db) + cursor = cnx.cursor(dictionary=True) + + query = (" SELECT id, path, name, parent_menu_id, is_hidden " + " FROM tbl_menus " + " WHERE id = %s ") + cursor.execute(query, (id_,)) + row_current_menu = cursor.fetchone() + if row_current_menu is None: + cursor.close() + cnx.disconnect() + raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND', + description='API.MENU_NOT_FOUND') + current_menu = None + current_menu_id = None + if row_current_menu is not None and len(row_current_menu) > 0: + for row in row_current_menu: + current_menu = {"id": row['id'], + "path": row['path'], + "name": row['name'], + "parent_menu_id": row['parent_menu_id'], + "is_hidden": row['is_hidden']} + current_menu_id = row['id'] + + query = (" SELECT id, path, name, parent_menu_id, is_hidden" + " FROM tbl_menus " + " WHERE parent_menu_id = %s") + cursor.execute(query, (current_menu_id,)) + rows_menus = cursor.fetchall() + + children_menus = [] + if rows_menus is not None and len(rows_menus) > 0: + for row in rows_menus: + children_menus.append( + { + "id": row['id'], + "path": row['path'], + "name": row['name'], + "parent_menu": current_menu, + "is_hidden": row['is_hidden'] + } + ) + + result = { + "current": current_menu, + "children": children_menus, + } + + cursor.close() + cnx.disconnect() + resp.body = json.dumps(result) + + +class MenuWebCollection: + @staticmethod + def __init__(): + pass + + @staticmethod + def on_options(req, resp): + resp.status = falcon.HTTP_200 + + @staticmethod + def on_get(req, resp): + cnx = mysql.connector.connect(**config.myems_system_db) + cursor = cnx.cursor(dictionary=True) + + query = (" SELECT id, path, parent_menu_id, is_hidden " + " FROM tbl_menus " + " WHERE parent_menu_id is NULL " + " AND is_hidden=0 ") + cursor.execute(query) + rows_menus = cursor.fetchall() + + first_paths = {} + if rows_menus is not None and len(rows_menus) > 0: + for row in rows_menus: + _id = row['id'] + path = row['path'] + first_paths[_id] = { + 'path': path, + 'children': [] + } + + query = (" SELECT id, path, parent_menu_id, is_hidden " + " FROM tbl_menus " + " WHERE parent_menu_id is not NULL " + " AND is_hidden=0 ") + cursor.execute(query) + rows_menus = cursor.fetchall() + + if rows_menus is not None and len(rows_menus) > 0: + for row in rows_menus: + _id = row['id'] + parent_menu_id = row['parent_menu_id'] + path = row['path'] + if parent_menu_id in first_paths.keys(): + first_paths[parent_menu_id]['children'].append(path) + + result = dict() + for _id, item in first_paths.items(): + first_path = item['path'] + children = item['children'] + result[first_path] = children + + cursor.close() + cnx.disconnect() + resp.body = json.dumps(result) From 9bc743f7c9baaca1772357294378c1748f08671b Mon Sep 17 00:00:00 2001 From: hyh123a Date: Fri, 30 Jul 2021 15:14:49 +0800 Subject: [PATCH 2/4] fixed the bug for menu --- myems-api/core/menu.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/myems-api/core/menu.py b/myems-api/core/menu.py index eb13e079..39010276 100644 --- a/myems-api/core/menu.py +++ b/myems-api/core/menu.py @@ -146,13 +146,12 @@ class MenuChildrenCollection: current_menu = None current_menu_id = None if row_current_menu is not None and len(row_current_menu) > 0: - for row in row_current_menu: - current_menu = {"id": row['id'], - "path": row['path'], - "name": row['name'], - "parent_menu_id": row['parent_menu_id'], - "is_hidden": row['is_hidden']} - current_menu_id = row['id'] + current_menu = {"id": row_current_menu['id'], + "path": row_current_menu['path'], + "name": row_current_menu['name'], + "parent_menu_id": row_current_menu['parent_menu_id'], + "is_hidden": row_current_menu['is_hidden']} + current_menu_id = row_current_menu['id'] query = (" SELECT id, path, name, parent_menu_id, is_hidden" " FROM tbl_menus " From 95c1dcca633d64ea189eb31b58e9892555c47bc0 Mon Sep 17 00:00:00 2001 From: hyh123a Date: Fri, 30 Jul 2021 18:58:05 +0800 Subject: [PATCH 3/4] fixed the bug and add the notes --- myems-api/MyEMS.postman_collection.json | 1072 ++++++++++++++++++++++- myems-api/README.md | 29 + myems-api/core/menu.py | 5 +- 3 files changed, 1102 insertions(+), 4 deletions(-) diff --git a/myems-api/MyEMS.postman_collection.json b/myems-api/MyEMS.postman_collection.json index c3bd20a9..e628022f 100644 --- a/myems-api/MyEMS.postman_collection.json +++ b/myems-api/MyEMS.postman_collection.json @@ -1,6 +1,6 @@ { "info": { - "_postman_id": "6678a44a-20bd-4ef2-9a9f-3c47421936c2", + "_postman_id": "8f6cf459-2545-4a7d-973e-509a235ab01c", "name": "MyEMS", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, @@ -7094,6 +7094,1050 @@ "response": [] } ] + }, + { + "name": "Space Copy", + "item": [ + { + "name": "GET All Spaces", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/spaces", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces" + ] + } + }, + "response": [] + }, + { + "name": "GET a Space by ID", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1" + ] + } + }, + "response": [] + }, + { + "name": "POST Create New Space", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\"data\":{\"name\":\"MyEMSSpace\", \"parent_space_id\":1, \"area\":999.99, \"timezone_id\":56, \"is_input_counted\":true, \"is_output_counted\":false, \"contact_id\":1, \"cost_center_id\":1, \"description\":\"Space description\"}}" + }, + "url": { + "raw": "{{base_url}}/spaces", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces" + ] + } + }, + "response": [] + }, + { + "name": "PUT Update a Space", + "request": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\"data\":{\"name\":\"MyEMSSpace\", \"parent_space_id\":2, \"area\":999.99, \"timezone_id\":56, \"is_input_counted\":true, \"is_output_counted\":true, \"contact_id\":1, \"cost_center_id\":1, \"description\":\"Space description\"}}" + }, + "url": { + "raw": "{{base_url}}/spaces/1", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1" + ] + } + }, + "response": [] + }, + { + "name": "DELETE a Space by ID", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/57", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "57" + ] + } + }, + "response": [] + }, + { + "name": "GET All Children of a Space", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/children", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "children" + ] + } + }, + "response": [] + }, + { + "name": "GET All Combined Equipments of a Space", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/combinedequipments", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "combinedequipments" + ] + } + }, + "response": [] + }, + { + "name": "POST Bind a Combined Equipment to a Space", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\"data\":{\"combined_equipment_id\":1}}" + }, + "url": { + "raw": "{{base_url}}/spaces/1/combinedequipments", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "combinedequipments" + ] + } + }, + "response": [] + }, + { + "name": "DELETE a Combined Equipment from Space", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/combinedequipments/1", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "combinedequipments", + "1" + ] + } + }, + "response": [] + }, + { + "name": "GET All Equipments of a Space", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/equipments", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "equipments" + ] + } + }, + "response": [] + }, + { + "name": "POST Bind an Equipment to a Space", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\"data\":{\"equipment_id\":1}}" + }, + "url": { + "raw": "{{base_url}}/spaces/1/equipments", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "equipments" + ] + } + }, + "response": [] + }, + { + "name": "DELETE an Equipment from Space", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/equipments/1", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "equipments", + "1" + ] + } + }, + "response": [] + }, + { + "name": "GET All Meters of a Space", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/meters", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "meters" + ] + } + }, + "response": [] + }, + { + "name": "POST Bind a Meter to a Space", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\"data\":{\"meter_id\":1}}" + }, + "url": { + "raw": "{{base_url}}/spaces/1/meters", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "meters" + ] + } + }, + "response": [] + }, + { + "name": "DELETE a Meter from Space", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/meters/1", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "meters", + "1" + ] + } + }, + "response": [] + }, + { + "name": "GET All OfflineMeters of a Space", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/offlinemeters", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "offlinemeters" + ] + } + }, + "response": [] + }, + { + "name": "POST Bind an OfflineMeter to a Space", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\"data\":{\"offline_meter_id\":1}}" + }, + "url": { + "raw": "{{base_url}}/spaces/1/offlinemeters", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "offlinemeters" + ] + } + }, + "response": [] + }, + { + "name": "DELETE an Offline Meter from Space", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/offlinemeters/1", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "offlinemeters", + "1" + ] + } + }, + "response": [] + }, + { + "name": "GET All Points of a Space", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/virtualmeters", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "virtualmeters" + ] + } + }, + "response": [] + }, + { + "name": "POST Bind a Point to a Space", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\"data\":{\"point_id\":1}}" + }, + "url": { + "raw": "{{base_url}}/spaces/1/points", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "points" + ] + } + }, + "response": [] + }, + { + "name": "DELETE a Point from Space", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/points/3", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "points", + "3" + ] + } + }, + "response": [] + }, + { + "name": "GET All Sensors of a Space", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/sensors", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "sensors" + ] + } + }, + "response": [] + }, + { + "name": "POST Bind a Sensor to a Space", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\"data\":{\"sensor_id\":1}}" + }, + "url": { + "raw": "{{base_url}}/spaces/1/sensors", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "sensors" + ] + } + }, + "response": [] + }, + { + "name": "DELETE a Sensor from Space", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/sensors/1", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "sensors", + "1" + ] + } + }, + "response": [] + }, + { + "name": "GET All Shopfloors of a Space", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/shopfloors", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "shopfloors" + ] + } + }, + "response": [] + }, + { + "name": "POST Bind a Shopfloor to a Space", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\"data\":{\"shopfloor_id\":1}}" + }, + "url": { + "raw": "{{base_url}}/spaces/1/shopfloors", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "shopfloors" + ] + } + }, + "response": [] + }, + { + "name": "DELETE a Shopfloor from a Space", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/shopfloors/1", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "shopfloors", + "1" + ] + } + }, + "response": [] + }, + { + "name": "GET All Stores of a Space", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/stores", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "stores" + ] + } + }, + "response": [] + }, + { + "name": "POST Bind a Store to a Space", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\"data\":{\"store_id\":1}}" + }, + "url": { + "raw": "{{base_url}}/spaces/1/stores", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "stores" + ] + } + }, + "response": [] + }, + { + "name": "DELETE a Store from Space", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/stores/1", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "stores", + "1" + ] + } + }, + "response": [] + }, + { + "name": "GET All Tenants of a Space", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/tenants", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "tenants" + ] + } + }, + "response": [] + }, + { + "name": "POST Bind a Tenant to a Space", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\"data\":{\"tenant_id\":1}}" + }, + "url": { + "raw": "{{base_url}}/spaces/1/tenants", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "tenants" + ] + } + }, + "response": [] + }, + { + "name": "DELETE a Tenant from Space", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/tenants/1", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "tenants", + "1" + ] + } + }, + "response": [] + }, + { + "name": "GET All Virtual Meters of a Space", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/virtualmeters", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "virtualmeters" + ] + } + }, + "response": [] + }, + { + "name": "POST Bind a Virtual Meter to a Space", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\"data\":{\"virtual_meter_id\":1}}" + }, + "url": { + "raw": "{{base_url}}/spaces/1/virtualmeters", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "virtualmeters" + ] + } + }, + "response": [] + }, + { + "name": "DELETE a Virtual Meter from Space", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{base_url}}/spaces/1/virtualmeters/1", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "1", + "virtualmeters", + "1" + ] + } + }, + "response": [] + }, + { + "name": "GET Space Tree", + "request": { + "method": "GET", + "header": [ + { + "key": "User-UUID", + "value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4", + "type": "text" + }, + { + "key": "Token", + "value": "e1879592cb12e4cbf0e1762ed42edde699499cd9", + "type": "text" + } + ], + "url": { + "raw": "{{base_url}}/spaces/tree", + "host": [ + "{{base_url}}" + ], + "path": [ + "spaces", + "tree" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "Menu", + "item": [ + { + "name": "GET All Menus", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/menus", + "host": [ + "{{base_url}}" + ], + "path": [ + "menus" + ] + } + }, + "response": [ + { + "name": "GET All Menus", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/menus", + "host": [ + "{{base_url}}" + ], + "path": [ + "menus" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Server", + "value": "gunicorn/20.0.4" + }, + { + "key": "Date", + "value": "Fri, 30 Jul 2021 10:45:21 GMT" + }, + { + "key": "Connection", + "value": "close" + }, + { + "key": "content-length", + "value": "9497" + }, + { + "key": "content-type", + "value": "application/json" + } + ], + "cookie": [], + "body": "[\n {\n \"id\": 1,\n \"path\": \"/dashboard\",\n \"name\": \"Dashboard\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 100,\n \"path\": \"/space\",\n \"name\": \"Space Data\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 101,\n \"path\": \"/space/energycategory\",\n \"name\": \"Energy Category Data\",\n \"parent_menu_id\": 100,\n \"is_hidden\": 0\n },\n {\n \"id\": 102,\n \"path\": \"/space/energyitem\",\n \"name\": \"Energy Item Data\",\n \"parent_menu_id\": 100,\n \"is_hidden\": 0\n },\n {\n \"id\": 103,\n \"path\": \"/space/cost\",\n \"name\": \"Cost\",\n \"parent_menu_id\": 100,\n \"is_hidden\": 0\n },\n {\n \"id\": 104,\n \"path\": \"/space/output\",\n \"name\": \"Output\",\n \"parent_menu_id\": 100,\n \"is_hidden\": 0\n },\n {\n \"id\": 105,\n \"path\": \"/space/income\",\n \"name\": \"Income\",\n \"parent_menu_id\": 100,\n \"is_hidden\": 0\n },\n {\n \"id\": 106,\n \"path\": \"/space/efficiency\",\n \"name\": \"Efficiency\",\n \"parent_menu_id\": 100,\n \"is_hidden\": 0\n },\n {\n \"id\": 107,\n \"path\": \"/space/load\",\n \"name\": \"Load\",\n \"parent_menu_id\": 100,\n \"is_hidden\": 0\n },\n {\n \"id\": 108,\n \"path\": \"/space/statistics\",\n \"name\": \"Statistics\",\n \"parent_menu_id\": 100,\n \"is_hidden\": 0\n },\n {\n \"id\": 109,\n \"path\": \"/space/saving\",\n \"name\": \"Saving\",\n \"parent_menu_id\": 100,\n \"is_hidden\": 0\n },\n {\n \"id\": 200,\n \"path\": \"/equipment\",\n \"name\": \"Equipment Data\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 201,\n \"path\": \"/equipment/energycategory\",\n \"name\": \"Energy Category Data\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 202,\n \"path\": \"/equipment/energyitem\",\n \"name\": \"Energy Item Data\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 203,\n \"path\": \"/equipment/cost\",\n \"name\": \"Cost\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 204,\n \"path\": \"/equipment/output\",\n \"name\": \"Output\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 205,\n \"path\": \"/equipment/income\",\n \"name\": \"Income\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 206,\n \"path\": \"/equipment/efficiency\",\n \"name\": \"Efficiency\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 207,\n \"path\": \"/equipment/load\",\n \"name\": \"Load\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 208,\n \"path\": \"/equipment/statistics\",\n \"name\": \"Statistics\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 209,\n \"path\": \"/equipment/saving\",\n \"name\": \"Saving\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 210,\n \"path\": \"/equipment/batch\",\n \"name\": \"Batch Analysis\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 211,\n \"path\": \"/equipment/tracking\",\n \"name\": \"Equipment Tracking\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 300,\n \"path\": \"/meter\",\n \"name\": \"Meter Data\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 301,\n \"path\": \"/meter/meterenergy\",\n \"name\": \"Meter Energy\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 302,\n \"path\": \"/meter/metercost\",\n \"name\": \"Meter Cost\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 303,\n \"path\": \"/meter/metertrend\",\n \"name\": \"Meter Trend\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 304,\n \"path\": \"/meter/meterrealtime\",\n \"name\": \"Meter Realtime\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 305,\n \"path\": \"/meter/metersubmetersbalance\",\n \"name\": \"Master Meter Submeters Balance\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 306,\n \"path\": \"/meter/virtualmeterenergy\",\n \"name\": \"Virtual Meter Energy\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 307,\n \"path\": \"/meter/virtualmetercost\",\n \"name\": \"Virtual Meter Cost\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 308,\n \"path\": \"/meter/offlinemeterenergy\",\n \"name\": \"Offline Meter Energy\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 309,\n \"path\": \"/meter/offlinemetercost\",\n \"name\": \"Offline Meter Cost\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 310,\n \"path\": \"/meter/batch\",\n \"name\": \"Batch Analysis\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 311,\n \"path\": \"/meter/tracking\",\n \"name\": \"Meter Tracking\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 400,\n \"path\": \"/tenant\",\n \"name\": \"Tenant Data\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 401,\n \"path\": \"/tenant/energycategory\",\n \"name\": \"Energy Category Data\",\n \"parent_menu_id\": 400,\n \"is_hidden\": 0\n },\n {\n \"id\": 402,\n \"path\": \"/tenant/energyitem\",\n \"name\": \"Energy Item Data\",\n \"parent_menu_id\": 400,\n \"is_hidden\": 0\n },\n {\n \"id\": 403,\n \"path\": \"/tenant/cost\",\n \"name\": \"Cost\",\n \"parent_menu_id\": 400,\n \"is_hidden\": 0\n },\n {\n \"id\": 404,\n \"path\": \"/tenant/load\",\n \"name\": \"Load\",\n \"parent_menu_id\": 400,\n \"is_hidden\": 0\n },\n {\n \"id\": 405,\n \"path\": \"/tenant/statistics\",\n \"name\": \"Statistics\",\n \"parent_menu_id\": 400,\n \"is_hidden\": 0\n },\n {\n \"id\": 406,\n \"path\": \"/tenant/saving\",\n \"name\": \"Saving\",\n \"parent_menu_id\": 400,\n \"is_hidden\": 0\n },\n {\n \"id\": 407,\n \"path\": \"/tenant/bill\",\n \"name\": \"Tenant Bill\",\n \"parent_menu_id\": 400,\n \"is_hidden\": 0\n },\n {\n \"id\": 408,\n \"path\": \"/tenant/batch\",\n \"name\": \"Batch Analysis\",\n \"parent_menu_id\": 400,\n \"is_hidden\": 0\n },\n {\n \"id\": 500,\n \"path\": \"/store\",\n \"name\": \"Store Data\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 501,\n \"path\": \"/store/energycategory\",\n \"name\": \"Energy Category Data\",\n \"parent_menu_id\": 500,\n \"is_hidden\": 0\n },\n {\n \"id\": 502,\n \"path\": \"/store/energyitem\",\n \"name\": \"Energy Item Data\",\n \"parent_menu_id\": 500,\n \"is_hidden\": 0\n },\n {\n \"id\": 503,\n \"path\": \"/store/cost\",\n \"name\": \"Cost\",\n \"parent_menu_id\": 500,\n \"is_hidden\": 0\n },\n {\n \"id\": 504,\n \"path\": \"/store/load\",\n \"name\": \"Load\",\n \"parent_menu_id\": 500,\n \"is_hidden\": 0\n },\n {\n \"id\": 505,\n \"path\": \"/store/statistics\",\n \"name\": \"Statistics\",\n \"parent_menu_id\": 500,\n \"is_hidden\": 0\n },\n {\n \"id\": 506,\n \"path\": \"/store/saving\",\n \"name\": \"Saving\",\n \"parent_menu_id\": 500,\n \"is_hidden\": 0\n },\n {\n \"id\": 507,\n \"path\": \"/store/batch\",\n \"name\": \"Batch Analysis\",\n \"parent_menu_id\": 500,\n \"is_hidden\": 0\n },\n {\n \"id\": 600,\n \"path\": \"/shopfloor\",\n \"name\": \"Shopfloor Data\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 601,\n \"path\": \"/shopfloor/energycategory\",\n \"name\": \"Energy Category Data\",\n \"parent_menu_id\": 600,\n \"is_hidden\": 0\n },\n {\n \"id\": 602,\n \"path\": \"/shopfloor/energyitem\",\n \"name\": \"Energy Item Data\",\n \"parent_menu_id\": 600,\n \"is_hidden\": 0\n },\n {\n \"id\": 603,\n \"path\": \"/shopfloor/cost\",\n \"name\": \"Cost\",\n \"parent_menu_id\": 600,\n \"is_hidden\": 0\n },\n {\n \"id\": 604,\n \"path\": \"/shopfloor/load\",\n \"name\": \"Load\",\n \"parent_menu_id\": 600,\n \"is_hidden\": 0\n },\n {\n \"id\": 605,\n \"path\": \"/shopfloor/statistics\",\n \"name\": \"Statistics\",\n \"parent_menu_id\": 600,\n \"is_hidden\": 0\n },\n {\n \"id\": 606,\n \"path\": \"/shopfloor/saving\",\n \"name\": \"Saving\",\n \"parent_menu_id\": 600,\n \"is_hidden\": 0\n },\n {\n \"id\": 607,\n \"path\": \"/shopfloor/batch\",\n \"name\": \"Batch Analysis\",\n \"parent_menu_id\": 600,\n \"is_hidden\": 0\n },\n {\n \"id\": 700,\n \"path\": \"/combinedequipment\",\n \"name\": \"Combined Equipment Data\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 701,\n \"path\": \"/combinedequipment/energycategory\",\n \"name\": \"Energy Category Data\",\n \"parent_menu_id\": 700,\n \"is_hidden\": 0\n },\n {\n \"id\": 702,\n \"path\": \"/combinedequipment/energyitem\",\n \"name\": \"Energy Item Data\",\n \"parent_menu_id\": 700,\n \"is_hidden\": 0\n },\n {\n \"id\": 703,\n \"path\": \"/combinedequipment/cost\",\n \"name\": \"Cost\",\n \"parent_menu_id\": 700,\n \"is_hidden\": 0\n },\n {\n \"id\": 704,\n \"path\": \"/combinedequipment/output\",\n \"name\": \"Output\",\n \"parent_menu_id\": 700,\n \"is_hidden\": 0\n },\n {\n \"id\": 705,\n \"path\": \"/combinedequipment/income\",\n \"name\": \"Income\",\n \"parent_menu_id\": 700,\n \"is_hidden\": 0\n },\n {\n \"id\": 706,\n \"path\": \"/combinedequipment/efficiency\",\n \"name\": \"Efficiency\",\n \"parent_menu_id\": 700,\n \"is_hidden\": 0\n },\n {\n \"id\": 707,\n \"path\": \"/combinedequipment/load\",\n \"name\": \"Load\",\n \"parent_menu_id\": 700,\n \"is_hidden\": 0\n },\n {\n \"id\": 708,\n \"path\": \"/combinedequipment/statistics\",\n \"name\": \"Statistics\",\n \"parent_menu_id\": 700,\n \"is_hidden\": 0\n },\n {\n \"id\": 709,\n \"path\": \"/combinedequipment/saving\",\n \"name\": \"Saving\",\n \"parent_menu_id\": 700,\n \"is_hidden\": 0\n },\n {\n \"id\": 710,\n \"path\": \"/combinedequipment/batch\",\n \"name\": \"Batch Analysis\",\n \"parent_menu_id\": 700,\n \"is_hidden\": 0\n },\n {\n \"id\": 800,\n \"path\": \"/auxiliarysystem\",\n \"name\": \"Auxiliary System\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 801,\n \"path\": \"/auxiliarysystem/energyflowdiagram\",\n \"name\": \"Energy Flow Diagram\",\n \"parent_menu_id\": 800,\n \"is_hidden\": 0\n },\n {\n \"id\": 802,\n \"path\": \"/auxiliarysystem/distributionsystem\",\n \"name\": \"Distribution System\",\n \"parent_menu_id\": 800,\n \"is_hidden\": 0\n },\n {\n \"id\": 900,\n \"path\": \"/fdd\",\n \"name\": \"Fault Detection & Diagnostics\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 901,\n \"path\": \"/fdd/space\",\n \"name\": \"Space Faults Data\",\n \"parent_menu_id\": 900,\n \"is_hidden\": 0\n },\n {\n \"id\": 902,\n \"path\": \"/fdd/equipment\",\n \"name\": \"Equipment Faults Data\",\n \"parent_menu_id\": 900,\n \"is_hidden\": 0\n },\n {\n \"id\": 903,\n \"path\": \"/fdd/combinedequipment\",\n \"name\": \"Combined Equipment Faults Data\",\n \"parent_menu_id\": 900,\n \"is_hidden\": 0\n },\n {\n \"id\": 904,\n \"path\": \"/fdd/tenant\",\n \"name\": \"Tenant Faults Data\",\n \"parent_menu_id\": 900,\n \"is_hidden\": 0\n },\n {\n \"id\": 905,\n \"path\": \"/fdd/store\",\n \"name\": \"Store Faults Data\",\n \"parent_menu_id\": 900,\n \"is_hidden\": 0\n },\n {\n \"id\": 906,\n \"path\": \"/fdd/shopfloor\",\n \"name\": \"Shopfloor Faults Data\",\n \"parent_menu_id\": 900,\n \"is_hidden\": 0\n },\n {\n \"id\": 1000,\n \"path\": \"/monitoring\",\n \"name\": \"Monitoring\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 1001,\n \"path\": \"/monitoring/space\",\n \"name\": \"Space Equipments\",\n \"parent_menu_id\": 1000,\n \"is_hidden\": 0\n },\n {\n \"id\": 1002,\n \"path\": \"/monitoring/equipment\",\n \"name\": \"Combined Equipments\",\n \"parent_menu_id\": 1000,\n \"is_hidden\": 0\n },\n {\n \"id\": 1003,\n \"path\": \"/monitoring/combinedequipment\",\n \"name\": \"Tenant Equipments\",\n \"parent_menu_id\": 1000,\n \"is_hidden\": 0\n },\n {\n \"id\": 1004,\n \"path\": \"/monitoring/tenant\",\n \"name\": \"Store Equipments\",\n \"parent_menu_id\": 1000,\n \"is_hidden\": 0\n },\n {\n \"id\": 1005,\n \"path\": \"/monitoring/store\",\n \"name\": \"Shopfloor Equipments\",\n \"parent_menu_id\": 1000,\n \"is_hidden\": 0\n },\n {\n \"id\": 1100,\n \"path\": \"/advancedreporting\",\n \"name\": \"Advanced Reporting\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 1200,\n \"path\": \"/knowledgebase\",\n \"name\": \"Knowledge Base\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n }\n]" + } + ] + }, + { + "name": "GET a Menu by ID", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/menus/1", + "host": [ + "{{base_url}}" + ], + "path": [ + "menus", + "1" + ] + } + }, + "response": [ + { + "name": "GET a Menu by ID", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/menus/1", + "host": [ + "{{base_url}}" + ], + "path": [ + "menus", + "1" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Server", + "value": "gunicorn/20.0.4" + }, + { + "key": "Date", + "value": "Fri, 30 Jul 2021 10:45:44 GMT" + }, + { + "key": "Connection", + "value": "close" + }, + { + "key": "content-length", + "value": "92" + }, + { + "key": "content-type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"id\": 1,\n \"path\": \"/dashboard\",\n \"name\": \"Dashboard\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n}" + } + ] + }, + { + "name": "PUT Update a Menu", + "request": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"data\": {\n \"is_hidden\": false\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{base_url}}/menus/1", + "host": [ + "{{base_url}}" + ], + "path": [ + "menus", + "1" + ] + } + }, + "response": [ + { + "name": "PUT Update a Menu", + "originalRequest": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"data\": {\n \"is_hidden\": false\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{base_url}}/menus/1", + "host": [ + "{{base_url}}" + ], + "path": [ + "menus", + "1" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Server", + "value": "gunicorn/20.0.4" + }, + { + "key": "Date", + "value": "Fri, 30 Jul 2021 10:49:20 GMT" + }, + { + "key": "Connection", + "value": "close" + }, + { + "key": "content-length", + "value": "0" + }, + { + "key": "content-type", + "value": "application/json" + } + ], + "cookie": [], + "body": null + } + ] + }, + { + "name": "GET All Children of a Menu", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/menus/1/children", + "host": [ + "{{base_url}}" + ], + "path": [ + "menus", + "1", + "children" + ] + } + }, + "response": [ + { + "name": "GET All Children of a Space", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/menus/1/children", + "host": [ + "{{base_url}}" + ], + "path": [ + "menus", + "1", + "children" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Server", + "value": "gunicorn/20.0.4" + }, + { + "key": "Date", + "value": "Fri, 30 Jul 2021 10:50:23 GMT" + }, + { + "key": "Connection", + "value": "close" + }, + { + "key": "content-length", + "value": "121" + }, + { + "key": "content-type", + "value": "application/json" + } + ], + "cookie": [], + "body": "{\n \"current\": {\n \"id\": 1,\n \"path\": \"/dashboard\",\n \"name\": \"Dashboard\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n \"children\": []\n}" + } + ] + } + ] } ] }, @@ -9958,5 +11002,31 @@ }, "response": [] } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "key": "base_url", + "value": "127.0.0.1:8000" + } ] } \ No newline at end of file diff --git a/myems-api/README.md b/myems-api/README.md index 3467f663..684b8281 100644 --- a/myems-api/README.md +++ b/myems-api/README.md @@ -953,6 +953,35 @@ $ curl -i -H "Content-Type: application/TBD" -X POST -d 'file: (binary)' {{base_ $ curl -i -X GET {{base_url}}/knowledgefiles/{id}/restore ``` +### Menu +* GET Menu by ID +```bash +$ curl -i -X GET {{base_url}}/menus/{id} +``` +Result + +| Name | Data Type | Description | +|---------------|-----------|-------------------------------------------| +| id | integer | Menu ID | +| name | string | Menu name | +| path | string | Menu path | +| parent_menu_id| integer | Parent Menu ID | +| is_hidden | boolean | The menu status| | + +* GET All Menus +```bash +$ curl -i -X GET {{base_url}}/menus +``` +* PUT Update a Menu +```bash +$ curl -i -H "Content-Type: application/json" -X PUT -d '{"data":{"is_hidden": false}}' {{base_url}}/menus/{id} +``` +* Get All Menus for web +```bash +$ curl -i -X GET {{base_url}}/web/menus +``` + + ### Meter * GET Meter by ID diff --git a/myems-api/core/menu.py b/myems-api/core/menu.py index 39010276..1673f33f 100644 --- a/myems-api/core/menu.py +++ b/myems-api/core/menu.py @@ -94,11 +94,10 @@ class MenuItem: new_values = json.loads(raw_json) if 'is_hidden' not in new_values['data'].keys() or \ - not isinstance(new_values['data']['is_hidden'], str) or \ - len(str.strip(new_values['data']['is_hidden'])) == 0: + not isinstance(new_values['data']['is_hidden'], bool): raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_IS_HIDDEN') - is_hidden = str.strip(new_values['data']['is_hidden']) + is_hidden = new_values['data']['is_hidden'] cnx = mysql.connector.connect(**config.myems_system_db) cursor = cnx.cursor() From f3fe884268eadc8cd4989ffe4b9edbbcdfb2d6d7 Mon Sep 17 00:00:00 2001 From: "13621160019@163.com" <13621160019@163.com> Date: Sun, 1 Aug 2021 12:13:20 +0800 Subject: [PATCH 4/4] updated README and Postman Collection for Menu of API --- myems-api/MyEMS.postman_collection.json | 1171 ++--------------------- myems-api/README.md | 12 +- 2 files changed, 109 insertions(+), 1074 deletions(-) diff --git a/myems-api/MyEMS.postman_collection.json b/myems-api/MyEMS.postman_collection.json index e628022f..cf23dbdf 100644 --- a/myems-api/MyEMS.postman_collection.json +++ b/myems-api/MyEMS.postman_collection.json @@ -1,6 +1,6 @@ { "info": { - "_postman_id": "8f6cf459-2545-4a7d-973e-509a235ab01c", + "_postman_id": "6678a44a-20bd-4ef2-9a9f-3c47421936c2", "name": "MyEMS", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, @@ -2904,6 +2904,105 @@ } ] }, + { + "name": "Menu", + "item": [ + { + "name": "GET All Menus", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/menus", + "host": [ + "{{base_url}}" + ], + "path": [ + "menus" + ] + } + }, + "response": [] + }, + { + "name": "GET Menu by ID", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/menus/1", + "host": [ + "{{base_url}}" + ], + "path": [ + "menus", + "1" + ] + } + }, + "response": [] + }, + { + "name": "PUT Update a Menu", + "request": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\"data\":{\"is_hidden\":true}}" + }, + "url": { + "raw": "{{base_url}}/menus/1", + "host": [ + "{{base_url}}" + ], + "path": [ + "menus", + "1" + ] + } + }, + "response": [] + }, + { + "name": "GET All Children of Menu by ID", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/menus/100/children", + "host": [ + "{{base_url}}" + ], + "path": [ + "menus", + "100", + "children" + ] + } + }, + "response": [] + }, + { + "name": "GET All Menus for Web UI", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/menus/web", + "host": [ + "{{base_url}}" + ], + "path": [ + "menus", + "web" + ] + } + }, + "response": [] + } + ] + }, { "name": "Meter", "item": [ @@ -7094,1050 +7193,6 @@ "response": [] } ] - }, - { - "name": "Space Copy", - "item": [ - { - "name": "GET All Spaces", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/spaces", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces" - ] - } - }, - "response": [] - }, - { - "name": "GET a Space by ID", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1" - ] - } - }, - "response": [] - }, - { - "name": "POST Create New Space", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\"data\":{\"name\":\"MyEMSSpace\", \"parent_space_id\":1, \"area\":999.99, \"timezone_id\":56, \"is_input_counted\":true, \"is_output_counted\":false, \"contact_id\":1, \"cost_center_id\":1, \"description\":\"Space description\"}}" - }, - "url": { - "raw": "{{base_url}}/spaces", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces" - ] - } - }, - "response": [] - }, - { - "name": "PUT Update a Space", - "request": { - "method": "PUT", - "header": [], - "body": { - "mode": "raw", - "raw": "{\"data\":{\"name\":\"MyEMSSpace\", \"parent_space_id\":2, \"area\":999.99, \"timezone_id\":56, \"is_input_counted\":true, \"is_output_counted\":true, \"contact_id\":1, \"cost_center_id\":1, \"description\":\"Space description\"}}" - }, - "url": { - "raw": "{{base_url}}/spaces/1", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1" - ] - } - }, - "response": [] - }, - { - "name": "DELETE a Space by ID", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/57", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "57" - ] - } - }, - "response": [] - }, - { - "name": "GET All Children of a Space", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/children", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "children" - ] - } - }, - "response": [] - }, - { - "name": "GET All Combined Equipments of a Space", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/combinedequipments", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "combinedequipments" - ] - } - }, - "response": [] - }, - { - "name": "POST Bind a Combined Equipment to a Space", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\"data\":{\"combined_equipment_id\":1}}" - }, - "url": { - "raw": "{{base_url}}/spaces/1/combinedequipments", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "combinedequipments" - ] - } - }, - "response": [] - }, - { - "name": "DELETE a Combined Equipment from Space", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/combinedequipments/1", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "combinedequipments", - "1" - ] - } - }, - "response": [] - }, - { - "name": "GET All Equipments of a Space", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/equipments", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "equipments" - ] - } - }, - "response": [] - }, - { - "name": "POST Bind an Equipment to a Space", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\"data\":{\"equipment_id\":1}}" - }, - "url": { - "raw": "{{base_url}}/spaces/1/equipments", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "equipments" - ] - } - }, - "response": [] - }, - { - "name": "DELETE an Equipment from Space", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/equipments/1", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "equipments", - "1" - ] - } - }, - "response": [] - }, - { - "name": "GET All Meters of a Space", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/meters", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "meters" - ] - } - }, - "response": [] - }, - { - "name": "POST Bind a Meter to a Space", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\"data\":{\"meter_id\":1}}" - }, - "url": { - "raw": "{{base_url}}/spaces/1/meters", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "meters" - ] - } - }, - "response": [] - }, - { - "name": "DELETE a Meter from Space", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/meters/1", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "meters", - "1" - ] - } - }, - "response": [] - }, - { - "name": "GET All OfflineMeters of a Space", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/offlinemeters", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "offlinemeters" - ] - } - }, - "response": [] - }, - { - "name": "POST Bind an OfflineMeter to a Space", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\"data\":{\"offline_meter_id\":1}}" - }, - "url": { - "raw": "{{base_url}}/spaces/1/offlinemeters", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "offlinemeters" - ] - } - }, - "response": [] - }, - { - "name": "DELETE an Offline Meter from Space", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/offlinemeters/1", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "offlinemeters", - "1" - ] - } - }, - "response": [] - }, - { - "name": "GET All Points of a Space", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/virtualmeters", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "virtualmeters" - ] - } - }, - "response": [] - }, - { - "name": "POST Bind a Point to a Space", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\"data\":{\"point_id\":1}}" - }, - "url": { - "raw": "{{base_url}}/spaces/1/points", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "points" - ] - } - }, - "response": [] - }, - { - "name": "DELETE a Point from Space", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/points/3", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "points", - "3" - ] - } - }, - "response": [] - }, - { - "name": "GET All Sensors of a Space", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/sensors", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "sensors" - ] - } - }, - "response": [] - }, - { - "name": "POST Bind a Sensor to a Space", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\"data\":{\"sensor_id\":1}}" - }, - "url": { - "raw": "{{base_url}}/spaces/1/sensors", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "sensors" - ] - } - }, - "response": [] - }, - { - "name": "DELETE a Sensor from Space", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/sensors/1", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "sensors", - "1" - ] - } - }, - "response": [] - }, - { - "name": "GET All Shopfloors of a Space", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/shopfloors", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "shopfloors" - ] - } - }, - "response": [] - }, - { - "name": "POST Bind a Shopfloor to a Space", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\"data\":{\"shopfloor_id\":1}}" - }, - "url": { - "raw": "{{base_url}}/spaces/1/shopfloors", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "shopfloors" - ] - } - }, - "response": [] - }, - { - "name": "DELETE a Shopfloor from a Space", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/shopfloors/1", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "shopfloors", - "1" - ] - } - }, - "response": [] - }, - { - "name": "GET All Stores of a Space", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/stores", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "stores" - ] - } - }, - "response": [] - }, - { - "name": "POST Bind a Store to a Space", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\"data\":{\"store_id\":1}}" - }, - "url": { - "raw": "{{base_url}}/spaces/1/stores", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "stores" - ] - } - }, - "response": [] - }, - { - "name": "DELETE a Store from Space", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/stores/1", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "stores", - "1" - ] - } - }, - "response": [] - }, - { - "name": "GET All Tenants of a Space", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/tenants", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "tenants" - ] - } - }, - "response": [] - }, - { - "name": "POST Bind a Tenant to a Space", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\"data\":{\"tenant_id\":1}}" - }, - "url": { - "raw": "{{base_url}}/spaces/1/tenants", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "tenants" - ] - } - }, - "response": [] - }, - { - "name": "DELETE a Tenant from Space", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/tenants/1", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "tenants", - "1" - ] - } - }, - "response": [] - }, - { - "name": "GET All Virtual Meters of a Space", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/virtualmeters", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "virtualmeters" - ] - } - }, - "response": [] - }, - { - "name": "POST Bind a Virtual Meter to a Space", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\"data\":{\"virtual_meter_id\":1}}" - }, - "url": { - "raw": "{{base_url}}/spaces/1/virtualmeters", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "virtualmeters" - ] - } - }, - "response": [] - }, - { - "name": "DELETE a Virtual Meter from Space", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{base_url}}/spaces/1/virtualmeters/1", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "1", - "virtualmeters", - "1" - ] - } - }, - "response": [] - }, - { - "name": "GET Space Tree", - "request": { - "method": "GET", - "header": [ - { - "key": "User-UUID", - "value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4", - "type": "text" - }, - { - "key": "Token", - "value": "e1879592cb12e4cbf0e1762ed42edde699499cd9", - "type": "text" - } - ], - "url": { - "raw": "{{base_url}}/spaces/tree", - "host": [ - "{{base_url}}" - ], - "path": [ - "spaces", - "tree" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Menu", - "item": [ - { - "name": "GET All Menus", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/menus", - "host": [ - "{{base_url}}" - ], - "path": [ - "menus" - ] - } - }, - "response": [ - { - "name": "GET All Menus", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/menus", - "host": [ - "{{base_url}}" - ], - "path": [ - "menus" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Server", - "value": "gunicorn/20.0.4" - }, - { - "key": "Date", - "value": "Fri, 30 Jul 2021 10:45:21 GMT" - }, - { - "key": "Connection", - "value": "close" - }, - { - "key": "content-length", - "value": "9497" - }, - { - "key": "content-type", - "value": "application/json" - } - ], - "cookie": [], - "body": "[\n {\n \"id\": 1,\n \"path\": \"/dashboard\",\n \"name\": \"Dashboard\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 100,\n \"path\": \"/space\",\n \"name\": \"Space Data\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 101,\n \"path\": \"/space/energycategory\",\n \"name\": \"Energy Category Data\",\n \"parent_menu_id\": 100,\n \"is_hidden\": 0\n },\n {\n \"id\": 102,\n \"path\": \"/space/energyitem\",\n \"name\": \"Energy Item Data\",\n \"parent_menu_id\": 100,\n \"is_hidden\": 0\n },\n {\n \"id\": 103,\n \"path\": \"/space/cost\",\n \"name\": \"Cost\",\n \"parent_menu_id\": 100,\n \"is_hidden\": 0\n },\n {\n \"id\": 104,\n \"path\": \"/space/output\",\n \"name\": \"Output\",\n \"parent_menu_id\": 100,\n \"is_hidden\": 0\n },\n {\n \"id\": 105,\n \"path\": \"/space/income\",\n \"name\": \"Income\",\n \"parent_menu_id\": 100,\n \"is_hidden\": 0\n },\n {\n \"id\": 106,\n \"path\": \"/space/efficiency\",\n \"name\": \"Efficiency\",\n \"parent_menu_id\": 100,\n \"is_hidden\": 0\n },\n {\n \"id\": 107,\n \"path\": \"/space/load\",\n \"name\": \"Load\",\n \"parent_menu_id\": 100,\n \"is_hidden\": 0\n },\n {\n \"id\": 108,\n \"path\": \"/space/statistics\",\n \"name\": \"Statistics\",\n \"parent_menu_id\": 100,\n \"is_hidden\": 0\n },\n {\n \"id\": 109,\n \"path\": \"/space/saving\",\n \"name\": \"Saving\",\n \"parent_menu_id\": 100,\n \"is_hidden\": 0\n },\n {\n \"id\": 200,\n \"path\": \"/equipment\",\n \"name\": \"Equipment Data\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 201,\n \"path\": \"/equipment/energycategory\",\n \"name\": \"Energy Category Data\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 202,\n \"path\": \"/equipment/energyitem\",\n \"name\": \"Energy Item Data\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 203,\n \"path\": \"/equipment/cost\",\n \"name\": \"Cost\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 204,\n \"path\": \"/equipment/output\",\n \"name\": \"Output\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 205,\n \"path\": \"/equipment/income\",\n \"name\": \"Income\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 206,\n \"path\": \"/equipment/efficiency\",\n \"name\": \"Efficiency\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 207,\n \"path\": \"/equipment/load\",\n \"name\": \"Load\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 208,\n \"path\": \"/equipment/statistics\",\n \"name\": \"Statistics\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 209,\n \"path\": \"/equipment/saving\",\n \"name\": \"Saving\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 210,\n \"path\": \"/equipment/batch\",\n \"name\": \"Batch Analysis\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 211,\n \"path\": \"/equipment/tracking\",\n \"name\": \"Equipment Tracking\",\n \"parent_menu_id\": 200,\n \"is_hidden\": 0\n },\n {\n \"id\": 300,\n \"path\": \"/meter\",\n \"name\": \"Meter Data\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 301,\n \"path\": \"/meter/meterenergy\",\n \"name\": \"Meter Energy\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 302,\n \"path\": \"/meter/metercost\",\n \"name\": \"Meter Cost\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 303,\n \"path\": \"/meter/metertrend\",\n \"name\": \"Meter Trend\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 304,\n \"path\": \"/meter/meterrealtime\",\n \"name\": \"Meter Realtime\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 305,\n \"path\": \"/meter/metersubmetersbalance\",\n \"name\": \"Master Meter Submeters Balance\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 306,\n \"path\": \"/meter/virtualmeterenergy\",\n \"name\": \"Virtual Meter Energy\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 307,\n \"path\": \"/meter/virtualmetercost\",\n \"name\": \"Virtual Meter Cost\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 308,\n \"path\": \"/meter/offlinemeterenergy\",\n \"name\": \"Offline Meter Energy\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 309,\n \"path\": \"/meter/offlinemetercost\",\n \"name\": \"Offline Meter Cost\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 310,\n \"path\": \"/meter/batch\",\n \"name\": \"Batch Analysis\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 311,\n \"path\": \"/meter/tracking\",\n \"name\": \"Meter Tracking\",\n \"parent_menu_id\": 300,\n \"is_hidden\": 0\n },\n {\n \"id\": 400,\n \"path\": \"/tenant\",\n \"name\": \"Tenant Data\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 401,\n \"path\": \"/tenant/energycategory\",\n \"name\": \"Energy Category Data\",\n \"parent_menu_id\": 400,\n \"is_hidden\": 0\n },\n {\n \"id\": 402,\n \"path\": \"/tenant/energyitem\",\n \"name\": \"Energy Item Data\",\n \"parent_menu_id\": 400,\n \"is_hidden\": 0\n },\n {\n \"id\": 403,\n \"path\": \"/tenant/cost\",\n \"name\": \"Cost\",\n \"parent_menu_id\": 400,\n \"is_hidden\": 0\n },\n {\n \"id\": 404,\n \"path\": \"/tenant/load\",\n \"name\": \"Load\",\n \"parent_menu_id\": 400,\n \"is_hidden\": 0\n },\n {\n \"id\": 405,\n \"path\": \"/tenant/statistics\",\n \"name\": \"Statistics\",\n \"parent_menu_id\": 400,\n \"is_hidden\": 0\n },\n {\n \"id\": 406,\n \"path\": \"/tenant/saving\",\n \"name\": \"Saving\",\n \"parent_menu_id\": 400,\n \"is_hidden\": 0\n },\n {\n \"id\": 407,\n \"path\": \"/tenant/bill\",\n \"name\": \"Tenant Bill\",\n \"parent_menu_id\": 400,\n \"is_hidden\": 0\n },\n {\n \"id\": 408,\n \"path\": \"/tenant/batch\",\n \"name\": \"Batch Analysis\",\n \"parent_menu_id\": 400,\n \"is_hidden\": 0\n },\n {\n \"id\": 500,\n \"path\": \"/store\",\n \"name\": \"Store Data\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 501,\n \"path\": \"/store/energycategory\",\n \"name\": \"Energy Category Data\",\n \"parent_menu_id\": 500,\n \"is_hidden\": 0\n },\n {\n \"id\": 502,\n \"path\": \"/store/energyitem\",\n \"name\": \"Energy Item Data\",\n \"parent_menu_id\": 500,\n \"is_hidden\": 0\n },\n {\n \"id\": 503,\n \"path\": \"/store/cost\",\n \"name\": \"Cost\",\n \"parent_menu_id\": 500,\n \"is_hidden\": 0\n },\n {\n \"id\": 504,\n \"path\": \"/store/load\",\n \"name\": \"Load\",\n \"parent_menu_id\": 500,\n \"is_hidden\": 0\n },\n {\n \"id\": 505,\n \"path\": \"/store/statistics\",\n \"name\": \"Statistics\",\n \"parent_menu_id\": 500,\n \"is_hidden\": 0\n },\n {\n \"id\": 506,\n \"path\": \"/store/saving\",\n \"name\": \"Saving\",\n \"parent_menu_id\": 500,\n \"is_hidden\": 0\n },\n {\n \"id\": 507,\n \"path\": \"/store/batch\",\n \"name\": \"Batch Analysis\",\n \"parent_menu_id\": 500,\n \"is_hidden\": 0\n },\n {\n \"id\": 600,\n \"path\": \"/shopfloor\",\n \"name\": \"Shopfloor Data\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 601,\n \"path\": \"/shopfloor/energycategory\",\n \"name\": \"Energy Category Data\",\n \"parent_menu_id\": 600,\n \"is_hidden\": 0\n },\n {\n \"id\": 602,\n \"path\": \"/shopfloor/energyitem\",\n \"name\": \"Energy Item Data\",\n \"parent_menu_id\": 600,\n \"is_hidden\": 0\n },\n {\n \"id\": 603,\n \"path\": \"/shopfloor/cost\",\n \"name\": \"Cost\",\n \"parent_menu_id\": 600,\n \"is_hidden\": 0\n },\n {\n \"id\": 604,\n \"path\": \"/shopfloor/load\",\n \"name\": \"Load\",\n \"parent_menu_id\": 600,\n \"is_hidden\": 0\n },\n {\n \"id\": 605,\n \"path\": \"/shopfloor/statistics\",\n \"name\": \"Statistics\",\n \"parent_menu_id\": 600,\n \"is_hidden\": 0\n },\n {\n \"id\": 606,\n \"path\": \"/shopfloor/saving\",\n \"name\": \"Saving\",\n \"parent_menu_id\": 600,\n \"is_hidden\": 0\n },\n {\n \"id\": 607,\n \"path\": \"/shopfloor/batch\",\n \"name\": \"Batch Analysis\",\n \"parent_menu_id\": 600,\n \"is_hidden\": 0\n },\n {\n \"id\": 700,\n \"path\": \"/combinedequipment\",\n \"name\": \"Combined Equipment Data\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 701,\n \"path\": \"/combinedequipment/energycategory\",\n \"name\": \"Energy Category Data\",\n \"parent_menu_id\": 700,\n \"is_hidden\": 0\n },\n {\n \"id\": 702,\n \"path\": \"/combinedequipment/energyitem\",\n \"name\": \"Energy Item Data\",\n \"parent_menu_id\": 700,\n \"is_hidden\": 0\n },\n {\n \"id\": 703,\n \"path\": \"/combinedequipment/cost\",\n \"name\": \"Cost\",\n \"parent_menu_id\": 700,\n \"is_hidden\": 0\n },\n {\n \"id\": 704,\n \"path\": \"/combinedequipment/output\",\n \"name\": \"Output\",\n \"parent_menu_id\": 700,\n \"is_hidden\": 0\n },\n {\n \"id\": 705,\n \"path\": \"/combinedequipment/income\",\n \"name\": \"Income\",\n \"parent_menu_id\": 700,\n \"is_hidden\": 0\n },\n {\n \"id\": 706,\n \"path\": \"/combinedequipment/efficiency\",\n \"name\": \"Efficiency\",\n \"parent_menu_id\": 700,\n \"is_hidden\": 0\n },\n {\n \"id\": 707,\n \"path\": \"/combinedequipment/load\",\n \"name\": \"Load\",\n \"parent_menu_id\": 700,\n \"is_hidden\": 0\n },\n {\n \"id\": 708,\n \"path\": \"/combinedequipment/statistics\",\n \"name\": \"Statistics\",\n \"parent_menu_id\": 700,\n \"is_hidden\": 0\n },\n {\n \"id\": 709,\n \"path\": \"/combinedequipment/saving\",\n \"name\": \"Saving\",\n \"parent_menu_id\": 700,\n \"is_hidden\": 0\n },\n {\n \"id\": 710,\n \"path\": \"/combinedequipment/batch\",\n \"name\": \"Batch Analysis\",\n \"parent_menu_id\": 700,\n \"is_hidden\": 0\n },\n {\n \"id\": 800,\n \"path\": \"/auxiliarysystem\",\n \"name\": \"Auxiliary System\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 801,\n \"path\": \"/auxiliarysystem/energyflowdiagram\",\n \"name\": \"Energy Flow Diagram\",\n \"parent_menu_id\": 800,\n \"is_hidden\": 0\n },\n {\n \"id\": 802,\n \"path\": \"/auxiliarysystem/distributionsystem\",\n \"name\": \"Distribution System\",\n \"parent_menu_id\": 800,\n \"is_hidden\": 0\n },\n {\n \"id\": 900,\n \"path\": \"/fdd\",\n \"name\": \"Fault Detection & Diagnostics\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 901,\n \"path\": \"/fdd/space\",\n \"name\": \"Space Faults Data\",\n \"parent_menu_id\": 900,\n \"is_hidden\": 0\n },\n {\n \"id\": 902,\n \"path\": \"/fdd/equipment\",\n \"name\": \"Equipment Faults Data\",\n \"parent_menu_id\": 900,\n \"is_hidden\": 0\n },\n {\n \"id\": 903,\n \"path\": \"/fdd/combinedequipment\",\n \"name\": \"Combined Equipment Faults Data\",\n \"parent_menu_id\": 900,\n \"is_hidden\": 0\n },\n {\n \"id\": 904,\n \"path\": \"/fdd/tenant\",\n \"name\": \"Tenant Faults Data\",\n \"parent_menu_id\": 900,\n \"is_hidden\": 0\n },\n {\n \"id\": 905,\n \"path\": \"/fdd/store\",\n \"name\": \"Store Faults Data\",\n \"parent_menu_id\": 900,\n \"is_hidden\": 0\n },\n {\n \"id\": 906,\n \"path\": \"/fdd/shopfloor\",\n \"name\": \"Shopfloor Faults Data\",\n \"parent_menu_id\": 900,\n \"is_hidden\": 0\n },\n {\n \"id\": 1000,\n \"path\": \"/monitoring\",\n \"name\": \"Monitoring\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 1001,\n \"path\": \"/monitoring/space\",\n \"name\": \"Space Equipments\",\n \"parent_menu_id\": 1000,\n \"is_hidden\": 0\n },\n {\n \"id\": 1002,\n \"path\": \"/monitoring/equipment\",\n \"name\": \"Combined Equipments\",\n \"parent_menu_id\": 1000,\n \"is_hidden\": 0\n },\n {\n \"id\": 1003,\n \"path\": \"/monitoring/combinedequipment\",\n \"name\": \"Tenant Equipments\",\n \"parent_menu_id\": 1000,\n \"is_hidden\": 0\n },\n {\n \"id\": 1004,\n \"path\": \"/monitoring/tenant\",\n \"name\": \"Store Equipments\",\n \"parent_menu_id\": 1000,\n \"is_hidden\": 0\n },\n {\n \"id\": 1005,\n \"path\": \"/monitoring/store\",\n \"name\": \"Shopfloor Equipments\",\n \"parent_menu_id\": 1000,\n \"is_hidden\": 0\n },\n {\n \"id\": 1100,\n \"path\": \"/advancedreporting\",\n \"name\": \"Advanced Reporting\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n {\n \"id\": 1200,\n \"path\": \"/knowledgebase\",\n \"name\": \"Knowledge Base\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n }\n]" - } - ] - }, - { - "name": "GET a Menu by ID", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/menus/1", - "host": [ - "{{base_url}}" - ], - "path": [ - "menus", - "1" - ] - } - }, - "response": [ - { - "name": "GET a Menu by ID", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/menus/1", - "host": [ - "{{base_url}}" - ], - "path": [ - "menus", - "1" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Server", - "value": "gunicorn/20.0.4" - }, - { - "key": "Date", - "value": "Fri, 30 Jul 2021 10:45:44 GMT" - }, - { - "key": "Connection", - "value": "close" - }, - { - "key": "content-length", - "value": "92" - }, - { - "key": "content-type", - "value": "application/json" - } - ], - "cookie": [], - "body": "{\n \"id\": 1,\n \"path\": \"/dashboard\",\n \"name\": \"Dashboard\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n}" - } - ] - }, - { - "name": "PUT Update a Menu", - "request": { - "method": "PUT", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"data\": {\n \"is_hidden\": false\n }\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/menus/1", - "host": [ - "{{base_url}}" - ], - "path": [ - "menus", - "1" - ] - } - }, - "response": [ - { - "name": "PUT Update a Menu", - "originalRequest": { - "method": "PUT", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"data\": {\n \"is_hidden\": false\n }\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/menus/1", - "host": [ - "{{base_url}}" - ], - "path": [ - "menus", - "1" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Server", - "value": "gunicorn/20.0.4" - }, - { - "key": "Date", - "value": "Fri, 30 Jul 2021 10:49:20 GMT" - }, - { - "key": "Connection", - "value": "close" - }, - { - "key": "content-length", - "value": "0" - }, - { - "key": "content-type", - "value": "application/json" - } - ], - "cookie": [], - "body": null - } - ] - }, - { - "name": "GET All Children of a Menu", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/menus/1/children", - "host": [ - "{{base_url}}" - ], - "path": [ - "menus", - "1", - "children" - ] - } - }, - "response": [ - { - "name": "GET All Children of a Space", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/menus/1/children", - "host": [ - "{{base_url}}" - ], - "path": [ - "menus", - "1", - "children" - ] - } - }, - "status": "OK", - "code": 200, - "_postman_previewlanguage": "json", - "header": [ - { - "key": "Server", - "value": "gunicorn/20.0.4" - }, - { - "key": "Date", - "value": "Fri, 30 Jul 2021 10:50:23 GMT" - }, - { - "key": "Connection", - "value": "close" - }, - { - "key": "content-length", - "value": "121" - }, - { - "key": "content-type", - "value": "application/json" - } - ], - "cookie": [], - "body": "{\n \"current\": {\n \"id\": 1,\n \"path\": \"/dashboard\",\n \"name\": \"Dashboard\",\n \"parent_menu_id\": null,\n \"is_hidden\": 0\n },\n \"children\": []\n}" - } - ] - } - ] } ] }, @@ -11002,31 +10057,5 @@ }, "response": [] } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ], - "variable": [ - { - "key": "base_url", - "value": "127.0.0.1:8000" - } ] } \ No newline at end of file diff --git a/myems-api/README.md b/myems-api/README.md index 684b8281..2851ba11 100644 --- a/myems-api/README.md +++ b/myems-api/README.md @@ -159,7 +159,7 @@ View in Postman: import the file MyEMS.postman_collection.json with Postman [Data Source](#Data-Source) | [Point](#Point) -[Tariff](#Tariff) | [Cost Center](#Cost-Center) | [Cost File](#Offline-Cost-File) +[Tariff](#Tariff) | [Cost Center](#Cost-Center) | [Cost File](#Cost-File) [Meter](#Meter) | [Virtual Meter](#Virtual-Meter) | [Offline Meter](#Offline-Meter) | [Offline Meter File](#Offline-Meter-File) @@ -179,6 +179,8 @@ View in Postman: import the file MyEMS.postman_collection.json with Postman [Timezone](#Timezone) +[Menu](#Menu) + [Knowledge File](#Knowledge-File) [Reports](#Reports) @@ -976,9 +978,13 @@ $ curl -i -X GET {{base_url}}/menus ```bash $ curl -i -H "Content-Type: application/json" -X PUT -d '{"data":{"is_hidden": false}}' {{base_url}}/menus/{id} ``` -* Get All Menus for web +* Get All Menus for Web UI ```bash -$ curl -i -X GET {{base_url}}/web/menus +$ curl -i -X GET {{base_url}}/menus/web +``` +* GET All Children of Menu by ID +```bash +$ curl -i -X GET {{base_url}}/menus/{id}/children ```