44fe53a88276b352b1b51df7fd0b4fb7c3944c4a
[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>
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         /*Put user info into fields*/
317         $scope.inputUserInfo = function(userInfo){
318                 if (typeof(userInfo) != "undefined" && userInfo!=null && userInfo!=''){
319                         if (typeof(userInfo.USER_FIRST_NAME) != "undefined" && userInfo.USER_FIRST_NAME!=null && userInfo.USER_FIRST_NAME!='')
320                                 $scope.userProfile.firstName = userInfo.USER_FIRST_NAME;
321                         if (typeof(userInfo.USER_LAST_NAME) != "undefined" && userInfo.USER_LAST_NAME!=null && userInfo.USER_LAST_NAME!='')
322                                 $scope.userProfile.lastName = userInfo.USER_LAST_NAME;
323                         if (typeof(userInfo.USER_EMAIL) != "undefined" && userInfo.USER_EMAIL!=null && userInfo.USER_EMAIL!='')                         
324                                 $scope.userProfile.email = userInfo.USER_EMAIL;
325                 }               
326         }
327          /*getting user info from session*/
328         $scope.getUserNameFromSession = function(){
329                 UserInfoService.getFunctionalMenuStaticDetailSession()
330                 .then(function (res) {
331                                 $scope.userProfile.firstName = res.firstName;
332                                 $scope.redirectUrl = res.portalUrl;
333                 });
334         }
335         $scope.getTopMenuStaticInfo=function() {
336                 var promise = UserInfoService.getFunctionalMenuStaticDetailShareContext();
337                 promise.then(
338                                 function(res) {                                         
339                                         if(res==null || res==''){
340                                                 $log.info('failed getting static User information');    
341                                                 $scope.getUserNameFromSession();
342                                         }else{
343                                                 $log.info('Received static User information');
344                                                 var resData = res;                                              
345                                                 $scope.inputUserInfo(resData);                                  
346                                                 $scope.userProfile.fullName = $scope.userProfile.firstName+ ' '+ $scope.userProfile.lastName;                                   
347                                         }
348                                 },
349                                 function(err) {
350                                         $log.info('failed getting static User information');                                    
351                                 }
352                 );
353                 }
354                         
355                 var unflatten = function( array, parent, tree ){
356                         tree = typeof tree !== 'undefined' ? tree : [];
357                         parent = typeof parent !== 'undefined' ? parent : { menuId: null };
358                         var children = _.filter( array, function(child){ return child.parentMenuId == parent.menuId; });
359                 
360                         if( !_.isEmpty( children )  ){
361                                 if( parent.menuId === null ){
362                                                 tree = children;
363                                 }else{
364                                         parent['children'] = children
365                                 }
366                                 _.each( children, function( child ){ unflatten( array, child ) } );
367                         }
368
369                         return tree;
370                 }
371                 
372                 var menuStructureConvert = function(menuItems) {
373                         var megaMenuDataObjectTemp = [
374                                          {
375                                                  text: "ECOMP",
376                                                  children:menuItems
377                                          },
378                                          {
379                                                  text: "Help",
380                                                  children: [{
381                                                          text:"Contact Us",
382                                                          url:"<c:out value='${contactUsLink}'/>"
383                                                  },
384                                                  {
385                                                          text:"Get Access",
386                                                          url:"<c:out value='${getAccessLink}'/>"
387                                                  }]
388                                          }
389                                          ];
390                         return megaMenuDataObjectTemp;
391                 }; 
392                 
393                 
394                 /*Left Menu*/
395                 LeftMenuService.getAppName().then(function(response){
396                         var j = response; 
397                         try{
398                                 if(j && j !== "null" && j!== "undefined"){
399                                         // console.log("app name is " + $scope.app_name);
400                                         $scope.app_name_full = j.data;
401                                         var processed_app_name = j.data;
402                                         var indexOfLic = processed_app_name.indexOf('[');
403                                         if(indexOfLic>-1) {
404                                                 if (jQuery('.license-notification')!=null)
405                                                         jQuery('.license-notification').css("display", "none"); 
406                                         }
407                                         var n = processed_app_name.length;
408                                         if (n > 15) {
409                                                 n = 15;
410                                         }
411                                         if(n > indexOfLic && indexOfLic > 0) {
412                                                 n = indexOfLic;
413                                         }
414                                         $scope.app_name_full = $scope.app_name_full.substr(0, n);
415                                         $scope.app_name = processed_app_name.substr(0, n);
416                                         
417                                 }else{
418                                         throw "Get app_name response is not an object/is empty"; 
419                                 }  
420                         }catch (e) {
421                                 console.log("error happened while trying to get app name "+e);
422                                 return;
423                 }              
424                 },function(error){
425                         console.log('getAppName failed', error);
426                 });
427
428                 
429             $scope.getTopMenuStaticInfo();      
430         $scope.getMenu=function() {
431                 
432                  $http({
433                         method: "GET",
434                         url: 'get_functional_menu',
435 // TIMEOUT USED FOR LOCAL TESTING ONLY                          
436 //                      timeout: 100
437                  }).success(function (response) {
438                         if(response == '101: Timeout') {
439                                 $log.error('Timeout attempting to get_functional_menu');
440                         // TIMEOUT USED FOR LOCAL TESTING ONLY                          
441 //                              $scope.createErrorMenu();
442                                 $scope.megaMenuDataObject = menuStructureConvert('');
443                         }else {
444                                 $log.debug('get_functional_menu success: ' + response);                                                         
445                                 if(typeof response != 'undefined' && response.length!=0 && typeof response[0] != 'undefined' && typeof response[0].error!="undefined"){
446 // createErrorMenu() USED FOR LOCAL TESTING ONLY
447 //                                      $scope.createErrorMenu();
448                                         $scope.megaMenuDataObject = menuStructureConvert('');
449                                 //      $scope.loadMenufail=true;
450                                 }else{
451                                         $scope.jsonMenuData = unflatten( response );
452                                         $scope.megaMenuDataObject = menuStructureConvert($scope.jsonMenuData);
453                                 }
454                         }
455                 }).error(function (response){
456 // createErrorMenu() USED FOR LOCAL TESTING ONLY                                
457 //                              $scope.createErrorMenu();
458
459                                 //$scope.loadMenufail=true;
460                                 $scope.megaMenuDataObject = menuStructureConvert('');
461                         $log.debug('REST API failed get_functional_menu...'+ response);
462                   });
463                 }
464         $scope.adjustHLeftMenu = function (type){
465                 $scope.showHeader = ($cookies.show_app_header == undefined ? true : $cookies.show_app_header);
466                 
467                 if($scope.showHeader == true) {
468                         $scope.drawer_margin_top = 60;
469                         $scope.drawer_custom_top = 5;
470                         $scope.toggle_drawer_top = 5;
471                 }
472                 else  {
473                         
474                         $scope.drawer_margin_top = 50;
475                         $scope.drawer_custom_top = 5;
476                         $scope.toggle_drawer_top = 5;
477                 }
478                 if(type=='burgerIcon'){
479                         return { "top": $scope.toggle_drawer_top+"px"};
480                 }else if(type=='leftMenu'){
481                         return { "margin-top": $scope.drawer_margin_top+"px"};
482                 }else
483                         return;
484         }
485         $scope.adjustHeader=function() {
486                 $scope.showHeader = ($cookies.show_app_header == undefined ? true : $cookies.show_app_header);
487                 
488                 if($scope.showHeader == true) {
489                         $scope.drawer_margin_top = 50;
490                         $scope.drawer_custom_top = 5;
491                         $scope.toggle_drawer_top = 5;
492                 }
493                 else  {
494                         
495                         $scope.drawer_margin_top = 40;
496                         $scope.drawer_custom_top = 5;
497                         $scope.toggle_drawer_top = 5;
498                 }
499                 
500                 
501         }
502         
503         
504                 //$scope.getMenu();
505                 $scope.adjustHeader();
506                 
507
508                 /* **************************************************************************/
509                 /* Logic for the favorite menus is here */
510
511             $scope.loadFavorites = function () {
512                 $log.debug('loadFavorites has happened.');
513                 if ($scope.favoritesMenuItems == '') {
514                     $scope.generateFavoriteItems();
515                     $log.debug('loadFavorites is calling generateFavoriteItems()');
516                 } else {
517                     $log.debug('loadFavorites is NOT calling generateFavoriteItems()');
518                 }
519             }
520             
521             $scope.goToUrl = function (item) {
522                 $log.info("goToUrl called")
523                 $log.info(item);
524
525                 var url = item.url;
526                 var restrictedApp = item.restrictedApp;
527                 $log.debug('Restricted app status is: ' + restrictedApp);
528                 if (!url) {
529                     $log.info('No url found for this application, doing nothing..');
530                     return;
531                 }
532                 if (restrictedApp) {
533                     $window.open(url, '_blank');
534                 } else {
535                     $window.open(url, '_self');
536                 }
537
538             }
539             
540             $scope.submenuLevelAction = function(index, column) {
541                 if ($scope.favoritesMenuItems == '') {
542                     $scope.generateFavoriteItems();
543                     $log.debug('submenuLevelAction is calling generateFavoriteItems()');
544                 }
545                 $log.debug('item hovered/clicked: ' + index + '; column = ' + column);
546                 if (column == 2) {  // 2 is Design
547                     $scope.favoritesWindow = false;
548                     $scope.showFavorites = false;
549                     $scope.emptyFavorites = false;
550                 }
551                 if (index=='Favorites' && $scope.favoriteItemsCount != 0) {
552                     $log.debug('Showing Favorites window');
553                     $scope.favoritesWindow = true;
554                     $scope.showFavorites = true;
555                     $scope.emptyFavorites = false;
556                 }
557                 if (index=='Favorites' && $scope.favoriteItemsCount == 0) {
558                     $log.debug('Hiding Favorites window in favor of No Favorites Window');
559                     $scope.favoritesWindow = true;
560                     $scope.showFavorites = false;
561                     $scope.emptyFavorites = true;
562                 }
563                 if (column > 2) {
564                     $scope.favoritesWindow = false;
565                     $scope.showFavorites = false;
566                     $scope.emptyFavorites = false;
567                 }
568             };
569             
570             $scope.hideFavoritesWindow = function() {
571                 $log.debug('$scope.hideFavoritesWindow has been called');
572                 $scope.showFavorites = false;
573                 $scope.emptyFavorites = false;
574             }
575             
576             $scope.isUrlFavorite = function (menuId) {
577 //                 $log.debug('array objects in menu favorites = ' + $scope.favoriteItemsCount + '; menuId=' + menuId);
578                 var jsonMenu =  JSON.stringify($scope.favoritesMenuItems);
579                 var isMenuFavorite =  jsonMenu.indexOf('menuId\":' + menuId);
580                 if (isMenuFavorite==-1) {
581                     return false;
582                 } else {
583                     return true;
584                 }
585
586             }
587                             
588             $scope.generateFavoriteItems  = function() {
589                 $http({
590                         method: "GET",
591                         url: 'get_favorites',
592                 // TIMEOUT USED FOR LOCAL TESTING ONLY                          
593 //                                              timeout: 100
594                             }).success(function (response) {
595                                                 if (response == '101: Timeout') {
596                                                 $log.error('Timeout attempting to get_favorites_menu');
597                                         } else {
598                                                 if(typeof response != 'undefined' && response.length!=0 && typeof response[0] != 'undefined' && typeof response[0].error!="undefined"){
599                                                     $log.error('REST API failed get_favorites' + response);
600                                                         }else{
601                                                                 $log.debug('get_favorites = ' + JSON.stringify(response));
602                                                                 $scope.favoritesMenuItems = response;
603                                         $scope.favoriteItemsCount = Object.keys($scope.favoritesMenuItems).length;
604                                         $log.info('number of favorite menus: ' + $scope.favoriteItemsCount);
605                                 }
606                                                 }
607                                         }).error(function (response){
608                                             $log.error('REST API failed get_favorites' + response);
609                 //createFavoriteErrorMenu() USED FOR LOCAL TESTING ONLY                         
610 //                                                      $scope.createFavoriteErrorMenu();
611                                         });
612                 }
613                             
614                                 $scope.createFavoriteErrorMenu=function() {
615                                 $scope.favoritesMenuItems = [
616 //                                                           {
617 //                                                                  "menuId": "93",
618 //                                                                  "text": "JSONLint",
619 //                                                                  "url": "http://http://jsonlint.com"
620 //                                                                },
621 //                                                                {
622 //                                                                  "menuId": "22",
623 //                                                                  "text": "ECOMP Wasteland",
624 //                                                                  "url": "https://ecomp.homer.att.com/ecompportal/applicationsHome"
625 //                                                                },
626 //                                                                {
627 //                                                                  "menuId": "94",
628 //                                                                  "text": "HROneStop",
629 //                                                                  "url": "http://ebiz.sbc.com/hronestop"
630 //                                                                },
631 //                                                                {
632 //                                                                  "menuId": "91",
633 //                                                                  "text": "Andy and his Astrophotgraphy",
634 //                                                                  "url": "https://ecomp.homer.att.com/ecompportal/applicationsHome"
635 //                                                                }
636                                                                 ];
637                                 $scope.favoriteItemsCount = Object.keys($scope.favoritesMenuItems).length;
638                                 $log.info('number of favorite menus: ' + $scope.favoriteItemsCount);
639                                 }
640                             
641                 /* end of Favorite Menu code */
642                 /* **************************************************************************/
643
644                 
645                 /* **************************************************************************/
646                 // THIS IS USED FOR LOCAL TESTING ONLY
647                 /* **************************************************************************/
648
649                         $scope.createErrorMenu=function() {
650                 $scope.jsonMenuData = [
651                                    {
652                                     "menuId": 1,
653                                     "column": 2,
654                                     "text": "Design",
655                                     "parentMenuId": null,
656                                     "url": ""
657                                   },
658                                   {
659                                     "menuId": 2,
660                                     "column": 3,
661                                     "text": "Infrastructure Ordering",
662                                     "parentMenuId": null,
663                                     "url": ""
664                                   },
665                                   {
666                                     "menuId": 3,
667                                     "column": 4,
668                                     "text": "Service Creation",
669                                     "parentMenuId": null,
670                                     "url": ""
671                                   },
672                                   {
673                                     "menuId": 4,
674                                     "column": 5,
675                                     "text": "Service Mgmt",
676                                     "parentMenuId": null,
677                                     "url": ""
678                                   },
679                                   {
680                                     "menuId": 90,
681                                     "column": 1,
682                                     "text": "Google",
683                                     "parentMenuId": 1,
684                                     "url": "http://google.com"
685                                   },
686                                   {
687                                     "menuId": 91,
688                                     "column": 1,
689                                     "text": "Mike Little's Coffee Cup",
690                                     "parentMenuId": 2,
691                                     "url": "http://coffee.com"
692                                   },
693                                   {
694                                     "menuId": 92,
695                                     "column": 2,
696                                     "text": "Andy and his Astrophotgraphy",
697                                     "parentMenuId": 3,
698                                     "url": "http://nightskypix.com"
699                                   },
700                                   {
701                                     "menuId": 93,
702                                     "column": 1,
703                                     "text": "JSONLint",
704                                     "parentMenuId": 4,
705                                     "url": "http://http://jsonlint.com"
706                                   },
707                                   {
708                                     "menuId": 94,
709                                     "column": 2,
710                                     "text": "HROneStop",
711                                     "parentMenuId": 4,
712                                     "url": "http://ebiz.sbc.com/hronestop"
713                                   },
714                                   {
715                                     "menuId": 95,
716                                     "column": 2,
717                                     "text": "4th Level App4a R16",
718                                     "parentMenuId": 4,
719                                     "url": "http://www.e-access.att.com/ecomp_portal_ist/ecompportal/widgets"
720                                   },
721                                   {
722                                     "menuId": 96,
723                                     "column": 3,
724                                     "text": "3rd Level App1c R200",
725                                     "parentMenuId": 4,
726                                     "url": "http://app1c.com"
727                                   },
728                                   {
729                                     "menuId": 97,
730                                     "column": 1,
731                                     "text": "3rd Level App4b R16",
732                                     "parentMenuId": 5,
733                                     "url": "http://app4b.com"
734                                   },
735                                   {
736                                     "menuId": 98,
737                                     "column": 2,
738                                     "text": "3rd Level App2b R16",
739                                     "parentMenuId": 5,
740                                     "url": "http://app2b.com"
741                                   },
742                                   {
743                                     "menuId": 99,
744                                     "column": 1,
745                                     "text": "Favorites",
746                                     "parentMenuId": null,
747                                     "url": ""
748                                   }
749                                 ];
750                         $scope.jsonMenuData = unflatten( $scope.jsonMenuData );
751                         $scope.megaMenuDataObject = menuStructureConvert($scope.jsonMenuData);
752 //                      $log.debug(JSON.stringify($scope.jsonMenuData));
753         }
754                 var childItemList="";
755                 var parentList = "";
756                 try{
757                         childItemList = ${menu.childItemList};
758                         parentList = ${menu.parentList};
759                 }catch(err){
760                         console.log("ebz_header: failed to get child/parent lists", err);
761                 }
762                 
763                 var pageUrl = window.location.href.split('/')[window.location.href.split('/').length-1];
764                 
765                 $scope.menuItems = [];
766                 for (var i = 0; i < parentList.length; i++) {
767                         $scope.openCurrentMenu = false;
768                  if(pageUrl==parentList[i].action)
769                                 $scope.openCurrentMenu = true;
770                         $scope.childItemList = childItemList[i];
771                         for(chIndex in  $scope.childItemList){
772                                 if($scope.childItemList.length>0)
773                                         if($scope.childItemList[chIndex].action!=null){
774                                                 if($scope.childItemList[chIndex].action==pageUrl)
775                                                         $scope.openCurrentMenu = true;
776                                         }
777                         }
778                         $scope.item = {
779                                 parentLabel : parentList[i].label,
780                                 parentAction : parentList[i].action,
781                                 parentImageSrc : parentList[i].imageSrc,
782                                 open:$scope.openCurrentMenu,
783                                 childItemList : $scope.childItemList
784                         }
785                         $scope.menuItems.push($scope.item);
786                 }
787                 $scope.arrowShow = true;
788                 $scope.drawerOpen = false;
789                 $scope.subMenuContent = false;
790                 $scope.toggleSubMenu = function() {
791                         $scope.subMenuContent = !$scope.subMenuContent;
792                 };
793
794                 var drawerOpen = 'open';
795                 if (drawerOpen == 'open') {
796                         $scope.drawerOpen = true;
797                         $scope.arrowShow = true;
798                 } else {
799                         $scope.arrowShow = false;
800                 }
801                 $scope.arrowShow = true;
802                 $scope.drawerOpen = false;
803                 $scope.toggleDrawer = function() {
804                         $scope.drawerOpen = !($scope.drawerOpen);
805                         if ($scope.drawerOpen) {
806                                 $scope.arrowShow = true;                                
807                                 if (document.getElementById('mContent')!=null)
808                                         document.getElementById('mContent').style.marginLeft = "0px";                   
809                         } else {
810                                 $scope.arrowShow = false;
811                                 if (document.getElementById('mContent')!=null)
812                                         document.getElementById('mContent').style.marginLeft = "-150px";
813                         }
814                 };
815                 //var drawerOpen = getCookie('drawerOpen');
816                 if (drawerOpen == 'open') {
817                         $scope.drawerOpen = true;
818                         $scope.arrowShow = true;
819                 } else {
820                         $scope.arrowShow = false;
821                 }
822                 $timeout(function() {
823                         detectScrollEvent();
824                 }, 800);
825                 
826         });
827         
828         app.filter("ellipsis", function(){
829             return function(text, length){
830                 if (text) {
831                     var ellipsis = text.length > length ? "..." : "";
832                     return text.slice(0, length) + ellipsis;
833                 };
834                 return text;        
835             }
836         });
837 </script>