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