[PORTAL-16 PORTAL-18] Widget ms; staging
[portal.git] / ecomp-portal-FE-common / client / app / directives / left-menu / left-menu.directive.js
1 /*-
2  * ================================================================================
3  * ECOMP Portal
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 /**
21  * Created by nnaffar on 1/28/16.
22  */
23 (function () {
24     class LeftMenu {
25         constructor($rootScope, userbarUpdateService,notificationService,auditLogService) {
26             this.templateUrl = 'app/directives/left-menu/left-menu.tpl.html';
27             this.restrict = 'AE';
28             this.$rootScope = $rootScope;
29             this.userbarUpdateService = userbarUpdateService;
30             this.notificationService = notificationService;
31             this.auditLogService= auditLogService;
32             this.link = this._link.bind(this);
33             this.scope = {
34                 sidebarModel: '='
35             }
36         }
37         _link(scope) {
38             let init = () => {
39                 scope.isOpen = true;
40             };
41
42             init();
43
44             scope.refreshOnlineUsers = () => {
45                 this.userbarUpdateService.setRefreshCount(this.userbarUpdateService.maxCount);
46             };
47             
48             scope.refreshNotification = () => {
49                 this.notificationService.setRefreshCount(this.notificationService.maxCount);
50             };
51
52             scope.toggleSidebar = () => {
53                 scope.isOpen = !scope.isOpen;
54                 if(scope.isOpen==true)
55                         setContentPos(1);
56                 else
57                         setContentPos(0);
58             };
59             scope.auditLog =(name) => {         
60                         this.auditLogService.storeAudit(1,'leftMenu',name);
61                 };
62
63
64             scope.isBrowserInternetExplorer = false;
65             scope.browserName = bowser.name;
66
67             if (bowser.msie || bowser.msedge) {
68                 scope.isBrowserInternetExplorer = true;
69             } else {
70                 scope.isBrowserInternetExplorer = false;
71             }
72
73
74             this.$rootScope.$on('$stateChangeStart', () => {
75                 scope.isOpen = true;
76             });
77         }
78     }
79     angular.module('ecompApp').directive('leftMenu', ($rootScope,userbarUpdateService,notificationService,auditLogService) => new LeftMenu($rootScope,userbarUpdateService,notificationService,auditLogService));
80 })();
81
82 function setContentPos(open) {
83         // console.log("*******************************************");
84         if(open==1){
85                 $("#page-content" ).css( "padding-left", "210px" );
86         }else{
87                 $("#page-content" ).css( "padding-left", "50px" );
88         }
89
90 }