From c081bd0a7db3f434e76c03a9ca0334539ee84470 Mon Sep 17 00:00:00 2001 From: "Christopher Lott (cl778h)" Date: Thu, 11 May 2017 09:38:56 -0400 Subject: [PORTAL-7] Features and repairs from 1707 This merges latest changes made to Raptor and other features. Change-Id: I3a58f88e988ddadf52e1c0c782cdccd2b2ecf5e9 Signed-off-by: Christopher Lott (cl778h) --- .../app/fusion/scripts/DS2-directives/ds2Header.js | 256 +++++++++------------ .../fusion/scripts/DS2-directives/ds2LeftMenu.js | 18 +- 2 files changed, 111 insertions(+), 163 deletions(-) (limited to 'ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives') diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/ds2Header.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/ds2Header.js index 87ae7a31..7dcbdbe8 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/ds2Header.js +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/ds2Header.js @@ -1,152 +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', '$window', '$cookies', "$cookieStore", function ($scope, $filter, $http, $timeout, $log,UserInfoServiceDS2, $window, $cookies, $cookieStore) { - // copy from existing DS1 - /*Define fields*/ - $scope.userName; - $scope.userFirstName; - /*$scope.redirectUrl; - $scope.contactUsUrl; - $scope.getAccessUrl; - $scope.childData=[]; - $scope.parentData=[]; - $scope.menuItems = []; - $scope.loadMenufail=false; - $scope.megaMenuDataObject=[]; - $scope.activeClickSubMenu = { - x: '' - }; - $scope.activeClickMenu = { - x: '' - }; - $scope.favoritesMenuItems = []; - $scope.favoriteItemsCount = 0; - $scope.showFavorites = false; - $scope.emptyFavorites = false; - $scope.favoritesWindow = false;*/ +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 - //DS2 code - $scope.tabItems = [ - { - 'title': 'ECOMP' - }, - { - 'title': 'Help', - 'subitems': [{ - 'value': 'Contact Us' + /*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") ); - }, { - 'value': 'Get Access' - }, - ]}, - ]; - - $scope.userProfile = {}; - $scope.showInfo = false; - $scope.showProfile = function () { - $scope.showInfo = !$scope.showInfo; - }; - $scope.loginOptions1 = [ - {value: '', text: 'Log In..'}, - {value: '1', text: 'Premier'}, - {value: '2', text: 'Wifi Services'}, - {value: '3', text: 'Cloud Solutions'} - ]; - $scope.loginVal = {}; - $scope.loginVal.value = $scope.loginOptions1[0].value; - - $scope.clickLogin = function () { - $scope.openDropdown = !$scope.openDropdown; - }; - $scope.skipNavigation = function () { - var element = angular.element(document.querySelector('li.last'))[0]; - element.children[0].focus(); - }; - - /***************functions**************/ - /*Put user info into fields*/ + + /***************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; + } - $scope.inputUserInfo = function(userInfo){ - if (typeof(userInfo) != "undefined" && userInfo!=null && userInfo!=''){ - if(typeof(userInfo.USER_FIRST_NAME) != "undefined" && userInfo.USER_FIRST_NAME!=null){ - $scope.userFirstName = userInfo.USER_FIRST_NAME; - } - } - } - /*getting user info from session*/ - $scope.getUserNameFromSession = function(){ - UserInfoServiceDS2.getFunctionalMenuStaticDetailSession() - .then(function (res) { - $scope.contactUsUrl=res.contactUsLink; - $scope.userName = res.userName; - $scope.userFirstName = res.firstName; - $scope.redirectUrl = res.portalUrl; - $scope.getAccessUrl = res.getAccessUrl; - $scope.userProfile.fullName = res.userName; - $scope.userProfile.email = res.email; - }); - } + /*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; + }; - /*Put user info into fields*/ - $scope.inputUserInfo = function(userInfo){ - if (typeof(userInfo) != "undefined" && userInfo!=null && userInfo!=''){ - if (typeof(userInfo.USER_FIRST_NAME) != "undefined" && userInfo.USER_FIRST_NAME!=null && userInfo.USER_FIRST_NAME!='') - $scope.userProfile.firstName = userInfo.USER_FIRST_NAME; - if (typeof(userInfo.USER_LAST_NAME) != "undefined" && userInfo.USER_LAST_NAME!=null && userInfo.USER_LAST_NAME!='') - $scope.userProfile.lastName = userInfo.USER_LAST_NAME; - if (typeof(userInfo.USER_EMAIL) != "undefined" && userInfo.USER_EMAIL!=null && userInfo.USER_EMAIL!='') - $scope.userProfile.email = userInfo.USER_EMAIL; - } - } + $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); + } + ); + } - /*getting user info from shared context*/ - $scope.getUserName=function() { - var promise = UserInfoServiceDS2.getFunctionalMenuStaticDetailShareContext(); - promise.then( - function(res) { - if(res==null || res==''){ - $log.warn('DS2HeaderCtlr::getUserName: failed to get info from shared context'); - $scope.getUserNameFromSession(); - }else{ - // $log.info('Received User information from shared context',res); - var resData = res; - $scope.inputUserInfo(resData); - $scope.userProfile.fullName = $scope.userProfile.firstName+ ' '+ $scope.userProfile.lastName; - } - }, - function(err) { - console.log('error'); - } - ); - }; - - $scope.adjustHeader=function() { - $scope.showHeader = ($cookieStore.get("show_app_header") == undefined ? true : $cookies.show_app_header); - if($scope.showHeader == true) { - $scope.drawer_margin_top = 70; - $scope.drawer_custom_top = 54; - $scope.toggle_drawer_top = 55; - } - else { - - $scope.drawer_margin_top = 60; - $scope.drawer_custom_top = 0; - $scope.toggle_drawer_top = 10; - } - - } + + + $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(); + }); - /*call the get user info function*/ - try{ - $scope.getUserName(); - $scope.adjustHeader(); - - }catch(err){ - $log.info('Error while getting User information',err); - } - }] - } -}); \ No newline at end of file + $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; + } +}); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/ds2LeftMenu.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/ds2LeftMenu.js index 8174c586..758add6e 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/ds2LeftMenu.js +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/ds2LeftMenu.js @@ -64,23 +64,7 @@ appDS2.directive('ds2Menu', function () { },function(error){ console.log("error happened while calling getAppName "+error); }); - - $scope.adjustHeader=function() { - $scope.showHeader = ($cookies.show_app_header == undefined ? true : $cookies.show_app_header); - if ($scope.showHeader == true) { - $scope.drawer_margin_top = 50; - $scope.drawer_custom_top = 54; - $scope.toggle_drawer_top = 55; - } - else { - $scope.drawer_margin_top = 40; - $scope.drawer_custom_top = 0; - $scope.toggle_drawer_top = 10; - } - }; // adjustHeader - - - $scope.adjustHeader(); + $scope.drawerOpen = true; -- cgit 1.2.3-korg