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