diff options
author | 2017-09-01 11:57:47 +0800 | |
---|---|---|
committer | 2017-09-01 11:57:58 +0800 | |
commit | 57dbba269d19bc59fad89160200bb2dbcccb9003 (patch) | |
tree | d466041ceffa2161124ca79a48b3e077777c74b8 /usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-directives/ds2LeftMenu.js | |
parent | 4ff32341a0af1972b44a7410e76e9b231131e7ab (diff) |
Upload Monitor function code
Change-Id: I33ad76221b4cb771a298ff240245fc24be664efb
Issue-Id: USECASEUI-6
Signed-off-by: shentao <shentao@chinamobile.com>
Diffstat (limited to 'usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-directives/ds2LeftMenu.js')
-rw-r--r-- | usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-directives/ds2LeftMenu.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-directives/ds2LeftMenu.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-directives/ds2LeftMenu.js new file mode 100644 index 00000000..758add6e --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-directives/ds2LeftMenu.js @@ -0,0 +1,73 @@ +appDS2.directive('ds2Menu', function () { + return { + restrict: 'A', //This means that it will be used as an attribute and NOT as an element. I don't like creating custom HTML elements + replace: false, + templateUrl: "app/fusion/scripts/DS2-view-models/ds2Left_menu.html", + controller: ['$scope','$filter','$http','$timeout','$cookies','LeftMenuServiceDS2', function ($scope, $filter, $http, $timeout, $cookies, LeftMenuServiceDS2) { + $scope.menuData = []; + $scope.leftChildData = []; + $scope.leftParentData = []; + $scope.leftMenuItems = []; + $scope.app_name = ""; + $scope.app_name_full = ""; + LeftMenuServiceDS2.getLeftMenu().then(function(response){ + var j = response; + if (j && j !== "null" && j !== "undefined"){ + $scope.leftParentData = JSON.parse(j.data); + $scope.leftChildData = JSON.parse(j.data2); + } else { + console.log("ds2Menu::controller: unexpected getLeftMenu response"); + return; + } + var leftParentList = $scope.leftParentData; + var leftChildItemList = $scope.leftChildData; + for (var i = 0; i < leftParentList.length; i++) { + var parentItem = {}; + parentItem.name = leftParentList[i].label; + parentItem.imageSrc = leftParentList[i].imageSrc; + // Add link to items with no subitems + if (leftChildItemList[i].length == 0) + parentItem.href = leftParentList[i].action; + parentItem.menuItems = []; + for (var j = 0; j < leftChildItemList[i].length; j++) { + if (leftChildItemList[i][j].label != null && leftChildItemList[i][j].label.length > 0) { + var childItem = {}; + childItem.name = leftChildItemList[i][j].label; + childItem.href = leftChildItemList[i][j].action; + parentItem.menuItems.push(childItem) + } + } + $scope.menuData.push(parentItem); + } + },function(error){ + console.log("ds2Menu::controller: getLeftMenu failed", error); + }); + + LeftMenuServiceDS2.getAppName().then(function(response){ + var j = response; + try { + if (j && j !== "null" && j!== "undefined"){ + $scope.app_name_full = j.data; + var processed_app_name = j.data; + var n = processed_app_name.length; + if (n > 15) { + n = 15; + } + $scope.app_name = processed_app_name.substr(0, n); + } else { + throw "Get app_name respsone is not an object/is empty"; + } + } catch (e) { + console.log("error happened while trying to get app name "+e); + return; + } + },function(error){ + console.log("error happened while calling getAppName "+error); + }); + + $scope.drawerOpen = true; + + + }] + } +});
\ No newline at end of file |