forked from openshift/origin-web-console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheventsBadge.js
33 lines (29 loc) · 1.03 KB
/
eventsBadge.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
angular.module('openshiftConsole')
.directive('eventsBadge', function($filter, DataService, Logger) {
return {
restrict: 'E',
scope: {
projectContext: "=",
sidebarCollapsed: "="
},
templateUrl: 'views/directives/events-badge.html',
controller: function($scope) {
var watches = [];
var sort = $filter('orderObjectsByDate');
watches.push(DataService.watch("events", $scope.projectContext, function(eventData) {
var events = eventData.by('metadata.name');
$scope.events = sort(events, true);
$scope.warningCount = _.size(_.filter(events, { type: 'Warning' }));
$scope.normalCount = _.size(_.filter(events, { type: 'Normal' }));
Logger.log("events (subscribe)", $scope.events);
}));
$scope.expandSidebar = function() {
$scope.sidebarCollapsed = false;
};
$scope.$on('$destroy', function() {
DataService.unwatchAll(watches);
});
},
};
});