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
+3 -3
View File
@@ -9,8 +9,8 @@
<div class="modal-body" style="padding: 0 15px">
<fieldset>
<form role="form" name="appConfigureForm" ng-submit="appConfigure.submit()" autocomplete="off">
<uib-tabset>
<uib-tab index="0" heading="General">
<uib-tabset active="appConfigure.action">
<uib-tab index="'general'" heading="General">
<br/>
<div class="has-error text-center" ng-show="appConfigure.error.other">{{ appConfigure.error.other }}</div>
<div class="form-group" ng-class="{ 'has-error': (appConfigureForm.location.$dirty && appConfigureForm.location.$invalid) || (!appConfigureForm.location.$dirty && appConfigure.error.location) }">
@@ -101,7 +101,7 @@
</uib-tab>
<uib-tab index="1" heading="Advanced">
<uib-tab index="'advanced'" heading="Advanced">
<br/>
<div class="form-group">
<label class="control-label" for="memoryLimit">Memory Limit <sup><a ng-href="{{ config.webServerOrigin }}/documentation/apps/#increasing-the-memory-limit-of-an-app" class="help" target="_blank"><i class="fa fa-question-circle"></i></a></sup> : <b>{{ appConfigure.memoryLimit ? appConfigure.memoryLimit / 1024 / 1024 + 'MB' : 'Default (256 MB)' }}</b></label>
+11 -3
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;
}
+3 -3
View File
@@ -177,10 +177,10 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca
$('#collapseResourceConstraint').collapse('hide');
$('#collapseInstallForm').collapse('hide');
$('#collapseAppLimitReached').collapse('show');
} else if (error.statusCode === 409 && (error.message.indexOf('is reserved') !== -1 || error.message.indexOf('is already in use') !== -1)) {
} else if (error.statusCode === 409 && (error.message.indexOf('Port') !== -1)) {
$scope.appInstall.error.port = error.message;
} else if (error.statusCode === 409) {
$scope.appInstall.error.location = 'This name is already taken.';
} else if (error.statusCode === 409 && error.message.indexOf('subdomain') !== -1) {
$scope.appInstall.error.location = error.message;
$scope.appInstallForm.location.$setPristine();
$('#appInstallLocationInput').focus();
} else if (error.statusCode === 400 && error.message.indexOf('cert') !== -1 ) {