-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathindexer-statuses-controller.js
51 lines (40 loc) · 1.27 KB
/
indexer-statuses-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
angular
.module('nzbhydraApp')
.controller('IndexerStatusesController', IndexerStatusesController);
function IndexerStatusesController($scope, $http, statuses) {
$scope.statuses = statuses.data;
$scope.isInPast = function (epochSeconds) {
return epochSeconds < (new Date).getTime();
};
$scope.enable = function (indexerName) {
$http.get("internalapi/enableindexer", {params: {name: indexerName}}).then(function (response) {
$scope.statuses = response.data.indexerStatuses;
});
}
}
angular
.module('nzbhydraApp')
.filter('formatDate', formatDate);
function formatDate(dateFilter) {
return function (timestamp, hidePast) {
if (timestamp) {
if (timestamp * 1000 < (new Date).getTime() && hidePast) {
return ""; //
}
var t = timestamp * 1000;
t = dateFilter(t, 'yyyy-MM-dd HH:mm');
return t;
} else {
return "";
}
}
}
angular
.module('nzbhydraApp')
.filter('reformatDate', reformatDate);
function reformatDate() {
return function (date) {
//Date in database is saved as UTC without timezone information
return moment.unix(date).local().format("YYYY-MM-DD HH:mm");
}
}