Fix error handling and tab focus

This commit is contained in:
Girish Ramakrishnan
2019-01-19 22:04:46 -08:00
parent 8d3c1c9f9e
commit cb856ce2bb
3 changed files with 17 additions and 9 deletions

View File

@@ -43,6 +43,8 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
alternateDomain: null,
ssoAuth: false,
action: 'general',
isAccessRestrictionValid: function () {
var tmp = $scope.appConfigure.accessRestriction;
return !!(tmp.users.length || tmp.groups.length);
@@ -170,16 +172,20 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
}
Client.configureApp($scope.appConfigure.app.id, data, function (error) {
let tab = 'advanced'; // the tab to switch to
if (error) {
if (error.statusCode === 409 && (error.message.indexOf('is reserved') !== -1 || error.message.indexOf('is already in use') !== -1)) {
if (error.statusCode === 409 && (error.message.indexOf('Port') !== -1)) {
$scope.appConfigure.error.port = error.message;
tab = 'general';
} else if (error.statusCode === 400 && error.message.indexOf('mailbox') !== -1 ) {
$scope.appConfigure.error.mailboxName = error.message;
$scope.appConfigureForm.mailboxName.$setPristine();
$('#appConfigureMailboxNameInput').focus();
} else if (error.statusCode === 409) {
} else if (error.statusCode === 409 && error.message.indexOf('subdomain') !== -1) {
$scope.appConfigure.error.location = error.message;
$scope.appConfigureForm.location.$setPristine();
tab = 'general';
$('#appConfigureLocationInput').focus();
} else if (error.statusCode === 400 && error.message.indexOf('cert') !== -1 ) {
$scope.appConfigure.error.cert = error.message;
@@ -195,14 +201,16 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
$scope.appConfigure.error.alternateDomains = error.message;
$scope.appConfigureForm.alternateDomains.$setPristine();
$('#appConfigureAlternateSubdomainInput').focus();
} else if (error.statusCode === 400 && error.message.indexOf('dataDir') !== -1 ) {
} else if (error.message.indexOf('dataDir') !== -1 ) { // can be 400 or 409
$scope.appConfigure.error.dataDir = error.message;
$scope.appConfigureForm.dataDir.$setPristine();
$('#appConfigureDataDirInput').focus();
} else {
$scope.appConfigure.error.other = error.message;
tab = 'general';
}
$scope.appConfigure.action = tab;
$scope.appConfigure.busy = false;
return;
}