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