diff --git a/CHANGES b/CHANGES index df1a75c0c..9bb66f9f8 100644 --- a/CHANGES +++ b/CHANGES @@ -2662,4 +2662,5 @@ * branding: make oidc login does not use cloudron name * translation: fix crash when translated text has single quote (french) * dyndns: show logs +* mail: server location get it's own section diff --git a/dashboard/src/translation/en.json b/dashboard/src/translation/en.json index 55dc47ccc..a30cb157c 100644 --- a/dashboard/src/translation/en.json +++ b/dashboard/src/translation/en.json @@ -56,7 +56,8 @@ }, "action": { "reboot": "Reboot", - "logs": "Logs" + "logs": "Logs", + "showLogs": "Show Logs" }, "clipboard": { "copied": "Copied to clipboard", diff --git a/dashboard/src/translation/nl.json b/dashboard/src/translation/nl.json index a8bd1affc..cd8efd6a6 100644 --- a/dashboard/src/translation/nl.json +++ b/dashboard/src/translation/nl.json @@ -1211,7 +1211,8 @@ }, "dyndns": { "title": "Dynamische DNS", - "description": "Schakel deze optie in om je DNS records synchroon te houden met je veranderende IP adres. Dit is handig als je Cloudron opgenomen is in een netwerk waarbij het publieke IP adres steeds wisselt zoals in een thuissituatie." + "description": "Schakel deze optie in om je DNS records synchroon te houden met je veranderende IP adres. Dit is handig als je Cloudron opgenomen is in een netwerk waarbij het publieke IP adres steeds wisselt zoals in een thuissituatie.", + "showLogsAction": "Toon logbestanden" }, "configureIp": { "title": "Configureer IP aanbieder", diff --git a/dashboard/src/views/emails.html b/dashboard/src/views/emails.html index 36aeba123..1dca3e067 100644 --- a/dashboard/src/views/emails.html +++ b/dashboard/src/views/emails.html @@ -1,50 +1,3 @@ - - - +

{{ 'emails.mailboxSharing.title' | tr }}

@@ -289,22 +244,82 @@ + +
+

+ {{ 'emails.settings.location' | tr }} + +

+
+ +
+
+
+

+
+
+
+ + +
+ + +
+
+
+
+ +
+
+
+
+
+
+
+ +

+ +
+
+

{{ mailLocation.message }}

+

+

{{ mailLocation.errorMessage }}
+

+
+
+ + + +
+
+
+ +

{{ 'emails.settings.title' | tr }}

-
-
- {{ 'emails.settings.location' | tr }} -
-
- {{ mailLocation.currentLocation.subdomain + (!mailLocation.currentLocation.subdomain ? '' : '.') + mailLocation.currentLocation.domain.domain }} - - -
{{ 'emails.settings.maxMailSize' | tr }}
@@ -339,19 +354,6 @@
- -
-
- {{ 'emails.settings.changeDomainProgress' | tr }} -
-
-
-
-
-
-

{{ mailLocation.message }}

-
-
diff --git a/dashboard/src/views/emails.js b/dashboard/src/views/emails.js index 96f6a55d9..70aefdcea 100644 --- a/dashboard/src/views/emails.js +++ b/dashboard/src/views/emails.js @@ -24,25 +24,28 @@ angular.module('Application').controller('EmailsController', ['$scope', '$locati $scope.mailLocation = { busy: false, - error: null, + percent: 0, + message: '', + errorMessage: '', + currentLocation: { domain: null, subdomain: '' }, domain: null, subdomain: '', - taskId: null, - percent: 0, - taskMinutesActive: 0, - message: '', - errorMessage: '', - reconfigure: false, + tasks: [], - stopTask: function () { - Client.getLatestTaskByType(TASK_TYPES.TASK_CHANGE_MAIL_LOCATION, function (error, task) { + refreshTasks: function () { + Client.getTasksByType(TASK_TYPES.TASK_CHANGE_MAIL_LOCATION, function (error, tasks) { if (error) return console.error(error); - if (!task.id) return; + $scope.mailLocation.tasks = tasks.slice(0, 10); + if ($scope.mailLocation.tasks.length && $scope.mailLocation.tasks[0].active) $scope.mailLocation.updateStatus(); + }); + }, - Client.stopTask(task.id, function (error) { - if (error) console.error(error); - }); + stop: function () { + Client.stopTask($scope.mailLocation.tasks[0].id, function (error) { + if (error) console.error(error); + $scope.mailLocation.busy = false; + $scope.mailLocation.refreshTasks(); }); }, @@ -50,46 +53,27 @@ angular.module('Application').controller('EmailsController', ['$scope', '$locati Client.getMailLocation(function (error, location) { if (error) return console.error('Failed to get max email location', error); - $scope.mailLocation.currentLocation.subdomain = location.subdomain; - $scope.mailLocation.currentLocation.domain = $scope.domains.find(function (d) { return location.domain === d.domain; }); + $scope.mailLocation.currentLocation.subdomain = $scope.mailLocation.subdomain = location.subdomain; + $scope.mailLocation.currentLocation.domain = $scope.mailLocation.domain = $scope.domains.find(function (d) { return location.domain === d.domain; }); - Client.getLatestTaskByType(TASK_TYPES.TASK_CHANGE_MAIL_LOCATION, function (error, task) { - if (error) return console.error(error); - if (!task) return; - - $scope.mailLocation.taskId = task.id; - $scope.mailLocation.reconfigure = task.active; // if task is active when this view reloaded, reconfigure email apps when task done - $scope.mailLocation.updateStatus(); - }); + $scope.mailLocation.refreshTasks(); }); }, - show: function () { - $scope.mailLocation.busy = false; - $scope.mailLocation.error = null; - - $scope.mailLocation.domain = $scope.mailLocation.currentLocation.domain; - $scope.mailLocation.subdomain = $scope.mailLocation.currentLocation.subdomain; - - $scope.mailLocationForm.$setUntouched(); - $scope.mailLocationForm.$setPristine(); - - $('#mailLocationModal').modal('show'); - }, - updateStatus: function () { - Client.getTask($scope.mailLocation.taskId, function (error, data) { + var taskId = $scope.mailLocation.tasks[0].id; + + Client.getTask(taskId, function (error, data) { if (error) return window.setTimeout($scope.mailLocation.updateStatus, 5000); if (!data.active) { - $scope.mailLocation.taskId = null; $scope.mailLocation.busy = false; $scope.mailLocation.message = ''; - $scope.mailLocation.percent = 0; - $scope.taskMinutesActive = 0; + $scope.mailLocation.percent = 100; $scope.mailLocation.errorMessage = data.success ? '' : data.error.message; - if ($scope.mailLocation.reconfigure) $scope.reconfigureEmailApps(); + $scope.reconfigureEmailApps(); + $scope.mailLocation.refreshTasks(); // update the tasks list dropdown return; } @@ -97,32 +81,26 @@ 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); }); }, - submit: function () { + change: function () { $scope.mailLocation.busy = true; + $scope.mailLocation.percent = 0; + $scope.mailLocation.message = ''; + $scope.mailLocation.errorMessage = ''; Client.setMailLocation($scope.mailLocation.subdomain, $scope.mailLocation.domain.domain, function (error, result) { if (error) { + console.error(error); + $scope.mailLocation.errorMessage = error.message; $scope.mailLocation.busy = false; - $scope.mailLocation.error = error; - return; + } else { + $scope.mailLocation.refreshTasks(); } - // update UI immediately - $scope.mailLocation.currentLocation = { subdomain: $scope.mailLocation.subdomain, domain: $scope.mailLocation.domain }; - - $scope.mailLocation.taskId = result.taskId; - $scope.mailLocation.reconfigure = true; // reconfigure email apps when task done - $scope.mailLocation.updateStatus(); - Client.refreshConfig(); // update config.mailFqdn - - $('#mailLocationModal').modal('hide'); }); } };