From 6beb446925c967aca92f5513adf36c5db77c00d6 Mon Sep 17 00:00:00 2001 From: TATTAVARADA Date: Thu, 27 Apr 2017 07:53:18 -0400 Subject: [PORTAL-7] Rebase This rebasing includes common libraries and common overlays projects abstraction of components Change-Id: Ia1efa4deacdc5701e6205104ac021a6c80ed60ba Signed-off-by: st782s --- .../scripts/DS2-directives/b2b-leftnav-ext.js | 64 +++++++++ .../app/fusion/scripts/DS2-directives/ds2Header.js | 152 +++++++++++++++++++++ .../fusion/scripts/DS2-directives/ds2LeftMenu.js | 89 ++++++++++++ .../app/fusion/scripts/DS2-directives/footer.js | 27 ++++ 4 files changed, 332 insertions(+) create mode 100644 ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/b2b-leftnav-ext.js create mode 100644 ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/ds2Header.js create mode 100644 ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/ds2LeftMenu.js create mode 100644 ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/footer.js (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/b2b-leftnav-ext.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/b2b-leftnav-ext.js new file mode 100644 index 00000000..64da0a49 --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/b2b-leftnav-ext.js @@ -0,0 +1,64 @@ +appDS2.directive('leftMenuEcomp', function () { + /* + * Custom version of b2b-left-navigation directive: + * 1. Make parent menu a link if no child menus. + * 2. Add unique IDs to all items. + * 3. Hide icon if no child menus. + * 4. Arrow toggle button. + * 5. Adjust the page on collapse/expand. + */ + return { + restrict: 'EA', + templateUrl: 'app/fusion/scripts/DS2-view-models/b2b-leftnav-ext.html', + scope: { + menuData: '=' + }, + link: function (scope, element, attrs, ctrl) { + scope.idx = -1; + scope.itemIdx = -1; + scope.navIdx = -1; + /*assuming menu is expanded when page loads*/ + scope.showmenu=true; + scope.leftMenuClass= ""; + scope.leftMenuArrowClass="leftmenu-arrow-expand"; + scope.toggleNav = function (val,link,menuStatus) { + + if(!menuStatus){ + scope.toggleDrawer(menuStatus); + return; + } + if(link!=null && link!=''){ + location.href = link; + return; + } + if (val === scope.idx) { + scope.idx = -1; + return; + } + scope.idx = val; + }; + scope.toggleDrawer = function(menuStatus){ + scope.idx=-1; /*hide the sub menus*/ + if(menuStatus){ + //Collapse Menu + scope.showmenu=false; + scope.leftMenuClass = "left-menu-collapsed"; + scope.leftMenuArrowClass="leftmenu-arrow-collapse"; + document.getElementById('page-content').style.marginLeft = "50px"; + }else{ + //Expand Menu + scope.showmenu=true; + scope.leftMenuClass = ""; + scope.leftMenuArrowClass="leftmenu-arrow-expand"; + document.getElementById('page-content').style.marginLeft = "250px"; + } + + }; + scope.liveLink = function (evt, val1, val2) { + scope.itemIdx = val1; + scope.navIdx = val2; + evt.stopPropagation(); + }; + } + }; +}); \ No newline at end of file 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 new file mode 100644 index 00000000..87ae7a31 --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/ds2Header.js @@ -0,0 +1,152 @@ + 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;*/ + + //DS2 code + $scope.tabItems = [ + { + 'title': 'ECOMP' + }, + { + 'title': 'Help', + 'subitems': [{ + 'value': 'Contact Us' + + }, { + '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*/ + + $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; + }); + } + + /*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; + } + } + + /*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; + } + + } + + /*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 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 new file mode 100644 index 00000000..8174c586 --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/ds2LeftMenu.js @@ -0,0 +1,89 @@ +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.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; + + + }] + } +}); \ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/footer.js b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/footer.js new file mode 100644 index 00000000..e11c3a05 --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/app/fusion/scripts/DS2-directives/footer.js @@ -0,0 +1,27 @@ +appDS2.directive('ds2Footer', 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/footer.html", + controller: ['$scope', '$filter','ManifestService', function ($scope, $filter,ManifestService) { + $scope.build_number = ''; + ManifestService.getManifest().then(function(response){ + $scope.build_number=response['Build-Number']; + }); + }] + } +}); + +/*Analytics for all the pages*/ +$(function() { + portalHook(); + function portalHook() { + var script = document.createElement('script'); + script.src = "api/v2/analytics" + script.async = true; + script.onload = function() { + runAnalytics(); //runAnaltics() has endpoint in epsdk-fw library. + } + document.head.appendChild(script); + } +}); \ No newline at end of file -- cgit 1.2.3-korg