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