yangui fixes
[dlux.git] / modules / common-topbar-resources / src / main / resources / topbar / topbar.js
1 angular.module('common.topbar', ['ngCookies', 'common.auth', 'common.navigation'])
2     .factory('taskFactory',function () {
3         var factory = {};
4         factory.getTaskData = function () {
5             return {
6                 count: 4,
7                 latest: [
8                     {
9                         title: "Software Update",
10                         percentage: 65
11                     },  
12                     {
13                         title: "Hardware Upgrade" ,
14                         percentage: 35 ,
15                         progressBarClass: "progress-bar-danger"
16                     },
17                     {
18                         title: "Unit Testing" ,
19                         percentage: 15  ,
20                         progressBarClass: "progress-bar-warning"
21                     },
22                     {
23                         title: "Bug Fixes" ,
24                         percentage: 90 ,
25                         progressClass: "progress-striped active",
26                         progressBarClass: "progress-bar-success"
27                     }
28                 ]
29             };
30
31         };
32         return factory;
33     }).factory('messageFactory', function () {
34         var factory = {};
35         factory.getMessageData = function () {
36             return {
37                 count: 5,
38                 latest: [
39                     {
40                         name: "Alex",
41                         img: "avatar.png",
42                         time: "a moment ago",
43                         summary: "Ciao sociis natoque penatibus et auctor ..."
44                     },
45                     {
46                         name: "Susan",
47                         img: "avatar3.png",
48                         time: "20 minutes ago",
49                         summary: "Vestibulum id ligula porta felis euismod ..."
50                     },
51                     {
52                         name: "Bob",
53                         img: "avatar4.png",
54                         time: "3:15 pm",
55                         summary: "Nullam quis risus eget urna mollis ornare ..."
56                     }
57                 ]
58             };
59         };
60         return factory;
61     })
62     .factory('notifsFactory', function () {
63         var factory = {};
64         factory.getNotifsData = function () {
65             return {
66                 "count": 8,
67                 "latest": [
68                     {
69                         title: "New Comments",
70                         icon: "icon-comment",
71                         iconClass: "btn-pink",
72                         badge: "+12",
73                         badgeClass: "badge-info"
74                     },
75                     {
76                         title: "Bob just signed up as an editor ...",
77                         icon: "icon-user",
78                         iconClass: "btn-primary"
79                     },
80                     {
81                         title: "New Orders",
82                         icon: "icon-shopping-cart",
83                         iconClass: "btn-success",
84                         badge: "+8",
85                         badgeClass: "badge-success"
86                     },
87                     {
88                         title: "Followers",
89                         icon: "icon-twitter",
90                         iconClass: "btn-info",
91                         badge: "+11",
92                         badgeClass: "badge-info"
93                     }
94                 ]
95             };
96
97         };
98         return factory;
99     })
100     .directive('mcTopBar', function () {
101         return {
102             replace: true,
103             templateUrl: 'topbar/topbar.tpl.html',
104         };
105     })
106     .directive('mcTopBarTasks', function () {
107         return {
108             replace: true,
109             controller: 'topBarTasksCtrl',
110             templateUrl: 'topbar/tasks.tpl.html'
111         };
112     })
113     .directive('mcTopBarNotifications', function () {
114         return {
115             replace: true,
116             controller: 'topBarNotifsCtrl',
117             templateUrl: 'topbar/notifications.tpl.html'
118         };
119     })
120     .directive('mcTopBarMessages', function () {
121         return {
122             replace: true,
123             controller: 'topBarMessagesCtrl',
124             templateUrl: 'topbar/messages.tpl.html'
125         };
126     })
127     .directive('mcTopBarUserMenu', function () {
128         return {
129             replace: true,
130             controller: 'topBarUserMenuCtrl',
131             templateUrl: 'topbar/user_menu.tpl.html'
132         };
133     })
134     .controller('topBarTasksCtrl',function ($scope, taskFactory) {
135         $scope.tasks = taskFactory.getTaskData();
136     }).controller('topBarNotifsCtrl',function ($scope, notifsFactory) {
137         $scope.notifs = notifsFactory.getNotifsData();
138         $scope.isValid = function (value) {
139             if (angular.isUndefined(value) || value === null) {
140                 return false;
141             }
142             else {
143                 return true;
144             }
145         };
146     }).controller('topBarMessagesCtrl',function ($scope, messageFactory) {
147         $scope.messages = messageFactory.getMessageData();
148         $scope.isValid = function (value) {
149             if (angular.isUndefined(value) || value === null) {
150                 return false;
151             }
152             else {
153                 return true;
154             }
155         };
156     }).controller('topBarUserMenuCtrl', function ($scope, $cookieStore, Auth, $window) {
157         $scope.logOut = function () {
158             Auth.logout(
159             function(res) {
160                 $window.location.href = 'login.html'; 
161             });
162
163         };
164     });