Files
duplicati/Duplicati/Server/webroot/ngax/scripts/controllers/BackupLogController.js
T

78 lines
2.9 KiB
JavaScript
Raw Normal View History

backupApp.controller('BackupLogController', function($scope, $routeParams, AppUtils, LogService, BackupList, gettextCatalog) {
$scope.BackupID = $routeParams.backupid;
2018-12-22 17:21:26 +01:00
const PAGE_SIZE = 15;
$scope.$watch('Page', function() {
if ($scope.Page == 'remote' && $scope.RemoteData == null)
$scope.LoadMoreRemoteData();
});
2018-11-22 11:31:13 -02:00
$scope.parseTimestampToSeconds = function(ts) {
return moment(ts).format('YYYY-MM-DD HH:mm:ss');
}
$scope.gettextCatalog = gettextCatalog;
2018-11-22 11:31:13 -02:00
$scope.formatDuration = AppUtils.formatDuration;
$scope.formatSize = AppUtils.formatSizeString;
2018-11-14 09:24:08 -02:00
2018-12-22 17:21:26 +01:00
$scope.Page = 'general';
$scope.LoadMoreGeneralData = function() {
2018-11-14 09:24:08 -02:00
LogService.LoadMoreData('/backup/' + $scope.BackupID + '/log', $scope.GeneralData, 'ID', PAGE_SIZE)
.then(function(result) {
if (!result)
return;
var current = result.current;
$scope.GeneralDataComplete = result.complete;
2018-11-14 09:24:08 -02:00
$scope.Backup = BackupList.lookup[$scope.BackupID];
for (var i in current) {
2018-12-22 17:21:26 +01:00
try {
2018-11-22 11:31:13 -02:00
current[i].Result = JSON.parse(current[i].Message);
current[i].Formatted = JSON.stringify(current[i].Result, null, 2);
}
catch (err) {
// catch block meant to be empty (avoiding eslint warning)
// it is empty because if a result fails to be parsed, it was
// probably stored in the old format and thus should be displayed
// with a single gray code box.
}
2018-11-19 10:26:33 -02:00
}
$scope.GeneralData = current;
$scope.$digest();
2018-12-22 17:21:26 +01:00
});
2018-11-14 09:24:08 -02:00
};
2018-12-22 17:21:26 +01:00
$scope.LoadMoreRemoteData = function() {
2018-11-14 09:24:08 -02:00
LogService.LoadMoreData('/backup/' + $scope.BackupID + '/remotelog', $scope.RemoteData, 'ID', PAGE_SIZE)
.then(function(result) {
if (!result)
return;
2018-12-22 17:21:26 +01:00
$scope.RemoteData = result.current;
$scope.RemoteDataComplete = result.complete;
2018-11-14 09:24:08 -02:00
$scope.Backup = BackupList.lookup[$scope.BackupID];
$scope.$digest();
2018-12-22 17:21:26 +01:00
});
2018-11-14 09:24:08 -02:00
};
$scope.ResultIcon = function (parsedResult) {
if (parsedResult == 'Success') {
return 'fa fa-check-circle success-color';
} else if (parsedResult == 'Warning') {
return 'fa fa-exclamation-circle warning-color';
} else if (parsedResult == 'Error') {
return 'fa fa-times-circle error-color';
} else if (parsedResult == 'Fatal') {
return 'fa fa-exclamation-triangle fatal-color';
} else {
return 'fa fa-question-circle';
}
};
2018-12-22 17:21:26 +01:00
2018-11-14 09:24:08 -02:00
$scope.LoadMoreGeneralData();
$scope.Backup = BackupList.lookup[$scope.BackupID];
});