Add checkbox UI for mailbox location

part of cloudron/box#587
This commit is contained in:
Girish Ramakrishnan
2018-09-25 11:26:10 -07:00
parent ed887953b6
commit ca76626d55
2 changed files with 15 additions and 7 deletions

View File

@@ -36,6 +36,7 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
accessRestriction: { users: [], groups: [] },
xFrameOptions: '',
alternateDomainEnabled: false,
mailboxNameEnabled: false,
alternateSubdomain: '',
alternateDomain: null,
ssoAuth: false,
@@ -64,6 +65,7 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
$scope.appConfigure.alternateDomain = app.alternateDomains[0] ? $scope.domains.filter(function (d) { return d.domain === app.alternateDomains[0].domain; })[0] : $scope.appConfigure.domain;
$scope.appConfigure.robotsTxt = app.robotsTxt;
$scope.appConfigure.enableBackup = app.enableBackup;
$scope.appConfigure.mailboxNameEnabled = app.mailboxName && (app.mailboxName.match(/\.app$/) === null);
$scope.appConfigure.mailboxName = app.mailboxName || '';
$scope.appConfigure.ssoAuth = (app.manifest.addons['ldap'] || app.manifest.addons['oauth']) && app.sso;
@@ -146,13 +148,17 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
// The backend supports multiple alternateDomains, however we only have ui for one
if ($scope.appConfigure.alternateDomainEnabled) data.alternateDomains = [{ domain: $scope.appConfigure.alternateDomain.domain, subdomain: $scope.appConfigure.alternateSubdomain }];
if ($scope.appConfigure.mailboxName !== $scope.appConfigure.app.mailboxName) data.mailboxName = $scope.appConfigure.mailboxName;
if ($scope.appConfigure.mailboxNameEnabled) {
data.mailboxName = $scope.appConfigure.mailboxName;
} else { // setting to empty will reset to .app name
data.mailboxName = '';
}
Client.configureApp($scope.appConfigure.app.id, data, function (error) {
if (error) {
if (error.statusCode === 409 && (error.message.indexOf('is reserved') !== -1 || error.message.indexOf('is already in use') !== -1)) {
$scope.appConfigure.error.port = error.message;
} else if (error.statusCode === 409 && error.message.indexOf('mailbox') !== -1 ) {
} else if (error.statusCode === 400 && error.message.indexOf('mailbox') !== -1 ) {
$scope.appConfigure.error.mailboxName = error.message;
$scope.appConfigureForm.mailboxName.$setPristine();
$('#appConfigureMailboxNameInput').focus();