diff --git a/src/views/apps.js b/src/views/apps.js index 6181b996d..bb9ddddf2 100644 --- a/src/views/apps.js +++ b/src/views/apps.js @@ -221,31 +221,41 @@ angular.module('Application').controller('AppsController', ['$scope', '$location let tab = 'advanced'; // the tab to switch to if (error) { - if (error.statusCode === 409 && (error.message.indexOf('Port') !== -1)) { - $scope.appConfigure.error.port = error.message; - tab = 'location'; - } 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 && error.message.indexOf('Domain') === 0) { - $scope.appConfigure.error.location = error.message; - $scope.appConfigureForm.location.$setPristine(); - tab = 'location'; - $('#appConfigureLocationInput').focus(); - } else if (error.statusCode === 409 && error.message.indexOf('Alternate domain') === 0 ) { - $scope.appConfigure.error.alternateDomains = error.message; - tab = 'location'; - } else if (error.statusCode === 400 && error.message.indexOf('cert') !== -1 ) { - $scope.appConfigure.error.cert = error.message; - $scope.appConfigure.certificateFileName = ''; - $scope.appConfigure.certificateFile = null; - $scope.appConfigure.keyFileName = ''; - $scope.appConfigure.keyFile = null; - } else if (error.message.indexOf('dataDir') !== -1 ) { // can be 400 or 409 - $scope.appConfigure.error.dataDir = error.message; - $scope.appConfigureForm.dataDir.$setPristine(); - $('#appConfigureDataDirInput').focus(); + if (error.statusCode === 409) { + if (error.portName) { + $scope.appConfigure.error.port = error.message; + tab = 'location'; + } else if (error.domain && error.domain === $scope.config.adminDomin) { + $scope.appConfigure.error.location = error.message; + $scope.appConfigureForm.location.$setPristine(); + tab = 'location'; + $('#appConfigureLocationInput').focus(); + } else if (error.domain && error.domain !== $scope.config.adminDomin) { + $scope.appConfigure.error.alternateDomains = error.message; + tab = 'location'; + } else { + $scope.appConfigure.error.other = error.message; + tab = 'location'; + } + } else if (error.statusCode === 400) { + if (error.field === 'mailboxName') { + $scope.appConfigure.error.mailboxName = error.message; + $scope.appConfigureForm.mailboxName.$setPristine(); + $('#appConfigureMailboxNameInput').focus(); + } else if (error.field === 'cert') { + $scope.appConfigure.error.cert = error.message; + $scope.appConfigure.certificateFileName = ''; + $scope.appConfigure.certificateFile = null; + $scope.appConfigure.keyFileName = ''; + $scope.appConfigure.keyFile = null; + } else if (error.field === 'dataDir') { + $scope.appConfigure.error.dataDir = error.message; + $scope.appConfigureForm.dataDir.$setPristine(); + $('#appConfigureDataDirInput').focus(); + } else { + $scope.appConfigure.error.other = error.message; + tab = 'location'; + } } else { $scope.appConfigure.error.other = error.message; tab = 'location'; @@ -362,11 +372,15 @@ angular.module('Application').controller('AppsController', ['$scope', '$location $scope.appClone.busy = false; if (error) { - if (error.statusCode === 409 && (error.message.indexOf('is reserved') !== -1 || error.message.indexOf('is already in use') !== -1)) { - $scope.appClone.error.port = error.message; - } else if (error.statusCode === 409) { - $scope.appClone.error.location = 'This location is already taken.'; - $('#appCloneLocationInput').focus(); + if (error.statusCode === 409) { + if (error.portName) { + $scope.appClone.error.port = error.message; + } else if (error.domain) { + $scope.appClone.error.location = 'This location is already taken.'; + $('#appCloneLocationInput').focus(); + } else { + Client.error(error); + } } else { Client.error(error); }