[VID-6] Initial rebase push
[vid.git] / epsdk-app-onap / src / main / webapp / WEB-INF / fusion / jsp / ds2 / left-menu.jsp
1 <%--\r
2   ================================================================================\r
3   eCOMP Portal SDK\r
4   ================================================================================\r
5   Copyright (C) 2017 AT&T Intellectual Property\r
6   ================================================================================\r
7   Licensed under the Apache License, Version 2.0 (the "License");\r
8   you may not use this file except in compliance with the License.\r
9   You may obtain a copy of the License at\r
10   \r
11        http://www.apache.org/licenses/LICENSE-2.0\r
12   \r
13   Unless required by applicable law or agreed to in writing, software\r
14   distributed under the License is distributed on an "AS IS" BASIS,\r
15   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16   See the License for the specific language governing permissions and\r
17   limitations under the License.\r
18   ================================================================================\r
19   --%>\r
20 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>\r
21 <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>\r
22 <%@ page isELIgnored="false"%>\r
23 <%@ page import="org.openecomp.portalsdk.core.util.SystemProperties"%>\r
24 <%@ page import="org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties"%>\r
25 <%@ page import="org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants"%>\r
26 <%@ page import="org.openecomp.portalsdk.core.domain.MenuData"%>\r
27 <link rel="stylesheet" type="text/css" href="app/fusion/external/ebz/ebz_header/header.css">\r
28 <link rel="stylesheet" type="text/css" href="app/fusion/external/ebz/ebz_header/portal_ebz_header.css">\r
29 <link rel="stylesheet" type="text/css" href="app/fusion/external/ebz/sandbox/styles/style.css" >\r
30 \r
31 \r
32 <!-- <script src= "app/fusion/external/ebz/angular_js/angular.js"></script> \r
33 <script src= "app/fusion/external/ebz/angular_js/angular-route.min.js"></script>\r
34 <script src= "app/fusion/external/ebz/angular_js/angular-sanitize.js"></script>\r
35 <script src= "app/fusion/external/ebz/angular_js/angular-cookies.js"></script>\r
36 <script src= "app/fusion/external/ebz/angular_js/app.js"></script>\r
37 <script src= "app/fusion/external/ebz/angular_js/gestures.js"></script>\r
38 <script src="static/js/jquery-1.10.2.js"></script>\r
39 <script src="app/fusion/scripts/modalService.js"></script>\r
40 <script src="static/js/jquery.mask.min.js" type="text/javascript"></script>\r
41 <script src="static/js/jquery-ui.js" type="text/javascript"></script>\r
42 <script src="app/fusion/external/ebz/sandbox/att-abs-tpls.js" type="text/javascript"></script>\r
43 <script src="static/fusion/js/att_angular_gridster/ui-gridster-tpls.js"></script>\r
44 <script src="static/fusion/js/att_angular_gridster/angular-gridster.js"></script>\r
45 <script src= "app/fusion/external/ebz/angular_js/checklist-model.js"></script>\r
46 <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/0.10.0/lodash.min.js"></script>\r
47 <script src="app/fusion/external/angular-ui/ui-bootstrap-tpls-1.1.2.min.js"></script>\r
48 <script src="app/fusion/scripts/services/userInfoService.js"></script>\r
49 <script src="app/fusion/scripts/services/leftMenuService.js"></script> -->\r
50 \r
51 \r
52 <jsp:include page="/WEB-INF/fusion/jsp/ebz/loginSnippet.html" ></jsp:include> \r
53 \r
54 \r
55 <c:set var="UserName"   value="<%= session.getAttribute(\"fullName\")%>" />\r
56 <c:set var="UserFirstName"      value="<%= session.getAttribute(\"first_name\")%>" />\r
57 \r
58 <% \r
59         String contactUsLink = SystemProperties.getProperty(SystemProperties.CONTACT_US_LINK);\r
60         String redirectUrl = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL);\r
61         String portalUrl = redirectUrl;\r
62         String getAccessLink = redirectUrl.substring(0, redirectUrl.lastIndexOf('/')) + "/get_access";  \r
63 %>\r
64 <c:set var="returnPortalUrl" value="<%=portalUrl%>" />\r
65 <c:set var="contactUsLink" value="<%=contactUsLink%>" />\r
66 <c:set var="getAccessLink" value="<%=getAccessLink%>" />\r
67 \r
68 <style>\r
69 </style>\r
70 \r
71 <%@include  file="/WEB-INF/fusion/jsp/ebz/loginSnippet.html" %>\r
72 \r
73 <div style="position: relative; z-index: 999;">\r
74         <div ng-controller="headerController">\r
75         \r
76                  <div class="headerContainer" id="headerContainer" ng-cloak  ng-show="{{showHeader}}">\r
77                         <div id="megaMenuContainer" class="megaMenuContainer" style="margin-top: 0; overflow: visible;">\r
78                                 <div>\r
79                                         <!--for mega Menu-->\r
80                                         <!-- Mega Menu parent-tab directive with three models menu-items, active-sub-menu, active-menu -->\r
81                                         <div id="topMenu" class="top-megamenu" ng-mouseleave="activeClickSubMenu.x.active=false; activeClickMenu.x.active=false">\r
82                                                 <div style="float:left;width:100%;"parent-tab menu-items="megaMenuDataObject" active-sub-menu='activeClickSubMenu.x' active-menu='activeClickMenu.x'>\r
83                                         <div parentmenu-tabs mega-menu="true" menu-items="megaMenuDataObject" style="height:55px;">\r
84                                                                 <div style="float:left">\r
85                                                                         <li class="megamenu__item" style="line-height:55px;" onclick="returnToPortal()">\r
86                                                                                 <img src="app/fusion/external/ebz/images/logo.png" class="Logo"   ></span>\r
87 <!--                                                                                    <a id='returnPortal' class="primaryMenuOptionLink" style="font-weight: 400 !important; font-family: clearview_att_bold !important; font-size: 18px;">ECOMP</a>\r
88  -->                                                                            <strong style="font-weight: 400 !important; font-family: clearview_att_bold !important; font-size: 18px;" id='returnPortal' >ECOMP Portal</strong>\r
89                                                                         </li>                                                                           \r
90                                                                         <div menu-tabs mega-menu="true" tab-name="item.text" menu-item="item" active-menu="activeClickMenu.x" \r
91                                                                         ng-repeat="item in megaMenuDataObject" style="font-size: 18px;" ng-mousedown="loadFavorites()" >\r
92                                                         <div parentmenu-tabs sub-menu="true" ng-show="activeClickMenu.x.active && item.active" menu-items="activeClickMenu.x.children">\r
93                                                         <!-- Second level menu -->\r
94                                                                         <div>\r
95                                                                                 <div menu-tabs sub-menu="true" tab-name="subItem.text" \r
96                                                                                         tab-url="subItem.url"  menu-item="subItem" \r
97                                                                                         ng-repeat="subItem in activeClickMenu.x.children | orderBy : 'column'" active-menu="activeClickSubMenu.x" \r
98                                                                                         sub-item-active="{{subItem.active}}" style="float:left;" aria-label="{{subItem.text}}"\r
99                                                  ng-mouseenter="submenuLevelAction(subItem.text,subItem.column)"\r
100                                                  ng-mouseleave="submenuLevelAction(subItem.text,subItem.column)"\r
101                                                 ng-click="submenuLevelAction(subItem.text,subItem.column)"  >\r
102                                                 <i ng-if="subItem.text=='Favorites'" id="favorite-star"\r
103                                                    class="icon-star favorites-icon-active">\r
104                                                 </i>\r
105                                                                                 </div>\r
106                                                                                                 \r
107                                                         <div class="sub__menu" ng-mouseleave="activeClickSubMenu.x.active=false" >\r
108                                                                 <ul ng-show="activeClickSubMenu.x.active"  role="menubar" class="columns">\r
109                                        <!-- Third level menu -->                                                                                \r
110                                                                     <div menu-tabs menu-item="subItem" \r
111                                                                     class="columns-div"\r
112                                                                     ng-repeat="subItem in activeClickSubMenu.x.children | orderBy : 'column'" \r
113                                                                     ng-show="activeClickSubMenu.x.active">\r
114 \r
115                                                             <i id="favorite-selector-third-level"\r
116                                                                ng-show="isUrlFavorite(subItem.menuId)==false"\r
117                                                                class="icon-star favorites-icon-inactive"\r
118                                                                ng-if="subItem.url.length > 1">\r
119                                                             </i>                                                                            \r
120                                                             <i id="favorite-selector-third-level"\r
121                                                                ng-show="isUrlFavorite(subItem.menuId)"\r
122                                                                class="icon-star favorites-icon-active"\r
123                                                                ng-if="subItem.url.length > 1">\r
124                                                             </i>                                                                            \r
125                                                                                                                 <span class="title" aria-label="{{subItem.text}}" \r
126                                                                                                                 ng-click="goToUrl(subItem)">{{subItem.text}}</span>\r
127                                                         <!-- Fourth level menus -->     \r
128                                                                         <div att-links-list="">\r
129                                                             <i id="favorite-selector-fourth-level"\r
130                                                                class="icon-star favorites-icon-inactive"\r
131                                                                ng-show="isUrlFavorite(tabValue.menuId)==false"\r
132                                                                ng-if="tabValue.url.length > 1">\r
133 \r
134                                                             </i>\r
135                                                             <i id="favorite-selector-fourth-level"\r
136                                                                class="icon-star favorites-icon-active"\r
137                                                                ng-show="isUrlFavorite(tabValue.menuId)"\r
138                                                                ng-if="tabValue.url.length > 1">\r
139 \r
140                                                             </i>\r
141                                                                             <span role="menuitem" att-links-list-item="" \r
142                                                                             ng-repeat="tabValue in subItem.children" \r
143                                                                             ng-click="goToUrl(tabValue)" \r
144                                                                             att-accessibility-click="13,32" \r
145                                                                             ng-class="{'disabled': tabValue.disabled}">{{tabValue.text}}</span>\r
146                                                                         </div>\r
147                                                                         <hr ng-show="!$last"/>\r
148                                                                         \r
149                                                                     </div>\r
150                                                                  </ul>\r
151                                    <!-- Favorites level menu -->\r
152                                                                                                 <div class="favorites-window" ng-show='favoritesWindow' ng-mouseleave="hideFavoritesWindow()">\r
153                                                                                                         <div id="favorites-menu-items" ng-show="showFavorites">\r
154                                                                                                                 <div ng-repeat="subItem in favoritesMenuItems" att-links-list="" style='display: inline'>\r
155                                                                                                                                 <i id="favorite-selector-favorites-list" class="icon-star favorites-icon-active">\r
156                                                                                                                                 </i>\r
157                                                                                                                                 <a id="favorites-list" aria-label="{{subItem.text}}"\r
158                                                                                                                                    ng-click="goToUrl(subItem)" \r
159                                                                                                                                    style="margin-left: 3px; margin-right: 20px; text-decoration: none;  color: #666666;">\r
160                                                                                                                                    {{subItem.text}}\r
161                                                                                                                                 </a>\r
162                                                                                                                 </div>\r
163                                                                                                                 <div>\r
164                                                                                                                         <br>\r
165                                                                                                                         <p style='font-weight: 400; font-family: clearview_att_bold !important;\r
166                                                                                                                         font-size: 18px; text-align: center; background-color: lightgray;\r
167                                                                                                                         width: 400px; margin-left: 25%; margin-right: 25%;'>\r
168                                                                                                                                 Manage favorites on ECOMP Portal.\r
169                                                                                                                         </p>\r
170                                                                                                                 </div>\r
171                                                                                                         </div>\r
172                                                                   <!-- Favorites when empty -->\r
173                                                                                                                 <div id="favorites-empty" ng-show='favoritesWindow' ng-show="emptyFavorites">\r
174                                                                         <div id="favorites-empty" ng-show="emptyFavorites" class="favorites-window-empty">\r
175                                                                             <div>\r
176                                                                                 <img src="app/fusion/external/ebz/images/no_favorites_star.png">\r
177                                                                                 <p class='favoritesLargeText'>No Favorites</p>\r
178                                                                                                                                         <p class='favoritesNormalText'>Manage favorites on ECOMP Portal.</p>\r
179                                                                             </div>\r
180                                                                         </div>\r
181                                                                                                                 </div>\r
182                                                                                                         </div>\r
183                                                                         \r
184                                                                 </div>\r
185                                                             </div>\r
186                                                         </div> \r
187                                                     </div >\r
188                                                     <li class="megamenu__item" style="line-height:55px;" ng-if="loadMenufail">\r
189                                                                                 <strong style="font-weight: 400 !important; font-family: clearview_att_bold !important; font-size: 18px;" >Unable to load menus</strong>\r
190                                                                         </li>\r
191 <!--                                                                            <li class="megamenu__item" style="width: 20%;">&nbsp;</li>\r
192  -->                                                                    </div>\r
193                                                                 <!--  Login Snippet-->\r
194                                                                 <div  style="float:right">\r
195                                                                         <li id="bcLoginSnippet" class="megamenu__item" style="width: 140px;" >\r
196                                                                                 <div popover="loginSnippet.html"  aria-label="Login Snippet"    referby="loginSnippet" att-accessibility-click="13,32" popover-style="\" popover-placement="below" style="width: 200px;">\r
197                                                                                         <div class="icon-user-small login-snippet-icon"></div>\r
198                                                                                         <div class="login-snippet-text" style="display: inline-block; font-size:12px; margin-left:5px;overflow: hidden; max-height: 31px;   max-width:120px; padding-top: 0px; margin-top: 0px; white-space: nowrap;" ng-bind="userProfile.firstName"></div>\r
199                                                                                 </div>\r
200                                                                         </li>\r
201                                                                         <li class="megamenu__item" style="width:120px;">&nbsp;</li>\r
202                                                                 </div>\r
203                                                                 \r
204                                                         </div>          \r
205                                                 </div>\r
206                                                 <div style="clear: both"></div>\r
207                                         </div>\r
208                                         </div>\r
209                                 </div>\r
210                         </div>\r
211                 <div class="license-notification" id="license-notification">\r
212                         <a href="javascript:void(0)" style="background-color:#bbb;" class="button button--small" tooltip="Please contact ECOMP Portal team to get the license" tooltip-placement="below" tooltip-style="light"  tooltip-popup-delay="500" >\r
213                                 <span style="">{{app_name_full}}</span>\r
214                         </a>                                                                    \r
215                 </div>\r
216                 <div style="position: relative; color: black; top: 70px;">\r
217                         <div ng-cloak>          \r
218                                 <span ng-style="adjustHLeftMenu('burgerIcon')" style="z-index:998; position:fixed; left:0%; font-size:35px; margin-left:10px;text-decoration:none;">\r
219                                         <a ng-click="toggleDrawer();isOpen = !isOpen" href="javascript:void(0);" class="arrow-icon-left" >\r
220                                         <span class="icon-hamburger"></span></a>        \r
221                                         <span ng-init="isOpen = true" ng-show="isOpen" style="font-size:16px; position:relative; top:-8px; left:-15px;">&nbsp&nbsp&nbsp {{app_name}}</span>\r
222                                 </span>\r
223                                 <div att-drawer drawer-slide="left" drawer-custom-top="{{drawer_custom_top}}px" drawer-size="200px" drawer-open="drawerOpen" drawer-custom-height="100%" >\r
224                                     <div ng-style="adjustHLeftMenu('leftMenu')">\r
225                                             <div class="attDrawer" style="margin-top:{{drawer_margin_top}}px;">   \r
226                                                 <div style="margin-left:10px; margin-right:10px;">\r
227                                                         <accordion close-others="true" css="att-accordion--no-box">\r
228                                                     <accordion-group ng-repeat="parent in menuItems" heading="{{parent.parentLabel}}" child="{{parent.parentAction}}" parent-link="{{parent.parentAction}}" image-source="{{parent.parentImageSrc}}" child-length="{{parent.childItemList.length}}" is-open="parent.open">\r
229                                                         <div ng-repeat="subMenu in parent.childItemList" style="font-size:12px; margin-left:10px;">\r
230                                                                 <a href="{{subMenu.action}}" style="font-size:12px; color:#666666;" >{{subMenu.label}}</a>\r
231                                                         </div>\r
232                                                     </accordion-group>\r
233                                                 </accordion>\r
234                                                         </div>                                          \r
235                                             </div>\r
236                                     </div>\r
237                                 </div>\r
238                         </div>          \r
239                 </div>\r
240         </div>\r
241 </div>\r
242 \r
243 <script>    \r
244         function returnToPortal(){\r
245                 window.location.href = "<c:out value='${returnPortalUrl}'/>";\r
246         }\r
247         detectScrollEvent = function() {\r
248                 var footerOff = $('#footerContainer').offset().top;\r
249                 var headOff = $('#headerContainer').offset().top;\r
250                 var winHeight = $(window).height();\r
251                 if ((footerOff - headOff) <= winHeight) {\r
252                         $('.att-drawer').css({\r
253                                 "height" : footerOff - headOff - 55\r
254                         });\r
255                 } else {\r
256                         $('.att-drawer').css({\r
257                                 "height" : "94vh"\r
258                         });\r
259                 }\r
260         }\r
261         $(window).scroll(function() {\r
262                 if ($('.att-drawer').is(':visible')) {\r
263                         detectScrollEvent();\r
264                 }\r
265         });\r
266         app.controller("headerController", function($scope, $timeout, $log, $http, UserInfoService, $window, $cookies,LeftMenuService) {\r
267                 // $log.debug('HeaderController started');\r
268                 $scope.jsonMenuData = [];\r
269                 $scope.loadMenufail=false;\r
270                 $scope.app_name = "";\r
271                 $scope.app_name_full = "";\r
272                 $scope.megaMenuDataObject =[];\r
273                 $scope.activeClickSubMenu = {\r
274                         x: ''\r
275         };\r
276         $scope.activeClickMenu = {\r
277                         x: ''\r
278         };\r
279                 $scope.favoritesMenuItems = [];\r
280         $scope.favoriteItemsCount = 0;\r
281         $scope.showFavorites = false;\r
282         $scope.emptyFavorites = false;\r
283         $scope.favoritesWindow = false;\r
284         $scope.userProfile={\r
285                         firstName:'',\r
286                         lastName:'',\r
287                         fullName:'',\r
288                         email:''\r
289         }\r
290         /*Put user info into fields*/\r
291         $scope.inputUserInfo = function(userInfo){\r
292                 if (typeof(userInfo) != "undefined" && userInfo!=null && userInfo!=''){\r
293                         if (typeof(userInfo.USER_FIRST_NAME) != "undefined" && userInfo.USER_FIRST_NAME!=null && userInfo.USER_FIRST_NAME!='')\r
294                                 $scope.userProfile.firstName = userInfo.USER_FIRST_NAME;\r
295                         if (typeof(userInfo.USER_LAST_NAME) != "undefined" && userInfo.USER_LAST_NAME!=null && userInfo.USER_LAST_NAME!='')\r
296                                 $scope.userProfile.lastName = userInfo.USER_LAST_NAME;\r
297                         if (typeof(userInfo.USER_EMAIL) != "undefined" && userInfo.USER_EMAIL!=null && userInfo.USER_EMAIL!='')                         \r
298                                 $scope.userProfile.email = userInfo.USER_EMAIL;\r
299                 }               \r
300         }\r
301          /*getting user info from session*/\r
302         $scope.getUserNameFromSession = function(){\r
303                 UserInfoService.getFunctionalMenuStaticDetailSession()\r
304                 .then(function (res) {\r
305                                 $scope.userProfile.firstName = res.firstName;\r
306                                 $scope.redirectUrl = res.portalUrl;\r
307                 });\r
308         }\r
309         $scope.getTopMenuStaticInfo=function() {\r
310                 var promise = UserInfoService.getFunctionalMenuStaticDetailShareContext();\r
311                 promise.then(\r
312                                 function(res) {                                         \r
313                                         if(res==null || res==''){\r
314                                                 $log.info('failed getting static User information');    \r
315                                                 $scope.getUserNameFromSession();\r
316                                         }else{\r
317                                                 $log.info('Received static User information');\r
318                                                 var resData = res;                                              \r
319                                                 $scope.inputUserInfo(resData);                                  \r
320                                                 $scope.userProfile.fullName = $scope.userProfile.firstName+ ' '+ $scope.userProfile.lastName;                                   \r
321                                         }\r
322                                 },\r
323                                 function(err) {\r
324                                         $log.info('failed getting static User information');                                    \r
325                                 }\r
326                 );\r
327                 }\r
328                         \r
329                 var unflatten = function( array, parent, tree ){\r
330                         tree = typeof tree !== 'undefined' ? tree : [];\r
331                         parent = typeof parent !== 'undefined' ? parent : { menuId: null };\r
332                         var children = _.filter( array, function(child){ return child.parentMenuId == parent.menuId; });\r
333                 \r
334                         if( !_.isEmpty( children )  ){\r
335                                 if( parent.menuId === null ){\r
336                                                 tree = children;\r
337                                 }else{\r
338                                         parent['children'] = children\r
339                                 }\r
340                                 _.each( children, function( child ){ unflatten( array, child ) } );\r
341                         }\r
342 \r
343                         return tree;\r
344                 }\r
345                 \r
346                 var menuStructureConvert = function(menuItems) {\r
347                         var megaMenuDataObjectTemp = [\r
348                                          {\r
349                                                  text: "ECOMP",\r
350                                                  children:menuItems\r
351                                          },\r
352                                          {\r
353                                                  text: "Help",\r
354                                                  children: [{\r
355                                                          text:"Contact Us",\r
356                                                          url:"<c:out value='${contactUsLink}'/>"\r
357                                                  },\r
358                                                  {\r
359                                                          text:"Get Access",\r
360                                                          url:"<c:out value='${getAccessLink}'/>"\r
361                                                  }]\r
362                                          }\r
363                                          ];\r
364                         return megaMenuDataObjectTemp;\r
365                 }; \r
366                 \r
367                 \r
368                 /*Left Menu*/\r
369                 LeftMenuService.getAppName().then(function(response){\r
370                         var j = response; \r
371                         try{\r
372                                 if(j && j !== "null" && j!== "undefined"){\r
373                                         // console.log("app name is " + $scope.app_name);\r
374                                         $scope.app_name_full = j.data;\r
375                                         var processed_app_name = j.data;\r
376                                         if(processed_app_name.indexOf("[")<=-1) {\r
377                                                 if (document.getElementById('license-notification')!=null)\r
378                                                         document.getElementById('license-notification').style.display = "none"; \r
379                                         }\r
380                                         var n = processed_app_name.length;\r
381                                         if (n > 15) {\r
382                                                 n = 15;\r
383                                         }\r
384                                         $scope.app_name = processed_app_name.substr(0, n);\r
385                                 }else{\r
386                                         throw "Get app_name response is not an object/is empty"; \r
387                                 }  \r
388                         }catch (e) {\r
389                                 console.log("error happened while trying to get app name "+e);\r
390                                 return;\r
391                 }              \r
392                 },function(error){\r
393                         console.log('getAppName failed', error);\r
394                 });\r
395                 \r
396             $scope.getTopMenuStaticInfo();      \r
397         $scope.getMenu=function() {\r
398                 \r
399                  $http({\r
400                         method: "GET",\r
401                         url: 'get_functional_menu',\r
402 // TIMEOUT USED FOR LOCAL TESTING ONLY                          \r
403 //                      timeout: 100\r
404                  }).success(function (response) {\r
405                         if(response == '101: Timeout') {\r
406                                 $log.error('Timeout attempting to get_functional_menu');\r
407                         // TIMEOUT USED FOR LOCAL TESTING ONLY                          \r
408 //                              $scope.createErrorMenu();\r
409                                 $scope.megaMenuDataObject = menuStructureConvert('');\r
410                         }else {\r
411                                 $log.debug('get_functional_menu success: ' + response);                                                         \r
412                                 if(typeof response != 'undefined' && response.length!=0 && typeof response[0] != 'undefined' && typeof response[0].error!="undefined"){\r
413 // createErrorMenu() USED FOR LOCAL TESTING ONLY\r
414 //                                      $scope.createErrorMenu();\r
415                                         $scope.megaMenuDataObject = menuStructureConvert('');\r
416                                 //      $scope.loadMenufail=true;\r
417                                 }else{\r
418                                         $scope.jsonMenuData = unflatten( response );\r
419                                         $scope.megaMenuDataObject = menuStructureConvert($scope.jsonMenuData);\r
420                                 }\r
421                         }\r
422                 }).error(function (response){\r
423 // createErrorMenu() USED FOR LOCAL TESTING ONLY                                \r
424 //                              $scope.createErrorMenu();\r
425 \r
426                                 //$scope.loadMenufail=true;\r
427                                 $scope.megaMenuDataObject = menuStructureConvert('');\r
428                         $log.debug('REST API failed get_functional_menu...'+ response);\r
429                   });\r
430                 }\r
431         $scope.adjustHLeftMenu = function (type){\r
432                 $scope.showHeader = ($cookies.show_app_header == undefined ? true : $cookies.show_app_header);\r
433                 \r
434                 if($scope.showHeader == true) {\r
435                         $scope.drawer_margin_top = 60;\r
436                         $scope.drawer_custom_top = 54;\r
437                         $scope.toggle_drawer_top = 55;\r
438                 }\r
439                 else  {\r
440                         \r
441                         $scope.drawer_margin_top = 50;\r
442                         $scope.drawer_custom_top = 0;\r
443                         $scope.toggle_drawer_top = 10;\r
444                 }\r
445                 if(type=='burgerIcon'){\r
446                         return { "top": $scope.toggle_drawer_top+"px"};\r
447                 }else if(type=='leftMenu'){\r
448                         return { "margin-top": $scope.drawer_margin_top+"px"};\r
449                 }else\r
450                         return;\r
451         }\r
452         $scope.adjustHeader=function() {\r
453                 $scope.showHeader = ($cookies.show_app_header == undefined ? true : $cookies.show_app_header);\r
454                 \r
455                 if($scope.showHeader == true) {\r
456                         $scope.drawer_margin_top = 50;\r
457                         $scope.drawer_custom_top = 54;\r
458                         $scope.toggle_drawer_top = 55;\r
459                 }\r
460                 else  {\r
461                         \r
462                         $scope.drawer_margin_top = 40;\r
463                         $scope.drawer_custom_top = 0;\r
464                         $scope.toggle_drawer_top = 10;\r
465                 }\r
466                 \r
467                 \r
468         }\r
469         \r
470         \r
471                 //$scope.getMenu();\r
472                 $scope.adjustHeader();\r
473                 \r
474 \r
475                 /* **************************************************************************/\r
476                 /* Logic for the favorite menus is here */\r
477 \r
478             $scope.loadFavorites = function () {\r
479                 $log.debug('loadFavorites has happened.');\r
480                 if ($scope.favoritesMenuItems == '') {\r
481                     $scope.generateFavoriteItems();\r
482                     $log.debug('loadFavorites is calling generateFavoriteItems()');\r
483                 } else {\r
484                     $log.debug('loadFavorites is NOT calling generateFavoriteItems()');\r
485                 }\r
486             }\r
487             \r
488             $scope.goToUrl = function (item) {\r
489                 $log.info("goToUrl called")\r
490                 $log.info(item);\r
491 \r
492                 var url = item.url;\r
493                 var restrictedApp = item.restrictedApp;\r
494                 $log.debug('Restricted app status is: ' + restrictedApp);\r
495                 if (!url) {\r
496                     $log.info('No url found for this application, doing nothing..');\r
497                     return;\r
498                 }\r
499                 if (restrictedApp) {\r
500                     $window.open(url, '_blank');\r
501                 } else {\r
502                     $window.open(url, '_self');\r
503                 }\r
504 \r
505             }\r
506             \r
507             $scope.submenuLevelAction = function(index, column) {\r
508                 if ($scope.favoritesMenuItems == '') {\r
509                     $scope.generateFavoriteItems();\r
510                     $log.debug('submenuLevelAction is calling generateFavoriteItems()');\r
511                 }\r
512                 $log.debug('item hovered/clicked: ' + index + '; column = ' + column);\r
513                 if (column == 2) {  // 2 is Design\r
514                     $scope.favoritesWindow = false;\r
515                     $scope.showFavorites = false;\r
516                     $scope.emptyFavorites = false;\r
517                 }\r
518                 if (index=='Favorites' && $scope.favoriteItemsCount != 0) {\r
519                     $log.debug('Showing Favorites window');\r
520                     $scope.favoritesWindow = true;\r
521                     $scope.showFavorites = true;\r
522                     $scope.emptyFavorites = false;\r
523                 }\r
524                 if (index=='Favorites' && $scope.favoriteItemsCount == 0) {\r
525                     $log.debug('Hiding Favorites window in favor of No Favorites Window');\r
526                     $scope.favoritesWindow = true;\r
527                     $scope.showFavorites = false;\r
528                     $scope.emptyFavorites = true;\r
529                 }\r
530                 if (column > 2) {\r
531                     $scope.favoritesWindow = false;\r
532                     $scope.showFavorites = false;\r
533                     $scope.emptyFavorites = false;\r
534                 }\r
535             };\r
536             \r
537             $scope.hideFavoritesWindow = function() {\r
538                 $log.debug('$scope.hideFavoritesWindow has been called');\r
539                 $scope.showFavorites = false;\r
540                 $scope.emptyFavorites = false;\r
541             }\r
542             \r
543             $scope.isUrlFavorite = function (menuId) {\r
544 //                 $log.debug('array objects in menu favorites = ' + $scope.favoriteItemsCount + '; menuId=' + menuId);\r
545                 var jsonMenu =  JSON.stringify($scope.favoritesMenuItems);\r
546                 var isMenuFavorite =  jsonMenu.indexOf('menuId\":' + menuId);\r
547                 if (isMenuFavorite==-1) {\r
548                     return false;\r
549                 } else {\r
550                     return true;\r
551                 }\r
552 \r
553             }\r
554                             \r
555             $scope.generateFavoriteItems  = function() {\r
556                 $http({\r
557                         method: "GET",\r
558                         url: 'get_favorites',\r
559                 // TIMEOUT USED FOR LOCAL TESTING ONLY                          \r
560 //                                              timeout: 100\r
561                             }).success(function (response) {\r
562                                                 if (response == '101: Timeout') {\r
563                                                 $log.error('Timeout attempting to get_favorites_menu');\r
564                                         } else {\r
565                                                 if(typeof response != 'undefined' && response.length!=0 && typeof response[0] != 'undefined' && typeof response[0].error!="undefined"){\r
566                                                     $log.error('REST API failed get_favorites' + response);\r
567                                                         }else{\r
568                                                                 $log.debug('get_favorites = ' + JSON.stringify(response));\r
569                                                                 $scope.favoritesMenuItems = response;\r
570                                         $scope.favoriteItemsCount = Object.keys($scope.favoritesMenuItems).length;\r
571                                         $log.info('number of favorite menus: ' + $scope.favoriteItemsCount);\r
572                                 }\r
573                                                 }\r
574                                         }).error(function (response){\r
575                                             $log.error('REST API failed get_favorites' + response);\r
576                 //createFavoriteErrorMenu() USED FOR LOCAL TESTING ONLY                         \r
577 //                                                      $scope.createFavoriteErrorMenu();\r
578                                         });\r
579                 }\r
580                             \r
581                                 $scope.createFavoriteErrorMenu=function() {\r
582                                 $scope.favoritesMenuItems = [\r
583 //                                                          \r
584                                                                 ];\r
585                                 $scope.favoriteItemsCount = Object.keys($scope.favoritesMenuItems).length;\r
586                                 $log.info('number of favorite menus: ' + $scope.favoriteItemsCount);\r
587                                 }\r
588                             \r
589                 /* end of Favorite Menu code */\r
590                 /* **************************************************************************/\r
591 \r
592                 \r
593                 /* **************************************************************************/\r
594                 // THIS IS USED FOR LOCAL TESTING ONLY\r
595                 /* **************************************************************************/\r
596 \r
597                         $scope.createErrorMenu=function() {\r
598                 $scope.jsonMenuData = [\r
599                                   \r
600                                 ];\r
601                         $scope.jsonMenuData = unflatten( $scope.jsonMenuData );\r
602                         $scope.megaMenuDataObject = menuStructureConvert($scope.jsonMenuData);\r
603 //                      $log.debug(JSON.stringify($scope.jsonMenuData));\r
604         }\r
605                 var childItemList="";\r
606                 var parentList = "";\r
607                 try{\r
608                         childItemList = ${menu.childItemList};\r
609                         parentList = ${menu.parentList};\r
610                 }catch(err){\r
611                         console.log("ebz_header: failed to get child/parent lists", err);\r
612                 }\r
613                 \r
614                 var pageUrl = window.location.href.split('/')[window.location.href.split('/').length-1];\r
615                 \r
616                 $scope.menuItems = [];\r
617                 for (var i = 0; i < parentList.length; i++) {\r
618                         $scope.openCurrentMenu = false;\r
619                  if(pageUrl==parentList[i].action)\r
620                                 $scope.openCurrentMenu = true;\r
621                         $scope.childItemList = childItemList[i];\r
622                         for(chIndex in  $scope.childItemList){\r
623                                 if($scope.childItemList.length>0)\r
624                                         if($scope.childItemList[chIndex].action!=null){\r
625                                                 if($scope.childItemList[chIndex].action==pageUrl)\r
626                                                         $scope.openCurrentMenu = true;\r
627                                         }\r
628                         }\r
629                         $scope.item = {\r
630                                 parentLabel : parentList[i].label,\r
631                                 parentAction : parentList[i].action,\r
632                                 parentImageSrc : parentList[i].imageSrc,\r
633                                 open:$scope.openCurrentMenu,\r
634                                 childItemList : $scope.childItemList\r
635                         }\r
636                         $scope.menuItems.push($scope.item);\r
637                 }\r
638                 $scope.arrowShow = true;\r
639                 $scope.drawerOpen = false;\r
640                 $scope.subMenuContent = false;\r
641                 $scope.toggleSubMenu = function() {\r
642                         $scope.subMenuContent = !$scope.subMenuContent;\r
643                 };\r
644 \r
645                 var drawerOpen = 'open';\r
646                 if (drawerOpen == 'open') {\r
647                         $scope.drawerOpen = true;\r
648                         $scope.arrowShow = true;\r
649                 } else {\r
650                         $scope.arrowShow = false;\r
651                 }\r
652                 $scope.arrowShow = true;\r
653                 $scope.drawerOpen = false;\r
654                 $scope.toggleDrawer = function() {\r
655                         $scope.drawerOpen = !($scope.drawerOpen);\r
656                         if ($scope.drawerOpen) {\r
657                                 $scope.arrowShow = true;                                \r
658                                 if (document.getElementById('mContent')!=null)\r
659                                         document.getElementById('mContent').style.marginLeft = "0px";                   \r
660                         } else {\r
661                                 $scope.arrowShow = false;\r
662                                 if (document.getElementById('mContent')!=null)\r
663                                         document.getElementById('mContent').style.marginLeft = "-150px";\r
664                         }\r
665                 };\r
666                 //var drawerOpen = getCookie('drawerOpen');\r
667                 if (drawerOpen == 'open') {\r
668                         $scope.drawerOpen = true;\r
669                         $scope.arrowShow = true;\r
670                 } else {\r
671                         $scope.arrowShow = false;\r
672                 }\r
673                 $timeout(function() {\r
674                         detectScrollEvent();\r
675                 }, 800);\r
676                 \r
677         });\r
678         \r
679         app.filter("ellipsis", function(){\r
680             return function(text, length){\r
681                 if (text) {\r
682                     var ellipsis = text.length > length ? "..." : "";\r
683                     return text.slice(0, length) + ellipsis;\r
684                 };\r
685                 return text;        \r
686             }\r
687         });\r
688 </script>