duplicati/Duplicati/Server/webroot/ngax/scripts/controllers/BackupLogController.js
Jan 71eb03130a Improve result reporting for interrupted/failed backups (Fix #4829)
Direct import of PR#4978
Update web UI for new result reports.
For operations with fatal errors, write logs to same operation ID.
Test that Interrupted flag is correct in RunScriptTests.
Update backup log display for new result reporting.
Hide file statistics for fatal errors and change fatal icon.
2023-09-21 20:01:17 +02:00

77 lines
2.9 KiB
JavaScript

backupApp.controller('BackupLogController', function($scope, $routeParams, AppUtils, LogService, BackupList, gettextCatalog) {
$scope.BackupID = $routeParams.backupid;
const PAGE_SIZE = 15;
$scope.$watch('Page', function() {
if ($scope.Page == 'remote' && $scope.RemoteData == null)
$scope.LoadMoreRemoteData();
});
$scope.parseTimestampToSeconds = function(ts) {
return moment(ts).format('YYYY-MM-DD HH:mm:ss');
}
$scope.gettextCatalog = gettextCatalog;
$scope.formatDuration = AppUtils.formatDuration;
$scope.formatSize = AppUtils.formatSizeString;
$scope.Page = 'general';
$scope.LoadMoreGeneralData = function() {
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;
$scope.Backup = BackupList.lookup[$scope.BackupID];
for (var i in current) {
try {
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.
}
}
$scope.GeneralData = current;
$scope.$digest();
});
};
$scope.LoadMoreRemoteData = function() {
LogService.LoadMoreData('/backup/' + $scope.BackupID + '/remotelog', $scope.RemoteData, 'ID', PAGE_SIZE)
.then(function(result) {
if (!result)
return;
$scope.RemoteData = result.current;
$scope.RemoteDataComplete = result.complete;
$scope.Backup = BackupList.lookup[$scope.BackupID];
$scope.$digest();
});
};
$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';
}
};
$scope.LoadMoreGeneralData();
$scope.Backup = BackupList.lookup[$scope.BackupID];
});