blob: 2428da2e48889da83722c0b5104d9e780cc96875 (
plain)
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
|
backupApp.service('BackupList', function($rootScope, $timeout, AppService, AppUtils, ServerStatus) {
var list = [];
var lookup = {};
this.list = list;
this.lookup = lookup;
this.watch = function(scope, m) {
scope.$on('backuplistchanged', function() {
$timeout(function() {
if (m) m();
scope.$digest();
});
});
if (m) $timeout(m);
return list;
}
function updateNextRunStamp() {
var schedule = ServerStatus.state.proposedSchedule || [];
for(var n in list) {
if (list[n].Backup.Metadata == null)
list[n].Backup.Metadata = {};
delete list[n].Backup.Metadata["NextScheduledRun"];
}
for(var n in schedule)
if (lookup[schedule[n].Item1])
lookup[schedule[n].Item1].Backup.Metadata["NextScheduledRun"] = schedule[n].Item2;
$rootScope.$broadcast('backuplistchanged');
};
var reload = function() {
AppService.get('/backups').then(function(data) {
list.length = 0;
for (var prop in lookup)
if (lookup.hasOwnProperty(prop))
delete lookup[prop];
for (var i = 0; i < data.data.length; i++) {
list.push(data.data[i]);
lookup[data.data[i].Backup.ID] = data.data[i];
}
updateNextRunStamp();
});
};
$rootScope.$on('serverstatechanged.lastDataUpdateId', reload);
$rootScope.$on('serverstatechanged.proposedSchedule', updateNextRunStamp);
reload();
});
|