diff --git a/Duplicati/Server/webroot/ngax/index.html b/Duplicati/Server/webroot/ngax/index.html index 3cec151b6..85d9bf592 100644 --- a/Duplicati/Server/webroot/ngax/index.html +++ b/Duplicati/Server/webroot/ngax/index.html @@ -50,6 +50,7 @@ + diff --git a/Duplicati/Server/webroot/ngax/scripts/controllers/StateController.js b/Duplicati/Server/webroot/ngax/scripts/controllers/StateController.js index ed98e1777..26ee68ddd 100644 --- a/Duplicati/Server/webroot/ngax/scripts/controllers/StateController.js +++ b/Duplicati/Server/webroot/ngax/scripts/controllers/StateController.js @@ -1,4 +1,4 @@ -backupApp.controller('StateController', function($scope, ServerStatus, BackupList, AppService, AppUtils) { +backupApp.controller('StateController', function($scope, $timeout, ServerStatus, BackupList, AppService, AppUtils) { $scope.state = ServerStatus.watch($scope); $scope.backups = BackupList.watch($scope); @@ -10,6 +10,7 @@ backupApp.controller('StateController', function($scope, ServerStatus, BackupLis $scope.$on('backuplistchanged', updateActiveTask); $scope.$on('serverstatechanged', updateActiveTask); + $scope.$on('serverstatechanged.pauseTimeRemain', function() { $timeout(function() {$scope.$digest(); }) }); $scope.sendResume = function() { ServerStatus.resume().then(function() {}, AppUtils.connectionError); diff --git a/Duplicati/Server/webroot/ngax/scripts/services/ServerStatus.js b/Duplicati/Server/webroot/ngax/scripts/services/ServerStatus.js index 3bd70198f..80b5ecab1 100644 --- a/Duplicati/Server/webroot/ngax/scripts/services/ServerStatus.js +++ b/Duplicati/Server/webroot/ngax/scripts/services/ServerStatus.js @@ -1,4 +1,4 @@ -backupApp.service('ServerStatus', function($http, $rootScope, $timeout, AppService) { +backupApp.service('ServerStatus', function($http, $rootScope, $timeout, AppService, AppUtils) { var polltime = 5 * 60 * 1000; @@ -60,6 +60,24 @@ backupApp.service('ServerStatus', function($http, $rootScope, $timeout, AppServi }, 500); }; + var updatepausetimer = null; + function pauseTimerUpdater(skipNotify) { + var prev = state.pauseTimeRemain; + + state.pauseTimeRemain = Math.max(0, AppUtils.parseDate(state.estimatedPauseEnd) - new Date()); + if (state.pauseTimeRemain > 0 && updatepausetimer == null) { + updatepausetimer = setInterval(pauseTimerUpdater, 500); + } else if (state.pauseTimeRemain <= 0 && updatepausetimer != null) { + clearInterval(updatepausetimer); + updatepausetimer = null; + } + + if (prev != state.pauseTimeRemain && !skipNotify) + $rootScope.$broadcast('serverstatechanged.pauseTimeRemain', state.pauseTimeRemain); + + return prev != state.pauseTimeRemain; + } + var notifyIfChanged = function (data, dataname, varname) { if (data[dataname] != null) { if (state[varname] != data[dataname]) { @@ -91,7 +109,8 @@ backupApp.service('ServerStatus', function($http, $rootScope, $timeout, AppServi notifyIfChanged(response.data, 'LastDataUpdateID', 'lastDataUpdateId') | notifyIfChanged(response.data, 'LastNotificationUpdateID', 'lastNotificationUpdateId') | notifyIfChanged(response.data, 'ActiveTask', 'activeTask') | - notifyIfChanged(response.data, 'ProgramState', 'programState'); + notifyIfChanged(response.data, 'ProgramState', 'programState') | + notifyIfChanged(response.data, 'EstimatedPauseEnd', 'estimatedPauseEnd'); if (state.connectionState != 'connected') { @@ -100,9 +119,12 @@ backupApp.service('ServerStatus', function($http, $rootScope, $timeout, AppServi anychanged = true; } + anychanged |= pauseTimerUpdater(true); + if (anychanged) $rootScope.$broadcast('serverstatechanged'); + poll(); }, @@ -115,9 +137,8 @@ backupApp.service('ServerStatus', function($http, $rootScope, $timeout, AppServi poll(); } else { - // TODO: First request should not long-poll .... - // Real failure, start countdown + state.lastEventId = -1; state.connectionState = 'disconnected'; countdownForForRePoll(poll); diff --git a/Duplicati/Server/webroot/ngax/templates/home.html b/Duplicati/Server/webroot/ngax/templates/home.html index 8a054faca..370ca977c 100644 --- a/Duplicati/Server/webroot/ngax/templates/home.html +++ b/Duplicati/Server/webroot/ngax/templates/home.html @@ -1,8 +1,9 @@
Scheduled backups: