diff --git a/dashboard/src/js/client.js b/dashboard/src/js/client.js index d1a4474d7..0be2c416e 100644 --- a/dashboard/src/js/client.js +++ b/dashboard/src/js/client.js @@ -1256,7 +1256,7 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N Client.prototype.getMailboxes = function (domain, callback) { get('/api/v1/mail/' + domain + '/mailboxes').success(function(data, status) { if (status !== 200) return callback(new ClientError(status, data)); - callback(null, data); + callback(null, data.mailboxes); }).error(defaultErrorHandler(callback)); }; diff --git a/dashboard/src/views/email.html b/dashboard/src/views/email.html index 36fb8a659..b9795fc25 100644 --- a/dashboard/src/views/email.html +++ b/dashboard/src/views/email.html @@ -186,6 +186,44 @@ +
+

Mailboxes

+
+ +
+
+
+ Manage mailboxes for users on this domain. Each user will get an email address of username@{{ selectedDomain.domain }} + +

+ + + + + + + + + + + + + + + + +
UserAction
+ {{ user.username }} + +   + + + +
+
+
+
+

Catch-all

diff --git a/dashboard/src/views/email.js b/dashboard/src/views/email.js index 948b36bcb..7c93132f1 100644 --- a/dashboard/src/views/email.js +++ b/dashboard/src/views/email.js @@ -85,6 +85,32 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio }); }; + $scope.mailboxes = { + users: [], + + enable: function (user) { + user.busy = true; + + Client.enableUserMailbox($scope.selectedDomain.domain, user.id, function (error) { + if (error) console.error(error); + + user.busy = false; + user.mailboxEnabled = error ? false : true; + }); + }, + + disable: function (user) { + user.busy = true; + + Client.disableUserMailbox($scope.selectedDomain.domain, user.id, function (error) { + if (error) console.error(error); + + user.busy = false; + user.mailboxEnabled = error ? true : false; + }); + } + }; + $scope.mailRelayPresets = [ { provider: 'cloudron-smtp', name: 'Built-in SMTP server' }, { provider: 'external-smtp', name: 'External SMTP server', host: '', port: 587 }, @@ -281,6 +307,17 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio $scope.selectedDomain.mailConfig = mailConfig; $scope.selectedDomain.mailStatus = {}; + // mailboxes + Client.getMailboxes($scope.selectedDomain.domain, function (error, mailboxes) { + if (error) return console.error(error); + + var enabledUsers = mailboxes.map(function (m) { return m.name; }); + $scope.mailboxes.users = $scope.users.filter(function (u) { return !!u.username; }).map(function (u) { + u.mailboxEnabled = (enabledUsers.indexOf(u.username) !== -1); + return u; + }); + }); + // we will fetch the status without blocking the ui Client.getMailStatusForDomain($scope.selectedDomain.domain, function (error, mailStatus) { $scope.refreshBusy = false;