aboutsummaryrefslogtreecommitdiffstats
path: root/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-directives
diff options
context:
space:
mode:
Diffstat (limited to 'usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-directives')
-rw-r--r--usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-directives/b2b-leftnav-ext.js64
-rw-r--r--usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-directives/ds2Header.js116
-rw-r--r--usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-directives/ds2LeftMenu.js73
-rw-r--r--usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-directives/footer.js27
4 files changed, 280 insertions, 0 deletions
diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-directives/b2b-leftnav-ext.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-directives/b2b-leftnav-ext.js
new file mode 100644
index 00000000..64da0a49
--- /dev/null
+++ b/usecaseui-common/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/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;
+ }
+});
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
diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-directives/footer.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-directives/footer.js
new file mode 100644
index 00000000..e11c3a05
--- /dev/null
+++ b/usecaseui-common/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