diff --git a/src/js/client.js b/src/js/client.js index b1d87cf99..4730d0c30 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -2459,6 +2459,23 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }); }; + Client.prototype.getMailboxSharing = function (callback) { + get('/api/v1/mailserver/mailbox_sharing', {}, function (error, data, status) { + if (error) return callback(error); + if (status !== 200) return callback(new ClientError(status, data)); + callback(null, data.enabled); + }); + }; + + Client.prototype.setMailboxSharing = function (enable, callback) { + post('/api/v1/mailserver/mailbox_sharing', { enable: enable }, null, function (error, data, status) { + if (error) return callback(error); + if (status !== 200) return callback(new ClientError(status, data)); + + callback(null); + }); + }; + Client.prototype.getDnsblConfig = function (callback) { var config = {}; diff --git a/src/views/emails.html b/src/views/emails.html index cb379c552..7740beed4 100644 --- a/src/views/emails.html +++ b/src/views/emails.html @@ -71,6 +71,35 @@ + + +
diff --git a/src/views/emails.js b/src/views/emails.js index 6009b13d0..b35221d9a 100644 --- a/src/views/emails.js +++ b/src/views/emails.js @@ -154,6 +154,48 @@ angular.module('Application').controller('EmailsController', ['$scope', '$locati } }; + $scope.mailboxSharing = { + busy: false, + error: null, + size: 0, + enable: false, + enabled: false, + + refresh: function () { + Client.getMailboxSharing(function (error, enabled) { + if (error) return console.error('Failed to get mailbox sharing', error); + + $scope.mailboxSharing.enabled = enabled; + }); + }, + + show: function() { + $scope.mailboxSharing.busy = false; + $scope.mailboxSharing.error = null; + $scope.mailboxSharing.enable = $scope.mailboxSharing.enabled; + + $scope.mailboxSharingChangeForm.$setUntouched(); + $scope.mailboxSharingChangeForm.$setPristine(); + + $('#mailboxSharingChangeModal').modal('show'); + }, + + submit: function () { + $scope.mailboxSharing.busy = true; + + Client.setMailboxSharing($scope.mailboxSharing.enable, function (error) { + $scope.mailboxSharing.busy = false; + + if (error) return console.error(error); + + $scope.mailboxSharing.enabled = $scope.mailboxSharing.enable; + + $('#mailboxSharingChangeModal').modal('hide'); + }); + + } + }; + $scope.solrConfig = { busy: false, error: {}, @@ -412,6 +454,7 @@ angular.module('Application').controller('EmailsController', ['$scope', '$locati if ($scope.user.isAtLeastOwner) { $scope.mailLocation.refresh(); $scope.maxEmailSize.refresh(); + $scope.mailboxSharing.refresh(); $scope.spamConfig.refresh(); $scope.solrConfig.refresh(); $scope.acl.refresh();