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