Add user listing to mail view to manage per user mailboxes

This commit is contained in:
Johannes Zellner
2018-03-30 18:06:40 +02:00
parent 8ebcc2f8af
commit 9575a1158a
3 changed files with 76 additions and 1 deletions

View File

@@ -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;