diff --git a/admin/app/controllers/settings/menu/menu.controller.js b/admin/app/controllers/settings/menu/menu.controller.js index 351dea6d..0297d452 100644 --- a/admin/app/controllers/settings/menu/menu.controller.js +++ b/admin/app/controllers/settings/menu/menu.controller.js @@ -2,7 +2,7 @@ app.controller('MenuController', function ($scope, $common, $uibModal, MenuService, CostCenterService, ContactService, toaster, $translate, SweetAlert) { $scope.menus = []; - $scope.currentMenuID = 1; + $scope.currentMenuID = null; $scope.currentMenu = {}; $scope.currentMenuChildren = []; diff --git a/admin/views/settings/menu/menu.html b/admin/views/settings/menu/menu.html index 105d49b0..aaefd3f1 100644 --- a/admin/views/settings/menu/menu.html +++ b/admin/views/settings/menu/menu.html @@ -30,9 +30,7 @@ {{'SETTING.ID' | translate}} {{'SETTING.NAME' | translate}} {{'SETTING.PARENT_MENU' | translate}} - - {{'SETTING.IS_HIDDEN' | translate}} - + {{'SETTING.IS_HIDDEN' | translate}} {{'SETTING.ACTION' | translate}} @@ -41,9 +39,7 @@ {{ currentMenu.id }} {{ currentMenu.name }} {{ currentMenu.parent_menu.name }} - {{ currentMenu.is_hidden }} - {{ currentMenu.is_hidden==false?'SETTING.NO':'SETTING.YES' | translate }} - + {{ currentMenu.is_hidden==false?'SETTING.NO':'SETTING.YES' | translate }} {{'SETTING.EDIT' | translate}} @@ -73,9 +69,7 @@ {{ menu.id }} {{ menu.name }} {{ menu.parent_menu.name }} - - {{ menu.is_hidden==false?'SETTING.NO':'SETTING.YES' | translate }} - + {{ menu.is_hidden==false?'SETTING.NO':'SETTING.YES' | translate }} {{'SETTING.EDIT' | translate}} diff --git a/database/myems_system_db.sql b/database/myems_system_db.sql index 3b0bb9e0..3f470e2c 100644 --- a/database/myems_system_db.sql +++ b/database/myems_system_db.sql @@ -772,104 +772,103 @@ DROP TABLE IF EXISTS `myems_system_db`.`tbl_menus` ; CREATE TABLE IF NOT EXISTS `myems_system_db`.`tbl_menus` ( `id` BIGINT NOT NULL AUTO_INCREMENT, - `path` VARCHAR(256) NOT NULL, `name` VARCHAR(256) NOT NULL, + `route` VARCHAR(256) NOT NULL, `parent_menu_id` BIGINT, `is_hidden` BOOL NOT NULL, PRIMARY KEY (`id`)); + +INSERT INTO myems_system_db.tbl_menus (id,name,route, parent_menu_id,is_hidden) +VALUES +(100,'Space Data','/space',NULL,0), +(101,'Energy Category Data','/space/energycategory',100,0), +(102,'Energy Item Data','/space/energyitem',100,0), +(103,'Cost','/space/cost',100,0), +(104,'Output','/space/output',100,0), +(105,'Income','/space/income',100,0), +(106,'Efficiency','/space/efficiency',100,0), +(107,'Load','/space/load',100,0), +(108,'Statistics','/space/statistics',100,0), +(109,'Saving','/space/saving',100,0), +(200,'Equipment Data','/equipment',NULL,0), +(201,'Energy Category Data','/equipment/energycategory',200,0), +(202,'Energy Item Data','/equipment/energyitem',200,0), +(203,'Cost','/equipment/cost',200,0), +(204,'Output','/equipment/output',200,0), +(205,'Income','/equipment/income',200,0), +(206,'Efficiency','/equipment/efficiency',200,0), +(207,'Load','/equipment/load',200,0), +(208,'Statistics','/equipment/statistics',200,0), +(209,'Saving','/equipment/saving',200,0), +(210,'Batch Analysis','/equipment/batch',200,0), +(211,'Equipment Tracking','/equipment/tracking',200,0), +(300,'Meter Data','/meter',NULL,0), +(301,'Meter Energy','/meter/meterenergy',300,0), +(302,'Meter Cost','/meter/metercost',300,0), +(303,'Meter Trend','/meter/metertrend',300,0), +(304,'Meter Realtime','/meter/meterrealtime',300,0), +(305,'Master Meter Submeters Balance','/meter/metersubmetersbalance',300,0), +(306,'Virtual Meter Energy','/meter/virtualmeterenergy',300,0), +(307,'Virtual Meter Cost','/meter/virtualmetercost',300,0), +(308,'Offline Meter Energy','/meter/offlinemeterenergy',300,0), +(309,'Offline Meter Cost','/meter/offlinemetercost',300,0), +(310,'Batch Analysis','/meter/batch',300,0), +(311,'Meter Tracking','/meter/tracking',300,0), +(400,'Tenant Data','/tenant',NULL,0), +(401,'Energy Category Data','/tenant/energycategory',400,0), +(402,'Energy Item Data','/tenant/energyitem',400,0), +(403,'Cost','/tenant/cost',400,0), +(404,'Load','/tenant/load',400,0), +(405,'Statistics','/tenant/statistics',400,0), +(406,'Saving','/tenant/saving',400,0), +(407,'Tenant Bill','/tenant/bill',400,0), +(408,'Batch Analysis','/tenant/batch',400,0), +(500,'Store Data','/store',NULL,0), +(501,'Energy Category Data','/store/energycategory',500,0), +(502,'Energy Item Data','/store/energyitem',500,0), +(503,'Cost','/store/cost',500,0), +(504,'Load','/store/load',500,0), +(505,'Statistics','/store/statistics',500,0), +(506,'Saving','/store/saving',500,0), +(507,'Batch Analysis','/store/batch',500,0), +(600,'Shopfloor Data','/shopfloor',NULL,0), +(601,'Energy Category Data','/shopfloor/energycategory',600,0), +(602,'Energy Item Data','/shopfloor/energyitem',600,0), +(603,'Cost','/shopfloor/cost',600,0), +(604,'Load','/shopfloor/load',600,0), +(605,'Statistics','/shopfloor/statistics',600,0), +(606,'Saving','/shopfloor/saving',600,0), +(607,'Batch Analysis','/shopfloor/batch',600,0), +(700,'Combined Equipment Data','/combinedequipment',NULL,0), +(701,'Energy Category Data','/combinedequipment/energycategory',700,0), +(702,'Energy Item Data','/combinedequipment/energyitem',700,0), +(703,'Cost','/combinedequipment/cost',700,0), +(704,'Output','/combinedequipment/output',700,0), +(705,'Income','/combinedequipment/income',700,0), +(706,'Efficiency','/combinedequipment/efficiency',700,0), +(707,'Load','/combinedequipment/load',700,0), +(708,'Statistics','/combinedequipment/statistics',700,0), +(709,'Saving','/combinedequipment/saving',700,0), +(710,'Batch Analysis','/combinedequipment/batch',700,0), +(800,'Auxiliary System','/auxiliarysystem',NULL,0), +(801,'Energy Flow Diagram','/auxiliarysystem/energyflowdiagram',800,0), +(802,'Distribution System','/auxiliarysystem/distributionsystem',800,0), +(900,'Fault Detection & Diagnostics','/fdd',NULL,0), +(901,'Space Faults Data','/fdd/space',900,0), +(902,'Equipment Faults Data','/fdd/equipment',900,0), +(903,'Combined Equipment Faults Data','/fdd/combinedequipment',900,0), +(904,'Tenant Faults Data','/fdd/tenant',900,0), +(905,'Store Faults Data','/fdd/store',900,0), +(906,'Shopfloor Faults Data','/fdd/shopfloor',900,0), +(1000,'Monitoring','/monitoring',NULL,0), +(1001,'Space Equipments','/monitoring/space',1000,0), +(1002,'Combined Equipments','/monitoring/equipment',1000,0), +(1003,'Tenant Equipments','/monitoring/combinedequipment',1000,0), +(1004,'Store Equipments','/monitoring/tenant',1000,0), +(1005,'Shopfloor Equipments','/monitoring/store',1000,0), +(1100,'Advanced Reporting','/advancedreporting',NULL,0), +(1200,'Knowledge Base','/knowledgebase',NULL,0); -INSERT INTO myems_system_db.tbl_menus -(id, path, name, parent_menu_id, is_hidden) -VALUES -(1, '/dashboard', 'Dashboard', null, false), -(100, '/space', 'Space Data', null, false), -(101, '/space/energycategory', 'Energy Category Data', 100, false), -(102, '/space/energyitem', 'Energy Item Data', 100, false), -(103, '/space/cost', 'Cost', 100, false), -(104, '/space/output', 'Output', 100, false), -(105, '/space/income', 'Income', 100, false), -(106, '/space/efficiency', 'Efficiency', 100, false), -(107, '/space/load', 'Load', 100, false), -(108, '/space/statistics', 'Statistics', 100, false), -(109, '/space/saving', 'Saving', 100, false), -(200, '/equipment', 'Equipment Data', null, false), -(201, '/equipment/energycategory', 'Energy Category Data', 200, false), -(202, '/equipment/energyitem', 'Energy Item Data', 200, false), -(203, '/equipment/cost', 'Cost', 200, false), -(204, '/equipment/output', 'Output', 200, false), -(205, '/equipment/income', 'Income', 200, false), -(206, '/equipment/efficiency', 'Efficiency', 200, false), -(207, '/equipment/load', 'Load', 200, false), -(208, '/equipment/statistics', 'Statistics', 200, false), -(209, '/equipment/saving', 'Saving', 200, false), -(210, '/equipment/batch', 'Batch Analysis', 200, false), -(211, '/equipment/tracking', 'Equipment Tracking', 200, false), -(300, '/meter', 'Meter Data', null, false), -(301, '/meter/meterenergy', 'Meter Energy', 300, false), -(302, '/meter/metercost', 'Meter Cost', 300, false), -(303, '/meter/metertrend', 'Meter Trend', 300, false), -(304, '/meter/meterrealtime', 'Meter Realtime', 300, false), -(305, '/meter/metersubmetersbalance', 'Master Meter Submeters Balance', 300, false), -(306, '/meter/virtualmeterenergy', 'Virtual Meter Energy', 300, false), -(307, '/meter/virtualmetercost', 'Virtual Meter Cost', 300, false), -(308, '/meter/offlinemeterenergy', 'Offline Meter Energy', 300, false), -(309, '/meter/offlinemetercost', 'Offline Meter Cost', 300, false), -(310, '/meter/batch', 'Batch Analysis', 300, false), -(311, '/meter/tracking', 'Meter Tracking', 300, false), -(400, '/tenant', 'Tenant Data', null, false), -(401, '/tenant/energycategory', 'Energy Category Data', 400, false), -(402, '/tenant/energyitem', 'Energy Item Data', 400, false), -(403, '/tenant/cost', 'Cost', 400, false), -(404, '/tenant/load', 'Load', 400, false), -(405, '/tenant/statistics', 'Statistics', 400, false), -(406, '/tenant/saving', 'Saving', 400, false), -(407, '/tenant/bill', 'Tenant Bill', 400, false), -(408, '/tenant/batch', 'Batch Analysis', 400, false), -(500, '/store', 'Store Data', null, false), -(501, '/store/energycategory', 'Energy Category Data', 500, false), -(502, '/store/energyitem', 'Energy Item Data', 500, false), -(503, '/store/cost', 'Cost', 500, false), -(504, '/store/load', 'Load', 500, false), -(505, '/store/statistics', 'Statistics', 500, false), -(506, '/store/saving', 'Saving', 500, false), -(507, '/store/batch', 'Batch Analysis', 500, false), -(600, '/shopfloor', 'Shopfloor Data', null, false), -(601, '/shopfloor/energycategory', 'Energy Category Data', 600, false), -(602, '/shopfloor/energyitem', 'Energy Item Data', 600, false), -(603, '/shopfloor/cost', 'Cost', 600, false), -(604, '/shopfloor/load', 'Load', 600, false), -(605, '/shopfloor/statistics', 'Statistics', 600, false), -(606, '/shopfloor/saving', 'Saving', 600, false), -(607, '/shopfloor/batch', 'Batch Analysis', 600, false), -(700, '/combinedequipment', 'Combined Equipment Data', null, false), -(701, '/combinedequipment/energycategory', 'Energy Category Data', 700, false), -(702, '/combinedequipment/energyitem', 'Energy Item Data', 700, false), -(703, '/combinedequipment/cost', 'Cost', 700, false), -(704, '/combinedequipment/output', 'Output', 700, false), -(705, '/combinedequipment/income', 'Income', 700, false), -(706, '/combinedequipment/efficiency', 'Efficiency', 700, false), -(707, '/combinedequipment/load', 'Load', 700, false), -(708, '/combinedequipment/statistics', 'Statistics', 700, false), -(709, '/combinedequipment/saving', 'Saving', 700, false), -(710, '/combinedequipment/batch', 'Batch Analysis', 700, false), -(800, '/auxiliarysystem', 'Auxiliary System', null, false), -(801, '/auxiliarysystem/energyflowdiagram', 'Energy Flow Diagram', 800, false), -(802, '/auxiliarysystem/distributionsystem', 'Distribution System', 800, false), -(900, '/fdd', 'Fault Detection & Diagnostics', null, false), -(901, '/fdd/space', 'Space Faults Data', 900, false), -(902, '/fdd/equipment', 'Equipment Faults Data', 900, false), -(903, '/fdd/combinedequipment', 'Combined Equipment Faults Data', 900, false), -(904, '/fdd/tenant', 'Tenant Faults Data', 900, false), -(905, '/fdd/store', 'Store Faults Data', 900, false), -(906, '/fdd/shopfloor', 'Shopfloor Faults Data', 900, false), -(1000, '/monitoring', 'Monitoring', null, false), -(1001, '/monitoring/space', 'Space Equipments', 1000, false), -(1002, '/monitoring/equipment', 'Combined Equipments', 1000, false), -(1003, '/monitoring/combinedequipment', 'Tenant Equipments', 1000, false), -(1004, '/monitoring/tenant', 'Store Equipments', 1000, false), -(1005, '/monitoring/store', 'Shopfloor Equipments', 1000, false), -(1100, '/advancedreporting', 'Advanced Reporting', null, false), -(1200, '/knowledgebase', 'Knowledge Base', null, false); @@ -2359,6 +2358,6 @@ USE `myems_system_db`; INSERT INTO `myems_system_db`.`tbl_versions` (`id`, `version`, `release_date`) VALUES -(1, '1.1.6', '2021-07-29'); +(1, '1.1.6', '2021-08-02'); COMMIT; diff --git a/database/upgrade1.1.6.sql b/database/upgrade1.1.6.sql index dbf934bd..dd78dd36 100644 --- a/database/upgrade1.1.6.sql +++ b/database/upgrade1.1.6.sql @@ -2,108 +2,109 @@ -- --------------------------------------------------------------------------------------------------------------------- -- Table `myems_system_db`.`tbl_menus` -- --------------------------------------------------------------------------------------------------------------------- +DROP TABLE IF EXISTS `myems_system_db`.`tbl_menus` ; + CREATE TABLE IF NOT EXISTS `myems_system_db`.`tbl_menus` ( `id` BIGINT NOT NULL AUTO_INCREMENT, - `path` VARCHAR(256) NOT NULL, `name` VARCHAR(256) NOT NULL, + `route` VARCHAR(256) NOT NULL, `parent_menu_id` BIGINT, `is_hidden` BOOL NOT NULL, PRIMARY KEY (`id`)); + +INSERT INTO myems_system_db.tbl_menus (id,name,route, parent_menu_id,is_hidden) +VALUES +(100,'Space Data','/space',NULL,0), +(101,'Energy Category Data','/space/energycategory',100,0), +(102,'Energy Item Data','/space/energyitem',100,0), +(103,'Cost','/space/cost',100,0), +(104,'Output','/space/output',100,0), +(105,'Income','/space/income',100,0), +(106,'Efficiency','/space/efficiency',100,0), +(107,'Load','/space/load',100,0), +(108,'Statistics','/space/statistics',100,0), +(109,'Saving','/space/saving',100,0), +(200,'Equipment Data','/equipment',NULL,0), +(201,'Energy Category Data','/equipment/energycategory',200,0), +(202,'Energy Item Data','/equipment/energyitem',200,0), +(203,'Cost','/equipment/cost',200,0), +(204,'Output','/equipment/output',200,0), +(205,'Income','/equipment/income',200,0), +(206,'Efficiency','/equipment/efficiency',200,0), +(207,'Load','/equipment/load',200,0), +(208,'Statistics','/equipment/statistics',200,0), +(209,'Saving','/equipment/saving',200,0), +(210,'Batch Analysis','/equipment/batch',200,0), +(211,'Equipment Tracking','/equipment/tracking',200,0), +(300,'Meter Data','/meter',NULL,0), +(301,'Meter Energy','/meter/meterenergy',300,0), +(302,'Meter Cost','/meter/metercost',300,0), +(303,'Meter Trend','/meter/metertrend',300,0), +(304,'Meter Realtime','/meter/meterrealtime',300,0), +(305,'Master Meter Submeters Balance','/meter/metersubmetersbalance',300,0), +(306,'Virtual Meter Energy','/meter/virtualmeterenergy',300,0), +(307,'Virtual Meter Cost','/meter/virtualmetercost',300,0), +(308,'Offline Meter Energy','/meter/offlinemeterenergy',300,0), +(309,'Offline Meter Cost','/meter/offlinemetercost',300,0), +(310,'Batch Analysis','/meter/batch',300,0), +(311,'Meter Tracking','/meter/tracking',300,0), +(400,'Tenant Data','/tenant',NULL,0), +(401,'Energy Category Data','/tenant/energycategory',400,0), +(402,'Energy Item Data','/tenant/energyitem',400,0), +(403,'Cost','/tenant/cost',400,0), +(404,'Load','/tenant/load',400,0), +(405,'Statistics','/tenant/statistics',400,0), +(406,'Saving','/tenant/saving',400,0), +(407,'Tenant Bill','/tenant/bill',400,0), +(408,'Batch Analysis','/tenant/batch',400,0), +(500,'Store Data','/store',NULL,0), +(501,'Energy Category Data','/store/energycategory',500,0), +(502,'Energy Item Data','/store/energyitem',500,0), +(503,'Cost','/store/cost',500,0), +(504,'Load','/store/load',500,0), +(505,'Statistics','/store/statistics',500,0), +(506,'Saving','/store/saving',500,0), +(507,'Batch Analysis','/store/batch',500,0), +(600,'Shopfloor Data','/shopfloor',NULL,0), +(601,'Energy Category Data','/shopfloor/energycategory',600,0), +(602,'Energy Item Data','/shopfloor/energyitem',600,0), +(603,'Cost','/shopfloor/cost',600,0), +(604,'Load','/shopfloor/load',600,0), +(605,'Statistics','/shopfloor/statistics',600,0), +(606,'Saving','/shopfloor/saving',600,0), +(607,'Batch Analysis','/shopfloor/batch',600,0), +(700,'Combined Equipment Data','/combinedequipment',NULL,0), +(701,'Energy Category Data','/combinedequipment/energycategory',700,0), +(702,'Energy Item Data','/combinedequipment/energyitem',700,0), +(703,'Cost','/combinedequipment/cost',700,0), +(704,'Output','/combinedequipment/output',700,0), +(705,'Income','/combinedequipment/income',700,0), +(706,'Efficiency','/combinedequipment/efficiency',700,0), +(707,'Load','/combinedequipment/load',700,0), +(708,'Statistics','/combinedequipment/statistics',700,0), +(709,'Saving','/combinedequipment/saving',700,0), +(710,'Batch Analysis','/combinedequipment/batch',700,0), +(800,'Auxiliary System','/auxiliarysystem',NULL,0), +(801,'Energy Flow Diagram','/auxiliarysystem/energyflowdiagram',800,0), +(802,'Distribution System','/auxiliarysystem/distributionsystem',800,0), +(900,'Fault Detection & Diagnostics','/fdd',NULL,0), +(901,'Space Faults Data','/fdd/space',900,0), +(902,'Equipment Faults Data','/fdd/equipment',900,0), +(903,'Combined Equipment Faults Data','/fdd/combinedequipment',900,0), +(904,'Tenant Faults Data','/fdd/tenant',900,0), +(905,'Store Faults Data','/fdd/store',900,0), +(906,'Shopfloor Faults Data','/fdd/shopfloor',900,0), +(1000,'Monitoring','/monitoring',NULL,0), +(1001,'Space Equipments','/monitoring/space',1000,0), +(1002,'Combined Equipments','/monitoring/equipment',1000,0), +(1003,'Tenant Equipments','/monitoring/combinedequipment',1000,0), +(1004,'Store Equipments','/monitoring/tenant',1000,0), +(1005,'Shopfloor Equipments','/monitoring/store',1000,0), +(1100,'Advanced Reporting','/advancedreporting',NULL,0), +(1200,'Knowledge Base','/knowledgebase',NULL,0); -INSERT INTO myems_system_db.tbl_menus -(id, path, name, parent_menu_id, is_hidden) -VALUES -(1, '/dashboard', 'Dashboard', null, false), -(100, '/space', 'Space Data', null, false), -(101, '/space/energycategory', 'Energy Category Data', 100, false), -(102, '/space/energyitem', 'Energy Item Data', 100, false), -(103, '/space/cost', 'Cost', 100, false), -(104, '/space/output', 'Output', 100, false), -(105, '/space/income', 'Income', 100, false), -(106, '/space/efficiency', 'Efficiency', 100, false), -(107, '/space/load', 'Load', 100, false), -(108, '/space/statistics', 'Statistics', 100, false), -(109, '/space/saving', 'Saving', 100, false), -(200, '/equipment', 'Equipment Data', null, false), -(201, '/equipment/energycategory', 'Energy Category Data', 200, false), -(202, '/equipment/energyitem', 'Energy Item Data', 200, false), -(203, '/equipment/cost', 'Cost', 200, false), -(204, '/equipment/output', 'Output', 200, false), -(205, '/equipment/income', 'Income', 200, false), -(206, '/equipment/efficiency', 'Efficiency', 200, false), -(207, '/equipment/load', 'Load', 200, false), -(208, '/equipment/statistics', 'Statistics', 200, false), -(209, '/equipment/saving', 'Saving', 200, false), -(210, '/equipment/batch', 'Batch Analysis', 200, false), -(211, '/equipment/tracking', 'Equipment Tracking', 200, false), -(300, '/meter', 'Meter Data', null, false), -(301, '/meter/meterenergy', 'Meter Energy', 300, false), -(302, '/meter/metercost', 'Meter Cost', 300, false), -(303, '/meter/metertrend', 'Meter Trend', 300, false), -(304, '/meter/meterrealtime', 'Meter Realtime', 300, false), -(305, '/meter/metersubmetersbalance', 'Master Meter Submeters Balance', 300, false), -(306, '/meter/virtualmeterenergy', 'Virtual Meter Energy', 300, false), -(307, '/meter/virtualmetercost', 'Virtual Meter Cost', 300, false), -(308, '/meter/offlinemeterenergy', 'Offline Meter Energy', 300, false), -(309, '/meter/offlinemetercost', 'Offline Meter Cost', 300, false), -(310, '/meter/batch', 'Batch Analysis', 300, false), -(311, '/meter/tracking', 'Meter Tracking', 300, false), -(400, '/tenant', 'Tenant Data', null, false), -(401, '/tenant/energycategory', 'Energy Category Data', 400, false), -(402, '/tenant/energyitem', 'Energy Item Data', 400, false), -(403, '/tenant/cost', 'Cost', 400, false), -(404, '/tenant/load', 'Load', 400, false), -(405, '/tenant/statistics', 'Statistics', 400, false), -(406, '/tenant/saving', 'Saving', 400, false), -(407, '/tenant/bill', 'Tenant Bill', 400, false), -(408, '/tenant/batch', 'Batch Analysis', 400, false), -(500, '/store', 'Store Data', null, false), -(501, '/store/energycategory', 'Energy Category Data', 500, false), -(502, '/store/energyitem', 'Energy Item Data', 500, false), -(503, '/store/cost', 'Cost', 500, false), -(504, '/store/load', 'Load', 500, false), -(505, '/store/statistics', 'Statistics', 500, false), -(506, '/store/saving', 'Saving', 500, false), -(507, '/store/batch', 'Batch Analysis', 500, false), -(600, '/shopfloor', 'Shopfloor Data', null, false), -(601, '/shopfloor/energycategory', 'Energy Category Data', 600, false), -(602, '/shopfloor/energyitem', 'Energy Item Data', 600, false), -(603, '/shopfloor/cost', 'Cost', 600, false), -(604, '/shopfloor/load', 'Load', 600, false), -(605, '/shopfloor/statistics', 'Statistics', 600, false), -(606, '/shopfloor/saving', 'Saving', 600, false), -(607, '/shopfloor/batch', 'Batch Analysis', 600, false), -(700, '/combinedequipment', 'Combined Equipment Data', null, false), -(701, '/combinedequipment/energycategory', 'Energy Category Data', 700, false), -(702, '/combinedequipment/energyitem', 'Energy Item Data', 700, false), -(703, '/combinedequipment/cost', 'Cost', 700, false), -(704, '/combinedequipment/output', 'Output', 700, false), -(705, '/combinedequipment/income', 'Income', 700, false), -(706, '/combinedequipment/efficiency', 'Efficiency', 700, false), -(707, '/combinedequipment/load', 'Load', 700, false), -(708, '/combinedequipment/statistics', 'Statistics', 700, false), -(709, '/combinedequipment/saving', 'Saving', 700, false), -(710, '/combinedequipment/batch', 'Batch Analysis', 700, false), -(800, '/auxiliarysystem', 'Auxiliary System', null, false), -(801, '/auxiliarysystem/energyflowdiagram', 'Energy Flow Diagram', 800, false), -(802, '/auxiliarysystem/distributionsystem', 'Distribution System', 800, false), -(900, '/fdd', 'Fault Detection & Diagnostics', null, false), -(901, '/fdd/space', 'Space Faults Data', 900, false), -(902, '/fdd/equipment', 'Equipment Faults Data', 900, false), -(903, '/fdd/combinedequipment', 'Combined Equipment Faults Data', 900, false), -(904, '/fdd/tenant', 'Tenant Faults Data', 900, false), -(905, '/fdd/store', 'Store Faults Data', 900, false), -(906, '/fdd/shopfloor', 'Shopfloor Faults Data', 900, false), -(1000, '/monitoring', 'Monitoring', null, false), -(1001, '/monitoring/space', 'Space Equipments', 1000, false), -(1002, '/monitoring/equipment', 'Combined Equipments', 1000, false), -(1003, '/monitoring/combinedequipment', 'Tenant Equipments', 1000, false), -(1004, '/monitoring/tenant', 'Store Equipments', 1000, false), -(1005, '/monitoring/store', 'Shopfloor Equipments', 1000, false), -(1100, '/advancedreporting', 'Advanced Reporting', null, false), -(1200, '/knowledgebase', 'Knowledge Base', null, false); -- UPDATE VERSION NUMBER -UPDATE myems_system_db.tbl_versions SET version='1.1.6', release_date='2021-07-29' WHERE id=1; +UPDATE myems_system_db.tbl_versions SET version='1.1.6', release_date='2021-08-02' WHERE id=1; diff --git a/myems-api/core/menu.py b/myems-api/core/menu.py index 596c0cf0..a78a39d4 100644 --- a/myems-api/core/menu.py +++ b/myems-api/core/menu.py @@ -2,10 +2,6 @@ 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: @@ -22,7 +18,7 @@ class MenuCollection: cnx = mysql.connector.connect(**config.myems_system_db) cursor = cnx.cursor(dictionary=True) - query = (" SELECT id, path, name, parent_menu_id, is_hidden " + query = (" SELECT id, name, route, parent_menu_id, is_hidden " " FROM tbl_menus ") cursor.execute(query) rows_menus = cursor.fetchall() @@ -31,8 +27,8 @@ class MenuCollection: 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'], + "route": row['route'], "parent_menu_id": row['parent_menu_id'], "is_hidden": bool(row['is_hidden'])} @@ -61,7 +57,7 @@ class MenuItem: cnx = mysql.connector.connect(**config.myems_system_db) cursor = cnx.cursor(dictionary=True) - query = (" SELECT id, path, name, parent_menu_id, is_hidden " + query = (" SELECT id, name, route, parent_menu_id, is_hidden " " FROM tbl_menus " " WHERE id=%s ") cursor.execute(query, (id_,)) @@ -70,8 +66,8 @@ class MenuItem: 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'], + "route": rows_menu['route'], "parent_menu_id": rows_menu['parent_menu_id'], "is_hidden": bool(rows_menu['is_hidden'])} @@ -132,7 +128,7 @@ class MenuChildrenCollection: cnx = mysql.connector.connect(**config.myems_system_db) cursor = cnx.cursor(dictionary=True) - query = (" SELECT id, path, name, parent_menu_id, is_hidden " + query = (" SELECT id, name, route, parent_menu_id, is_hidden " " FROM tbl_menus " " WHERE id = %s ") cursor.execute(query, (id_,)) @@ -142,39 +138,42 @@ class MenuChildrenCollection: 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: - 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": bool(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 " - " WHERE parent_menu_id = %s") - cursor.execute(query, (current_menu_id,)) + query = (" SELECT id, name " + " FROM tbl_menus ") + cursor.execute(query) rows_menus = cursor.fetchall() - children_menus = [] + menu_dict = dict() 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": bool(row['is_hidden']) - } - ) + menu_dict[row['id']] = {"id": row['id'], + "name": row['name']} - result = { - "current": current_menu, - "children": children_menus, - } + result = dict() + result['current'] = dict() + result['current']['id'] = row_current_menu['id'] + result['current']['name'] = row_current_menu['name'] + result['current']['parent_menu'] = menu_dict.get(row_current_menu['parent_menu_id'], None) + result['current']['is_hidden'] = bool(row_current_menu['is_hidden']) + + result['children'] = list() + + query = (" SELECT id, name, route, parent_menu_id, is_hidden " + " FROM tbl_menus " + " WHERE parent_menu_id = %s " + " ORDER BY id ") + cursor.execute(query, (id_, )) + rows_menus = cursor.fetchall() + + if rows_menus is not None and len(rows_menus) > 0: + for row in rows_menus: + parent_menu = menu_dict.get(row['parent_menu_id'], None) + meta_result = {"id": row['id'], + "name": row['name'], + "parent_menu": parent_menu, + "is_hidden": bool(row['is_hidden'])} + result['children'].append(meta_result) cursor.close() cnx.disconnect()