mirror of
https://github.com/ansible/awx.git
synced 2026-03-25 12:55:04 -02:30
Merge pull request #1873 from jaredevantabor/ldap-stuff
LDAP fixes for saving, and improved error handling
This commit is contained in:
@@ -1256,6 +1256,10 @@ input[type="checkbox"].checkbox-no-label {
|
|||||||
color:@red;
|
color:@red;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.error-border {
|
||||||
|
border-color:@red;
|
||||||
|
}
|
||||||
|
|
||||||
.connecting-color {
|
.connecting-color {
|
||||||
color: @warning;
|
color: @warning;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,6 +110,9 @@ export default [
|
|||||||
authVm.activeAuthForm = getActiveAuthForm();
|
authVm.activeAuthForm = getActiveAuthForm();
|
||||||
formTracker.setCurrentAuth(authVm.activeAuthForm);
|
formTracker.setCurrentAuth(authVm.activeAuthForm);
|
||||||
$('#FormModal-dialog').dialog('close');
|
$('#FormModal-dialog').dialog('close');
|
||||||
|
}).catch(() => {
|
||||||
|
event.preventDefault();
|
||||||
|
$('#FormModal-dialog').dialog('close');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
"class": "btn btn-primary",
|
"class": "btn btn-primary",
|
||||||
|
|||||||
@@ -186,3 +186,8 @@ input#filePickerText {
|
|||||||
hr {
|
hr {
|
||||||
height: 1px;
|
height: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ConfigureTower-errorIcon{
|
||||||
|
margin-right:5px;
|
||||||
|
color:@red;
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import defaultStrings from '~assets/default.strings.json';
|
|||||||
export default [
|
export default [
|
||||||
'$scope', '$rootScope', '$state', '$stateParams', '$timeout', '$q', 'Alert',
|
'$scope', '$rootScope', '$state', '$stateParams', '$timeout', '$q', 'Alert',
|
||||||
'ConfigurationService', 'ConfigurationUtils', 'CreateDialog', 'CreateSelect2', 'i18n', 'ParseTypeChange', 'ProcessErrors', 'Store',
|
'ConfigurationService', 'ConfigurationUtils', 'CreateDialog', 'CreateSelect2', 'i18n', 'ParseTypeChange', 'ProcessErrors', 'Store',
|
||||||
'Wait', 'configDataResolve', 'ToJSON', 'ConfigService',
|
'Wait', 'configDataResolve', 'ToJSON', 'ConfigService', 'ngToast',
|
||||||
//Form definitions
|
//Form definitions
|
||||||
'configurationAzureForm',
|
'configurationAzureForm',
|
||||||
'configurationGithubForm',
|
'configurationGithubForm',
|
||||||
@@ -32,7 +32,7 @@ export default [
|
|||||||
function(
|
function(
|
||||||
$scope, $rootScope, $state, $stateParams, $timeout, $q, Alert,
|
$scope, $rootScope, $state, $stateParams, $timeout, $q, Alert,
|
||||||
ConfigurationService, ConfigurationUtils, CreateDialog, CreateSelect2, i18n, ParseTypeChange, ProcessErrors, Store,
|
ConfigurationService, ConfigurationUtils, CreateDialog, CreateSelect2, i18n, ParseTypeChange, ProcessErrors, Store,
|
||||||
Wait, configDataResolve, ToJSON, ConfigService,
|
Wait, configDataResolve, ToJSON, ConfigService, ngToast,
|
||||||
//Form definitions
|
//Form definitions
|
||||||
configurationAzureForm,
|
configurationAzureForm,
|
||||||
configurationGithubForm,
|
configurationGithubForm,
|
||||||
@@ -241,10 +241,15 @@ export default [
|
|||||||
}, {
|
}, {
|
||||||
label: i18n._("Save changes"),
|
label: i18n._("Save changes"),
|
||||||
onClick: function() {
|
onClick: function() {
|
||||||
vm.formSave();
|
vm.formSave().then(() => {
|
||||||
$scope[formTracker.currentFormName()].$setPristine();
|
$scope[formTracker.currentFormName()].$setPristine();
|
||||||
$('#FormModal-dialog').dialog('close');
|
$('#FormModal-dialog').dialog('close');
|
||||||
active(setForm);
|
active(setForm);
|
||||||
|
}).catch(()=> {
|
||||||
|
event.preventDefault();
|
||||||
|
$('#FormModal-dialog').dialog('close');
|
||||||
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
"class": "btn btn-primary",
|
"class": "btn btn-primary",
|
||||||
"id": "formmodal-save-button"
|
"id": "formmodal-save-button"
|
||||||
@@ -396,11 +401,12 @@ export default [
|
|||||||
}
|
}
|
||||||
loginUpdate();
|
loginUpdate();
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(data) {
|
||||||
ProcessErrors($scope, error, status, formDefs[formTracker.getCurrent()],
|
ProcessErrors($scope, data.error, data.status, formDefs[formTracker.getCurrent()],
|
||||||
{
|
{
|
||||||
hdr: i18n._('Error!'),
|
hdr: `<i class="fa fa-warning ConfigureTower-errorIcon"></i>
|
||||||
msg: i18n._('There was an error resetting value. Returned status: ') + error.detail
|
<span class="error-color">${ i18n._('Error!')} </span>`,
|
||||||
|
msg: i18n._('There was an error resetting value. Returned status: ') + data.error.detail
|
||||||
});
|
});
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -495,14 +501,23 @@ export default [
|
|||||||
|
|
||||||
saveDeferred.resolve(data);
|
saveDeferred.resolve(data);
|
||||||
$scope[formTracker.currentFormName()].$setPristine();
|
$scope[formTracker.currentFormName()].$setPristine();
|
||||||
|
ngToast.success({
|
||||||
|
timeout: 2000,
|
||||||
|
dismissButton: false,
|
||||||
|
dismissOnTimeout: true,
|
||||||
|
content: `<i class="fa fa-check-circle
|
||||||
|
Toast-successIcon"></i>` +
|
||||||
|
i18n._('Save Complete')
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch(function(error, status) {
|
.catch(function(data) {
|
||||||
ProcessErrors($scope, error, status, formDefs[formTracker.getCurrent()],
|
ProcessErrors($scope, data.data, data.status, formDefs[formTracker.getCurrent()],
|
||||||
{
|
{
|
||||||
hdr: i18n._('Error!'),
|
hdr: `<i class="fa fa-warning ConfigureTower-errorIcon"></i>
|
||||||
msg: i18n._('Failed to save settings. Returned status: ') + status
|
<span class="error-color">${ i18n._('Error!')} </span>`,
|
||||||
|
msg: i18n._('Failed to save settings. Returned status: ') + data.status
|
||||||
});
|
});
|
||||||
saveDeferred.reject(error);
|
saveDeferred.reject(data);
|
||||||
})
|
})
|
||||||
.finally(function() {
|
.finally(function() {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
@@ -528,13 +543,14 @@ export default [
|
|||||||
.then(function() {
|
.then(function() {
|
||||||
//TODO consider updating form values with returned data here
|
//TODO consider updating form values with returned data here
|
||||||
})
|
})
|
||||||
.catch(function(error, status) {
|
.catch(function(data) {
|
||||||
//Change back on unsuccessful update
|
//Change back on unsuccessful update
|
||||||
$scope[key] = !$scope[key];
|
$scope[key] = !$scope[key];
|
||||||
ProcessErrors($scope, error, status, formDefs[formTracker.getCurrent()],
|
ProcessErrors($scope, data.data, data.status, formDefs[formTracker.getCurrent()],
|
||||||
{
|
{
|
||||||
hdr: i18n._('Error!'),
|
hdr: `<i class="fa fa-warning ConfigureTower-errorIcon"></i>
|
||||||
msg: i18n._('Failed to save toggle settings. Returned status: ') + error.detail
|
<span class="error-color">${ i18n._('Error!')} </span>`,
|
||||||
|
msg: i18n._('Failed to save toggle settings. Returned status: ') + data.status
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.finally(function() {
|
.finally(function() {
|
||||||
@@ -577,11 +593,12 @@ export default [
|
|||||||
});
|
});
|
||||||
|
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(data) {
|
||||||
ProcessErrors($scope, error, status, formDefs[formTracker.getCurrent()],
|
ProcessErrors($scope, data.error, data.status, formDefs[formTracker.getCurrent()],
|
||||||
{
|
{
|
||||||
hdr: i18n._('Error!'),
|
hdr: `<i class="fa fa-warning ConfigureTower-errorIcon"></i>
|
||||||
msg: i18n._('There was an error resetting values. Returned status: ') + error.detail
|
<span class="error-color">${ i18n._('Error!')} </span>`,
|
||||||
|
msg: i18n._('There was an error resetting values. Returned status: ') + data.error.detail
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.finally(function() {
|
.finally(function() {
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export default ['$rootScope', 'GetBasePath', 'ProcessErrors', '$q', '$http', 'Re
|
|||||||
.then(({data}) => {
|
.then(({data}) => {
|
||||||
deferred.resolve(data);
|
deferred.resolve(data);
|
||||||
})
|
})
|
||||||
.catch(({error}) => {
|
.catch((error) => {
|
||||||
deferred.reject(error);
|
deferred.reject(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ export default ['$rootScope', 'GetBasePath', 'ProcessErrors', '$q', '$http', 'Re
|
|||||||
.then(({data}) => {
|
.then(({data}) => {
|
||||||
deferred.resolve(data);
|
deferred.resolve(data);
|
||||||
})
|
})
|
||||||
.catch(({error}) => {
|
.catch((error) => {
|
||||||
deferred.reject(error);
|
deferred.reject(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -209,14 +209,17 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
|
|||||||
} else {
|
} else {
|
||||||
if (data[field]) {
|
if (data[field]) {
|
||||||
scope[field + '_api_error'] = data[field][0];
|
scope[field + '_api_error'] = data[field][0];
|
||||||
//scope[form.name + '_form'][field].$setValidity('apiError', false);
|
|
||||||
$('[name="' + field + '"]').addClass('ng-invalid');
|
$('[name="' + field + '"]').addClass('ng-invalid');
|
||||||
|
$('label[for="' + field + '"] span').addClass('error-color');
|
||||||
$('html, body').animate({scrollTop: $('[name="' + field + '"]').offset().top}, 0);
|
$('html, body').animate({scrollTop: $('[name="' + field + '"]').offset().top}, 0);
|
||||||
fieldErrors = true;
|
fieldErrors = true;
|
||||||
|
if(form.fields[field].codeMirror){
|
||||||
|
$(`#cm-${field}-container .CodeMirror`).addClass('error-border');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((!fieldErrors) && defaultMsg) {
|
if (defaultMsg) {
|
||||||
Alert(defaultMsg.hdr, defaultMsg.msg);
|
Alert(defaultMsg.hdr, defaultMsg.msg);
|
||||||
}
|
}
|
||||||
} else if (typeof data === 'object' && data !== null) {
|
} else if (typeof data === 'object' && data !== null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user