From 5307a187d57af8dd6c531704ff685791a3689f4e Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Mon, 13 Dec 2021 20:39:23 +0100 Subject: [PATCH] Add a way to stop the mail location change task after 2 minutes --- src/views/emails.html | 7 +++++-- src/views/emails.js | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/views/emails.html b/src/views/emails.html index 63bf56901..7b0fb37e6 100644 --- a/src/views/emails.html +++ b/src/views/emails.html @@ -344,8 +344,11 @@
{{ 'emails.settings.changeDomainProgress' | tr }} -
-
+
+
+
+
+

{{ mailLocation.message }}

diff --git a/src/views/emails.js b/src/views/emails.js index 9d44ed505..ee6ba630f 100644 --- a/src/views/emails.js +++ b/src/views/emails.js @@ -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); });