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/ds2Header.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/ds2Header.js')
-rw-r--r-- | usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-directives/ds2Header.js | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-directives/ds2Header.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-directives/ds2Header.js new file mode 100644 index 00000000..088fa487 --- /dev/null +++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-directives/ds2Header.js @@ -0,0 +1,116 @@ +appDS2.directive('ds2Header', function () { + return { + restrict: 'A', //This menas 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/ds2Header.html", + controller: ['$scope', '$filter','$http','$timeout', '$log','UserInfoServiceDS2', 'HeaderServiceDS2', '$window', '$cookies','$cookieStore', function ($scope, $filter, $http, $timeout, $log,UserInfoServiceDS2,HeaderServiceDS2, $window, $cookies,$cookieStore) { + // copy from existing DS1 + + /*Define fields*/ + $scope.userName; + $scope.userFirstName; + $scope.userId; + $scope.userEmail; + $scope.redirectUrl; + $scope.contactUsUrl; + $scope.getAccessUrl; + $scope.menuItems = []; + $scope.showHeader = ($cookieStore.get("show_app_header") == undefined ? true : $cookies.get("show_app_header") ); + + + /***************functions**************/ + /*getting user info from session*/ + $scope.getUserNameFromSession = function(){ + UserInfoServiceDS2.getFunctionalMenuStaticDetailSession() + .then(function (res) { + $scope.contactUsUrl=res.contactUsLink; + $scope.userName = res.userName; + $scope.userId = res.userid; + $scope.userEmail = res.email; + $scope.userFirstName = res.firstName; + $scope.redirectUrl = res.portalUrl; + $scope.getAccessUrl = res.getAccessUrl; + }); + } + + $scope.returnToPortal=function(){ + window.location.href = $scope.redirectUrl; + } + + /*Menu Structure*/ + var menuStructureConvert = function(menuItems) { + $scope.megaMenuDataObjectTemp = + [{ + text: "Manage", + children: menuItems + }, + { + text: "Support", + children: [ + { + label:"Contact Us", + action:$scope.contactUsUrl, + childMenus:[] + }, + { + label:"Get Access", + action:$scope.getAccessUrl, + childMenus:[] + }] + }]; + return $scope.megaMenuDataObjectTemp; + }; + + $scope.getMenu=function() { + $scope.getUserNameFromSession(); + var promise = HeaderServiceDS2.getMenu(); + promise.then( + function(res) { + if(res==null || res==''){ + $log.error('failed to get menu'); + $scope.getUserNameFromSession(); + }else{ + $scope.parentMenu = JSON.parse(res.data); + $scope.childMenu = JSON.parse(res.data2); + for(var i=0; i<$scope.parentMenu.length;i++){ + $scope.parentMenu[i].childMenus = ($scope.childMenu[i]); + } + $scope.menuItems = menuStructureConvert($scope.parentMenu); + } + }, + function(err) { + $log.error('getMenu failed', err); + } + ); + } + + + + $scope.adjustHeader=function() { + $scope.showHeader = ($cookies.get("show_app_header") == undefined ? true : $cookies.get("show_app_header")); + // console.log($scope.showHeader); + if ($scope.showHeader==true) { + document.getElementById('page-content').style.marginTop = "45px"; + }else{ + document.getElementById('page-content').style.marginTop = "0px"; + } + }; // adjustHeader + $scope.$on('$routeChangeSuccess', function () { + $scope.adjustHeader(); + }); + + $scope.getUserNameFromSession(); + $scope.getMenu(); + }] + } +}); + +appDS2.filter("ellipsis", function(){ + return function(text, length){ + if (text) { + var ellipsis = text.length > length ? "..." : ""; + return text.slice(0, length) + ellipsis; + }; + return text; + } +}); |