Add user listing to mail view to manage per user mailboxes
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user