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

76 lines
2.5 KiB
JavaScript
Raw Normal View History

2018-12-22 17:03:47 +01:00
backupApp.controller('LogController', function($scope, $timeout, AppService, LogService, SystemInfo, ServerStatus) {
$scope.state = ServerStatus.watch($scope);
$scope.SystemInfo = SystemInfo.watch($scope);
2015-11-28 21:52:00 +01:00
var liveRefreshTimer = null;
2018-11-14 09:24:08 -02:00
const PAGE_SIZE = 100;
2015-11-28 21:52:00 +01:00
function updateLivePoll() {
if ($scope.LiveRefreshing) {
$scope.LiveRefreshPending = true;
return;
}
if (liveRefreshTimer != null) {
$timeout.cancel(liveRefreshTimer);
liveRefreshTimer = null;
}
if ($scope.Page != 'live' || ($scope.LiveLogLevel || '') == '')
return;
$scope.LiveRefreshPending = false;
$scope.LiveRefreshing = true;
AppService.get('/logdata/poll?level=' + $scope.LiveLogLevel + '&id=' + $scope.LiveRefreshID + '&pagesize=' + PAGE_SIZE).then(
function(resp) {
2015-11-28 21:52:00 +01:00
for(var n in resp.data)
$scope.LiveRefreshID = Math.max($scope.LiveRefreshID, resp.data[n].ID);
if ($scope.LiveData == null)
$scope.LiveData = [];
2015-11-28 21:52:00 +01:00
resp.data.reverse();
2015-11-28 21:52:00 +01:00
$scope.LiveData.unshift.apply($scope.LiveData, resp.data);
$scope.LiveData.Length = Math.min(300, $scope.LiveData.length);
$scope.LiveData = $scope.LiveData.slice(0,$scope.LiveData.Length)
2015-11-28 21:52:00 +01:00
$scope.LiveRefreshing = false;
if ($scope.LiveRefreshPending)
updateLivePoll();
2015-11-28 21:52:00 +01:00
else
if ($scope.Page == 'live' && $scope.LiveLogLevel != '')
liveRefreshTimer = $timeout(updateLivePoll, 3000);
2015-11-28 21:52:00 +01:00
}, function(resp) {
if ($scope.Page == 'live' && $scope.LiveLogLevel != '')
liveRefreshTimer = $timeout(updateLivePoll, 3000);
}
);
2015-11-28 21:52:00 +01:00
};
$scope.$watch('LiveLogLevel', updateLivePoll);
$scope.$watch('Page', updateLivePoll);
2018-11-14 09:24:08 -02:00
$scope.Page = 'stored';
$scope.LiveLogLevel = '';
$scope.LiveRefreshID = 0;
$scope.LiveRefreshing = false;
$scope.LiveRefreshPending = false;
2018-12-22 17:03:47 +01:00
$scope.LoadMoreStoredData = function() {
2018-11-14 09:24:08 -02:00
LogService.LoadMoreData('/logdata/log', $scope.LogData, 'Timestamp', PAGE_SIZE)
.then(function(result) {
if (!result)
return;
2018-12-22 17:03:47 +01:00
$scope.LogData = result.current;
$scope.LogDataComplete = result.complete;
$scope.$digest();
2018-12-22 17:03:47 +01:00
});
2018-11-14 09:24:08 -02:00
};
$scope.LoadMoreStoredData();
2018-12-22 17:03:47 +01:00
2015-11-28 21:52:00 +01:00
});