mailbox: select group as owner
This commit is contained in:
@@ -16,7 +16,7 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
||||
$scope.user = Client.getUserInfo();
|
||||
$scope.config = Client.getConfig();
|
||||
$scope.apps = Client.getInstalledApps();
|
||||
$scope.users = [];
|
||||
$scope.owners = []; // users + groups
|
||||
$scope.incomingDomains = [];
|
||||
$scope.domain = null;
|
||||
$scope.adminDomain = null;
|
||||
@@ -359,7 +359,7 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
||||
submit: function () {
|
||||
$scope.mailboxes.add.busy = true;
|
||||
|
||||
Client.addMailbox($scope.domain.domain, $scope.mailboxes.add.name, $scope.mailboxes.add.owner.id, function (error) {
|
||||
Client.addMailbox($scope.domain.domain, $scope.mailboxes.add.name, $scope.mailboxes.add.owner.id, $scope.mailboxes.add.owner.type, function (error) {
|
||||
if (error) {
|
||||
$scope.mailboxes.add.busy = false;
|
||||
$scope.mailboxes.add.error = error;
|
||||
@@ -408,7 +408,7 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
||||
$scope.mailboxes.edit.busy = true;
|
||||
|
||||
// $scope.mailboxes.edit.owner is expected to be validated by the UI
|
||||
Client.updateMailbox($scope.domain.domain, $scope.mailboxes.edit.name, $scope.mailboxes.edit.owner.id, function (error) {
|
||||
Client.updateMailbox($scope.domain.domain, $scope.mailboxes.edit.name, $scope.mailboxes.edit.owner.id, $scope.mailboxes.edit.owner.type, function (error) {
|
||||
if (error) {
|
||||
$scope.mailboxes.edit.error = error;
|
||||
$scope.mailboxes.edit.busy = false;
|
||||
@@ -478,7 +478,7 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
||||
if (error) return iteratorCallback(error);
|
||||
|
||||
m.aliases = aliases;
|
||||
m.owner = $scope.users.find(function (u) { return u.id === m.ownerId; }); // owner may not exist
|
||||
m.owner = $scope.owners.find(function (o) { return o.id === m.ownerId; }); // owner may not exist
|
||||
m.ownerDisplayName = m.owner ? m.owner.display : ''; // this meta property is set when we get the user list
|
||||
iteratorCallback();
|
||||
});
|
||||
@@ -763,31 +763,36 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
||||
if (error) return console.error('Unable to get user listing.', error);
|
||||
|
||||
// ensure we have a display value available
|
||||
$scope.users = users.map(function (u) {
|
||||
u.display = u.username || u.email;
|
||||
return u;
|
||||
users.forEach(function (u) {
|
||||
$scope.owners.push({ display: u.username || u.email, id: u.id, type: 'user' });
|
||||
});
|
||||
|
||||
$scope.users = users;
|
||||
Client.getGroups(function (error, groups) {
|
||||
if (error) return console.error('Unable to get group listing.', error);
|
||||
|
||||
Client.getDomains(function (error, result) {
|
||||
if (error) return console.error('Unable to get view domain.', error);
|
||||
groups.forEach(function (g) {
|
||||
$scope.owners.push({ display: g.name, id: g.id, type: 'group' });
|
||||
});
|
||||
|
||||
$scope.domain = result.filter(function (d) { return d.domain === domainName; })[0];
|
||||
$scope.adminDomain = result.filter(function (d) { return d.domain === $scope.config.adminDomain; })[0];
|
||||
$scope.refreshDomain();
|
||||
Client.getDomains(function (error, result) {
|
||||
if (error) return console.error('Unable to get view domain.', error);
|
||||
|
||||
async.eachSeries(result, function (domain, iteratorDone) {
|
||||
Client.getMailConfigForDomain(domain.domain, function (error, mailConfig) {
|
||||
if (error) return console.error('Failed to fetch mail config for domain', domain.domain, error);
|
||||
$scope.domain = result.filter(function (d) { return d.domain === domainName; })[0];
|
||||
$scope.adminDomain = result.filter(function (d) { return d.domain === $scope.config.adminDomain; })[0];
|
||||
$scope.refreshDomain();
|
||||
|
||||
if (mailConfig.enabled) $scope.incomingDomains.push(domain);
|
||||
iteratorDone();
|
||||
async.eachSeries(result, function (domain, iteratorDone) {
|
||||
Client.getMailConfigForDomain(domain.domain, function (error, mailConfig) {
|
||||
if (error) return console.error('Failed to fetch mail config for domain', domain.domain, error);
|
||||
|
||||
if (mailConfig.enabled) $scope.incomingDomains.push(domain);
|
||||
iteratorDone();
|
||||
});
|
||||
}, function iteratorDone(error) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
$scope.ready = true;
|
||||
});
|
||||
}, function iteratorDone(error) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
$scope.ready = true;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user