2018-12-12 11:50:28 -02:00
|
|
|
backupApp.controller('BackupLogController', function($scope, $routeParams, AppUtils, LogService, BackupList, gettextCatalog) {
|
2018-11-14 08:47:24 -02:00
|
|
|
$scope.BackupID = $routeParams.backupid;
|
2018-12-22 17:21:26 +01:00
|
|
|
|
|
|
|
|
const PAGE_SIZE = 15;
|
2018-11-14 08:47:24 -02:00
|
|
|
|
|
|
|
|
$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');
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-12 11:50:28 -02:00
|
|
|
$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;
|
|
|
|
|
|
2018-12-12 11:39:03 -02:00
|
|
|
var current = result.current;
|
|
|
|
|
$scope.GeneralDataComplete = result.complete;
|
2018-11-14 09:24:08 -02:00
|
|
|
$scope.Backup = BackupList.lookup[$scope.BackupID];
|
2018-12-12 11:39:03 -02:00
|
|
|
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);
|
|
|
|
|
}
|
2018-12-13 10:15:34 -02:00
|
|
|
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;
|
2018-11-14 10:02:13 -02:00
|
|
|
$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
|
|
|
|
2018-12-12 11:39:03 -02:00
|
|
|
$scope.RemoteData = result.current;
|
|
|
|
|
$scope.RemoteDataComplete = result.complete;
|
2018-11-14 09:24:08 -02:00
|
|
|
$scope.Backup = BackupList.lookup[$scope.BackupID];
|
2018-11-14 10:02:13 -02:00
|
|
|
$scope.$digest();
|
2018-12-22 17:21:26 +01:00
|
|
|
});
|
2018-11-14 09:24:08 -02:00
|
|
|
};
|
2018-11-27 10:48:10 -02:00
|
|
|
|
2023-09-21 19:58:27 +02:00
|
|
|
$scope.ResultIcon = function (parsedResult) {
|
2018-11-27 10:48:10 -02:00
|
|
|
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';
|
2023-09-21 19:58:27 +02:00
|
|
|
} else if (parsedResult == 'Fatal') {
|
|
|
|
|
return 'fa fa-exclamation-triangle fatal-color';
|
2018-11-27 10:48:10 -02:00
|
|
|
} else {
|
|
|
|
|
return 'fa fa-question-circle';
|
|
|
|
|
}
|
2023-09-21 19:58:27 +02:00
|
|
|
};
|
2018-12-22 17:21:26 +01:00
|
|
|
|
2018-11-14 09:24:08 -02:00
|
|
|
$scope.LoadMoreGeneralData();
|
|
|
|
|
$scope.Backup = BackupList.lookup[$scope.BackupID];
|
2018-11-14 08:47:24 -02:00
|
|
|
|
|
|
|
|
});
|