-
-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathnotification-history-controller.js
91 lines (73 loc) · 2.51 KB
/
notification-history-controller.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
angular
.module('nzbhydraApp')
.controller('NotificationHistoryController', NotificationHistoryController);
function NotificationHistoryController($scope, StatsService, preloadData, ConfigService, $timeout, NotificationService) {
$scope.limit = 100;
$scope.pagination = {
current: 1
};
var sortModel = {
column: "time",
sortMode: 2
};
$timeout(function () {
$scope.$broadcast("newSortColumn", sortModel.column, sortModel.sortMode);
}, 10);
$scope.filterModel = {};
$scope.preselectedTimeInterval = {beforeDate: null, afterDate: null};
//Preloaded data
$scope.notifications = preloadData.notifications;
$scope.totalNotifications = preloadData.totalNotifications;
$scope.columnSizes = {
time: 10,
type: 15,
title: 15,
body: 40,
urls: 20
};
$scope.update = function () {
StatsService.getNotificationHistory($scope.pagination.current, $scope.limit, $scope.filterModel, sortModel).then(function (data) {
$scope.notifications = data.notifications;
$scope.totalNotifications = data.totalNotifications;
});
};
$scope.eventTypesForFiltering = [];
var eventTypes = NotificationService.getAllEventTypes();
_.each(eventTypes, function (key) {
$scope.eventTypesForFiltering.push({label: NotificationService.humanize(key), id: key})
})
$scope.$on("sort", function (event, column, sortMode) {
if (sortMode === 0) {
column = "time";
sortMode = 2;
}
sortModel = {
column: column,
sortMode: sortMode
};
$scope.$broadcast("newSortColumn", sortModel.column, sortModel.sortMode);
$scope.update();
});
$scope.$on("filter", function (event, column, filterModel, isActive) {
if (filterModel.filterValue) {
$scope.filterModel[column] = filterModel;
} else {
delete $scope.filterModel[column];
}
$scope.update();
})
$scope.formatEventType = function (notification) {
return NotificationService.humanize(notification.notificationEventType);
};
$scope.formatEventBody = function (notification) {
return notification.body.replace("\n", "<br>");
};
}
angular
.module('nzbhydraApp')
.filter('reformatDateEpoch', reformatDateEpoch);
function reformatDateEpoch() {
return function (date) {
return moment.unix(date).local().format("YYYY-MM-DD HH:mm");
}
}