Add user table to manage mailboxes per domain

This does not yet handle the aliases
This commit is contained in:
Johannes Zellner
2018-03-30 18:33:58 +02:00
parent 9575a1158a
commit 1b7556443f
3 changed files with 22 additions and 21 deletions
+10 -7
View File
@@ -193,29 +193,32 @@
<div class="card" style="margin-bottom: 15px;" ng-show="selectedDomain.mailConfig.enabled">
<div class="row">
<div class="col-md-12">
Manage mailboxes for users on this domain. Each user will get an email address of <b>username@{{ selectedDomain.domain }}</b>
Enable mailboxes for users on this domain. Each user will get an email address of <b>username@{{ selectedDomain.domain }}</b>
<br/><br/>
<table class="table table-hover">
<thead>
<tr>
<th>&nbsp;</th>
<th>User</th>
<th class="text-left"></th>
<th class="text-left">Aliases (Separate by comma)</th>
<th class="text-right">Action</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="user in mailboxes.users">
<td>
<input type="checkbox" ng-model="user.mailboxEnabled" title="Mailbox Enabled">
</td>
<td class="text-left elide-table-cell">
{{ user.username }}
</td>
<td class="text-left elide-table-cell">
&nbsp;
<td>
<tag-input ng-show="user.mailboxEnabled" placeholder="add alias" taglist="user.aliases" name="aliases"></tag-input>
</td>
<td class="text-right no-wrap" style="vertical-align: bottom">
<button ng-show="user.mailboxEnabled" class="btn btn-xs btn-danger" ng-disabled="user.busy" ng-click="mailboxes.disable(user)" title="Disalbe Mailbox for this User"><i class="fa fa-circle-o-notch fa-spin" ng-show="user.busy"></i> Disable</button>
<button ng-hide="user.mailboxEnabled" class="btn btn-xs btn-primary" ng-disabled="user.busy" ng-click="mailboxes.enable(user)" title="Enable Mailbox for this User"><i class="fa fa-circle-o-notch fa-spin" ng-show="user.busy"></i> Enable</button>
<td class="text-right no-wrap">
<button ng-show="user.mailboxEnabled !== user.orig.mailboxEnabled || user.aliases !== user.orig.aliases" class="btn btn-xs btn-primary" ng-disabled="user.busy" ng-click="mailboxes.submit(user)"><i class="fa fa-circle-o-notch fa-spin" ng-show="user.busy"></i> Save</button>
</td>
</tr>
</tbody>
+12 -13
View File
@@ -88,25 +88,18 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
$scope.mailboxes = {
users: [],
enable: function (user) {
submit: function (user) {
user.busy = true;
Client.enableUserMailbox($scope.selectedDomain.domain, user.id, function (error) {
var func = user.mailboxEnabled ? Client.enableUserMailbox : Client.disableUserMailbox;
func($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);
// reset the dirty state
user.orig.mailboxEnabled = user.mailboxEnabled;
user.orig.aliases = user.aliases;
user.busy = false;
user.mailboxEnabled = error ? true : false;
});
}
};
@@ -314,6 +307,12 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
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);
u.aliases = 'well, hello, there';
u.orig = {};
u.orig.mailboxEnabled = u.mailboxEnabled;
u.orig.aliases = u.aliases;
return u;
});
});