[POLICY-122] Policy GUI Fixes
[policy/engine.git] / ECOMP-SDK-APP / src / main / webapp / WEB-INF / fusion / jsp / ds2 / left-menu.jsp
1 <%--
2   ================================================================================
3   eCOMP 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.openecomp.portalsdk.core.util.SystemProperties"%>
24 <%@ page import="org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties"%>
25 <%@ page import="org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants"%>
26 <%@ page import="org.openecomp.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 <!-- <script src= "app/fusion/external/ebz/angular_js/angular.js"></script> 
33 <script src= "app/fusion/external/ebz/angular_js/angular-route.min.js"></script>
34 <script src= "app/fusion/external/ebz/angular_js/angular-sanitize.js"></script>
35 <script src= "app/fusion/external/ebz/angular_js/angular-cookies.js"></script>
36 <script src= "app/fusion/external/ebz/angular_js/app.js"></script>
37 <script src= "app/fusion/external/ebz/angular_js/gestures.js"></script>
38 <script src="static/js/jquery-1.10.2.js"></script>
39 <script src="app/fusion/scripts/modalService.js"></script>
40 <script src="static/js/jquery.mask.min.js" type="text/javascript"></script>
41 <script src="static/js/jquery-ui.js" type="text/javascript"></script>
42 <script src="app/fusion/external/ebz/sandbox/att-abs-tpls.js" type="text/javascript"></script>
43 <script src="static/fusion/js/att_angular_gridster/ui-gridster-tpls.js"></script>
44 <script src="static/fusion/js/att_angular_gridster/angular-gridster.js"></script>
45 <script src= "app/fusion/external/ebz/angular_js/checklist-model.js"></script>
46 <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/0.10.0/lodash.min.js"></script>
47 <script src="app/fusion/external/angular-ui/ui-bootstrap-tpls-1.1.2.min.js"></script>
48 <script src="app/fusion/scripts/services/userInfoService.js"></script>
49 <script src="app/fusion/scripts/services/leftMenuService.js"></script> -->
50
51
52 <jsp:include page="/WEB-INF/fusion/jsp/ebz/loginSnippet.html" ></jsp:include> 
53
54
55 <c:set var="UserName"   value="<%= session.getAttribute(\"fullName\")%>" />
56 <c:set var="UserFirstName"      value="<%= session.getAttribute(\"first_name\")%>" />
57
58 <% 
59         String contactUsLink = SystemProperties.getProperty(SystemProperties.CONTACT_US_LINK);
60         String redirectUrl = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL);
61         String portalUrl = redirectUrl.substring(0, redirectUrl.lastIndexOf('/')) + "/process_csp";
62         String getAccessLink = redirectUrl.substring(0, redirectUrl.lastIndexOf('/')) + "/get_access";  
63 %>
64 <c:set var="returnPortalUrl" value="<%=portalUrl%>" />
65 <c:set var="contactUsLink" value="<%=contactUsLink%>" />
66 <c:set var="getAccessLink" value="<%=getAccessLink%>" />
67
68 <style>
69 </style>
70
71 <%@include  file="/WEB-INF/fusion/jsp/ebz/loginSnippet.html" %>
72
73 <div style="position: relative; z-index: 999;">
74         <div ng-controller="headerController">
75         
76                  <div class="headerContainer" id="headerContainer" ng-cloak  ng-show="{{showHeader}}">
77                         <div id="megaMenuContainer" class="megaMenuContainer" style="margin-top: 0; overflow: visible;">
78                                 <div>
79                                         <!--for mega Menu-->
80                                         <!-- Mega Menu parent-tab directive with three models menu-items, active-sub-menu, active-menu -->
81                                         <div id="topMenu" class="top-megamenu" ng-mouseleave="activeClickSubMenu.x.active=false; activeClickMenu.x.active=false">
82                                                 <div style="float:left;width:100%;"parent-tab menu-items="megaMenuDataObject" active-sub-menu='activeClickSubMenu.x' active-menu='activeClickMenu.x'>
83                                         <div parentmenu-tabs mega-menu="true" menu-items="megaMenuDataObject" style="height:55px;">
84                                                                 <div style="float:left">
85                                                                         <li class="megamenu__item" style="line-height:55px;" onclick="returnToPortal()">
86                                                                                 <img src="app/fusion/external/ebz/images/att_logo.png" class="ATTLogo"   ></span>
87                                                                                 <strong style="font-weight: 400 !important; font-family: "Omnes-ECOMP-W02", Arial !important; font-size: 18px;" id='returnPortal' >ECOMP Portal</strong>
88                                                                         </li>                                                                           
89                                                                         <div menu-tabs mega-menu="true" tab-name="item.text" menu-item="item" active-menu="activeClickMenu.x" 
90                                                                         ng-repeat="item in megaMenuDataObject" style="font-size: 18px;" ng-mousedown="loadFavorites()" >
91                                                         <div parentmenu-tabs sub-menu="true" ng-show="activeClickMenu.x.active && item.active" menu-items="activeClickMenu.x.children">
92                                                         <!-- Second level menu -->
93                                                                         <div>
94                                                                                 <div menu-tabs sub-menu="true" tab-name="subItem.text" 
95                                                                                         tab-url="subItem.url"  menu-item="subItem" 
96                                                                                         ng-repeat="subItem in activeClickMenu.x.children | orderBy : 'column'" active-menu="activeClickSubMenu.x" 
97                                                                                         sub-item-active="{{subItem.active}}" style="float:left;" aria-label="{{subItem.text}}"
98                                                  ng-mouseenter="submenuLevelAction(subItem.text,subItem.column)"
99                                                  ng-mouseleave="submenuLevelAction(subItem.text,subItem.column)"
100                                                 ng-click="submenuLevelAction(subItem.text,subItem.column)"  >
101                                                 <i ng-if="subItem.text=='Favorites'" id="favorite-star"
102                                                    class="icon-star favorites-icon-active">
103                                                 </i>
104                                                                                 </div>
105                                                                                                 
106                                                         <div class="sub__menu" ng-mouseleave="activeClickSubMenu.x.active=false" >
107                                                                 <ul ng-show="activeClickSubMenu.x.active"  role="menubar" class="columns">
108                                        <!-- Third level menu -->                                                                                
109                                                                     <div menu-tabs menu-item="subItem" 
110                                                                     class="columns-div"
111                                                                     ng-repeat="subItem in activeClickSubMenu.x.children | orderBy : 'column'" 
112                                                                     ng-show="activeClickSubMenu.x.active">
113
114                                                             <i id="favorite-selector-third-level"
115                                                                ng-show="isUrlFavorite(subItem.menuId)==false"
116                                                                class="icon-star favorites-icon-inactive"
117                                                                ng-if="subItem.url.length > 1">
118                                                             </i>                                                                            
119                                                             <i id="favorite-selector-third-level"
120                                                                ng-show="isUrlFavorite(subItem.menuId)"
121                                                                class="icon-star favorites-icon-active"
122                                                                ng-if="subItem.url.length > 1">
123                                                             </i>                                                                            
124                                                                                                                 <span class="title" aria-label="{{subItem.text}}" 
125                                                                                                                 ng-click="goToUrl(subItem)">{{subItem.text}}</span>
126                                                         <!-- Fourth level menus -->     
127                                                                         <div att-links-list="">
128                                                             <i id="favorite-selector-fourth-level"
129                                                                class="icon-star favorites-icon-inactive"
130                                                                ng-show="isUrlFavorite(tabValue.menuId)==false"
131                                                                ng-if="tabValue.url.length > 1">
132
133                                                             </i>
134                                                             <i id="favorite-selector-fourth-level"
135                                                                class="icon-star favorites-icon-active"
136                                                                ng-show="isUrlFavorite(tabValue.menuId)"
137                                                                ng-if="tabValue.url.length > 1">
138
139                                                             </i>
140                                                                             <span role="menuitem" att-links-list-item="" 
141                                                                             ng-repeat="tabValue in subItem.children" 
142                                                                             ng-click="goToUrl(tabValue)" 
143                                                                             att-accessibility-click="13,32" 
144                                                                             ng-class="{'disabled': tabValue.disabled}">{{tabValue.text}}</span>
145                                                                         </div>
146                                                                         <hr ng-show="!$last"/>
147                                                                         
148                                                                     </div>
149                                                                  </ul>
150                                    <!-- Favorites level menu -->
151                                                                                                 <div class="favorites-window" ng-show='favoritesWindow' ng-mouseleave="hideFavoritesWindow()">
152                                                                                                         <div id="favorites-menu-items" ng-show="showFavorites">
153                                                                                                                 <div ng-repeat="subItem in favoritesMenuItems" att-links-list="" style='display: inline'>
154                                                                                                                                 <i id="favorite-selector-favorites-list" class="icon-star favorites-icon-active">
155                                                                                                                                 </i>
156                                                                                                                                 <a id="favorites-list" aria-label="{{subItem.text}}"
157                                                                                                                                    ng-click="goToUrl(subItem)" 
158                                                                                                                                    style="margin-left: 3px; margin-right: 20px; text-decoration: none;  color: #666666;">
159                                                                                                                                    {{subItem.text}}
160                                                                                                                                 </a>
161                                                                                                                 </div>
162                                                                                                                 <div>
163                                                                                                                         <br>
164                                                                                                                         <p style='font-weight: 400; font-family: "Omnes-ECOMP-W02", Arial !important;
165                                                                                                                         font-size: 18px; text-align: center; background-color: lightgray;
166                                                                                                                         width: 400px; margin-left: 25%; margin-right: 25%;'>
167                                                                                                                                 Manage favorites on ECOMP Portal.
168                                                                                                                         </p>
169                                                                                                                 </div>
170                                                                                                         </div>
171                                                                   <!-- Favorites when empty -->
172                                                                                                                 <div id="favorites-empty" ng-show='favoritesWindow' ng-show="emptyFavorites">
173                                                                         <div id="favorites-empty" ng-show="emptyFavorites" class="favorites-window-empty">
174                                                                             <div>
175                                                                                 <img src="app/fusion/external/ebz/images/no_favorites_star.png">
176                                                                                 <p class='favoritesLargeText'>No Favorites</p>
177                                                                                                                                         <p class='favoritesNormalText'>Manage favorites on ECOMP Portal.</p>
178                                                                             </div>
179                                                                         </div>
180                                                                                                                 </div>
181                                                                                                         </div>
182                                                                         
183                                                                 </div>
184                                                             </div>
185                                                         </div> 
186                                                     </div >
187                                                     <li class="megamenu__item" style="line-height:55px;" ng-if="loadMenufail">
188                                                                                 <strong style="font-weight: 400 !important; font-family: "Omnes-ECOMP-W02", Arial !important; font-size: 18px;" >Unable to load menus</strong>
189                                                                         </li>
190 <!--                                                                            <li class="megamenu__item" style="width: 20%;">&nbsp;</li>
191  -->                                                                    </div>
192                                                                 <!--  Login Snippet-->
193                                                                 <div  style="float:right">
194                                                                         <li id="bcLoginSnippet" class="megamenu__item" style="width: 140px;" >
195                                                                                 <div popover="loginSnippet.html"  aria-label="Login Snippet"    referby="loginSnippet" att-accessibility-click="13,32" popover-style="\" popover-placement="below" style="width: 200px;">
196                                                                                         <div class="icon-user-small login-snippet-icon"></div>
197                                                                                         <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>
198                                                                                 </div>
199                                                                         </li>
200                                                                         <li class="megamenu__item" style="width:120px;">&nbsp;</li>
201                                                                 </div>
202                                                                 
203                                                         </div>          
204                                                 </div>
205                                                 <div style="clear: both"></div>
206                                         </div>
207                                         </div>
208                                 </div>
209                         </div>
210                 <div class="license-notification" id="license-notification">
211                         <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" >
212                                 <span style="">{{app_name_full}}</span>
213                         </a>                                                                    
214                 </div>
215                 <div style="position: relative; color: black; top: 70px;">
216                         <div ng-cloak>          
217                                 <span ng-style="adjustHLeftMenu('burgerIcon')" style="z-index:998; position:fixed; left:0%; font-size:35px; margin-left:10px;text-decoration:none;">
218                                         <a ng-click="toggleDrawer();isOpen = !isOpen" href="javascript:void(0);" class="arrow-icon-left" >
219                                         <span class="icon-hamburger"></span></a>        
220                                         <span ng-init="isOpen = true" ng-show="isOpen" style="font-size:16px; position:relative; top:-8px; left:-15px;">&nbsp&nbsp&nbsp {{app_name}}</span>
221                                 </span>
222                                 <div att-drawer drawer-slide="left" drawer-custom-top="{{drawer_custom_top}}px" drawer-size="200px" drawer-open="drawerOpen" drawer-custom-height="100%" >
223                                     <div ng-style="adjustHLeftMenu('leftMenu')">
224                                             <div class="attDrawer" style="margin-top:{{drawer_margin_top}}px;">   
225                                                 <div style="margin-left:10px; margin-right:10px;">
226                                                         <accordion close-others="true" css="att-accordion--no-box">
227                                                     <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">
228                                                         <div ng-repeat="subMenu in parent.childItemList" style="font-size:12px; margin-left:10px;">
229                                                                 <a href="{{subMenu.action}}" style="font-size:12px; color:#666666;" >{{subMenu.label}}</a>
230                                                         </div>
231                                                     </accordion-group>
232                                                 </accordion>
233                                                         </div>                                          
234                                             </div>
235                                     </div>
236                                 </div>
237                         </div>          
238                 </div>
239         </div>
240 </div>
241
242 <script>    
243         function returnToPortal(){
244                 window.location.href = "<c:out value='${returnPortalUrl}'/>";
245         }
246         detectScrollEvent = function() {
247                 var footerOff = $('#footerContainer').offset().top;
248                 var headOff = $('#headerContainer').offset().top;
249                 var winHeight = $(window).height();
250                 if ((footerOff - headOff) <= winHeight) {
251                         $('.att-drawer').css({
252                                 "height" : footerOff - headOff - 55
253                         });
254                 } else {
255                         $('.att-drawer').css({
256                                 "height" : "94vh"
257                         });
258                 }
259         }
260         $(window).scroll(function() {
261                 if ($('.att-drawer').is(':visible')) {
262                         detectScrollEvent();
263                 }
264         });
265         app.controller("headerController", function($scope, $timeout, $log, $http, UserInfoService, $window, $cookies,LeftMenuService) {
266                 // $log.debug('HeaderController started');
267                 $scope.jsonMenuData = [];
268                 $scope.loadMenufail=false;
269                 $scope.app_name = "";
270                 $scope.app_name_full = "";
271                 $scope.megaMenuDataObject =[];
272                 $scope.activeClickSubMenu = {
273                         x: ''
274         };
275         $scope.activeClickMenu = {
276                         x: ''
277         };
278                 $scope.favoritesMenuItems = [];
279         $scope.favoriteItemsCount = 0;
280         $scope.showFavorites = false;
281         $scope.emptyFavorites = false;
282         $scope.favoritesWindow = false;
283         $scope.userProfile={
284                         firstName:'',
285                         lastName:'',
286                         fullName:'',
287                         email:''
288         }
289         /*Put user info into fields*/
290         $scope.inputUserInfo = function(userInfo){
291                 if (typeof(userInfo) != "undefined" && userInfo!=null && userInfo!=''){
292                         if (typeof(userInfo.USER_FIRST_NAME) != "undefined" && userInfo.USER_FIRST_NAME!=null && userInfo.USER_FIRST_NAME!='')
293                                 $scope.userProfile.firstName = userInfo.USER_FIRST_NAME;
294                         if (typeof(userInfo.USER_LAST_NAME) != "undefined" && userInfo.USER_LAST_NAME!=null && userInfo.USER_LAST_NAME!='')
295                                 $scope.userProfile.lastName = userInfo.USER_LAST_NAME;
296                         if (typeof(userInfo.USER_EMAIL) != "undefined" && userInfo.USER_EMAIL!=null && userInfo.USER_EMAIL!='')                         
297                                 $scope.userProfile.email = userInfo.USER_EMAIL;
298                 }               
299         }
300          /*getting user info from session*/
301         $scope.getUserNameFromSession = function(){
302                 UserInfoService.getFunctionalMenuStaticDetailSession()
303                 .then(function (res) {
304                                 $scope.userProfile.firstName = res.firstName;
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.getTopMenuStaticInfo();      
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>