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