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