[PORTAL-7] Rebase
[portal.git] / ecomp-portal-FE-common / client / app / directives / left-menu / left-menu.directive.js
1 /*-\r
2  * ================================================================================\r
3  * ECOMP Portal\r
4  * ================================================================================\r
5  * Copyright (C) 2017 AT&T Intellectual Property\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * \r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ================================================================================\r
19  */\r
20 /**\r
21  * Created by nnaffar on 1/28/16.\r
22  */\r
23 (function () {\r
24     class LeftMenu {\r
25         constructor($rootScope, userbarUpdateService,notificationService,auditLogService) {\r
26             this.templateUrl = 'app/directives/left-menu/left-menu.tpl.html';\r
27             this.restrict = 'AE';\r
28             this.$rootScope = $rootScope;\r
29             this.userbarUpdateService = userbarUpdateService;\r
30             this.notificationService = notificationService;\r
31             this.auditLogService= auditLogService;\r
32             this.link = this._link.bind(this);\r
33             this.scope = {\r
34                 sidebarModel: '='\r
35             }\r
36         }\r
37         _link(scope) {\r
38             let init = () => {\r
39                 scope.isOpen = true;\r
40             };\r
41 \r
42             init();\r
43 \r
44             scope.refreshOnlineUsers = () => {\r
45                 this.userbarUpdateService.setRefreshCount(this.userbarUpdateService.maxCount);\r
46             };\r
47             \r
48             scope.refreshNotification = () => {\r
49                 this.notificationService.setRefreshCount(this.notificationService.maxCount);\r
50             };\r
51 \r
52             scope.toggleSidebar = () => {\r
53                 scope.isOpen = !scope.isOpen;\r
54                 if(scope.isOpen==true)\r
55                         setContentPos(1);\r
56                 else\r
57                         setContentPos(0);\r
58             };\r
59             scope.auditLog =(name) => {         \r
60                         this.auditLogService.storeAudit(1,'leftMenu',name);\r
61                 };\r
62 \r
63 \r
64             scope.isBrowserInternetExplorer = false;\r
65             scope.browserName = bowser.name;\r
66 \r
67             if (bowser.msie || bowser.msedge) {\r
68                 scope.isBrowserInternetExplorer = true;\r
69             } else {\r
70                 scope.isBrowserInternetExplorer = false;\r
71             }\r
72 \r
73 \r
74             this.$rootScope.$on('$stateChangeStart', () => {\r
75                 scope.isOpen = true;\r
76             });\r
77         }\r
78     }\r
79     angular.module('ecompApp').directive('leftMenu', ($rootScope,userbarUpdateService,notificationService,auditLogService) => new LeftMenu($rootScope,userbarUpdateService,notificationService,auditLogService));\r
80 })();\r
81 \r
82 function setContentPos(open) {\r
83         // console.log("*******************************************");\r
84         if(open==1){\r
85                 $("#page-content" ).css( "padding-left", "210px" );\r
86         }else{\r
87                 $("#page-content" ).css( "padding-left", "50px" );\r
88         }\r
89 \r
90 }\r