Add a way to stop the mail location change task after 2 minutes

This commit is contained in:
Johannes Zellner
2021-12-13 20:39:23 +01:00
parent 84712ecc10
commit 5307a187d5
2 changed files with 19 additions and 2 deletions
+14
View File
@@ -30,10 +30,22 @@ angular.module('Application').controller('EmailsController', ['$scope', '$locati
subdomain: '',
taskId: null,
percent: 0,
taskMinutesActive: 0,
message: '',
errorMessage: '',
reconfigure: false,
stopTask: function () {
Client.getLatestTaskByType(TASK_TYPES.TASK_CHANGE_MAIL_LOCATION, function (error, task) {
if (error) return console.error(error);
if (!task.id) return;
Client.stopTask(task.id, function (error) {
if (error) console.error(error);
});
});
},
refresh: function () {
Client.getMailLocation(function (error, location) {
if (error) return console.error('Failed to get max email location', error);
@@ -74,6 +86,7 @@ angular.module('Application').controller('EmailsController', ['$scope', '$locati
$scope.mailLocation.busy = false;
$scope.mailLocation.message = '';
$scope.mailLocation.percent = 0;
$scope.taskMinutesActive = 0;
$scope.mailLocation.errorMessage = data.success ? '' : data.error.message;
if ($scope.mailLocation.reconfigure) $scope.reconfigureEmailApps();
@@ -84,6 +97,7 @@ angular.module('Application').controller('EmailsController', ['$scope', '$locati
$scope.mailLocation.busy = true;
$scope.mailLocation.percent = data.percent;
$scope.mailLocation.message = data.message;
$scope.mailLocation.taskMinutesActive = moment().diff(moment(data.creationTime), 'minutes');
window.setTimeout($scope.mailLocation.updateStatus, 1000);
});