Fixed update_interval save/load issues. Handling of multiple API calls to save group with source was wrong. Now form status is not checked until all calls complete. update_interval value is correctly translated btwn API integer value and UI drop-down list.

This commit is contained in:
chouseknecht
2013-10-15 12:41:17 -04:00
parent bc49317c23
commit edc0f2f774
3 changed files with 29 additions and 20 deletions

View File

@@ -198,7 +198,7 @@ angular.module('GroupFormDefinition', [])
ngShow: "source.value !== '' && source.value !== null", ngShow: "source.value !== '' && source.value !== null",
editRequired: false, editRequired: false,
addRequired: false, addRequired: false,
'default': { label: 'none', value: null }, 'default': { label: 'none', value: 0 },
dataTitle: 'Update Interval', dataTitle: 'Update Interval',
dataPlacement: 'left', dataPlacement: 'left',
awPopOver: "<p>Instruct the AWX server to automatically run the inventory update process the selected number of minutes from " + awPopOver: "<p>Instruct the AWX server to automatically run the inventory update process the selected number of minutes from " +

View File

@@ -26,7 +26,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
.factory('GetUpdateIntervalOptions', [ function() { .factory('GetUpdateIntervalOptions', [ function() {
return function() { return function() {
return [ return [
{ label: 'none', value: null }, { label: 'none', value: 0 },
{ label: '5 minutes', value: 5 }, { label: '5 minutes', value: 5 },
{ label: '10 minutes', value: 10 }, { label: '10 minutes', value: 10 },
{ label: '15 minutes', value: 15 }, { label: '15 minutes', value: 15 },
@@ -673,12 +673,13 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
master['source'] = scope['source']; master['source'] = scope['source'];
} }
else if (fld == 'update_interval') { else if (fld == 'update_interval') {
if (data['update_interval'] == '') { if (data[fld] == '' || data[fld] == null || data[fld] == undefined) {
data['update_interval'] = null; data[fld] = 0;
} }
for (var i=0; i < scope.update_interval_options.length; i++) { for (var i=0; i < scope.update_interval_options.length; i++) {
if (scope.update_interval_options[i].value == data['update_interval']) { if (scope.update_interval_options[i].value ==
scope['update_interval'] = scope.update_interval_options[i]; data[fld]) {
scope[fld] = scope.update_interval_options[i];
} }
} }
} }
@@ -738,6 +739,18 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
scope.$digest(); scope.$digest();
} }
if (scope.removeSaveComplete) {
scope.removeSaveComplete();
}
scope.removeSaveComplete = scope.$on('SaveComplete', function(e, error) {
if (!error) {
// Reset the form, adjust buttons and let user know changese saved
scope[form.name + '_form'].$setPristine();
scope['groupUpdateHide'] = (scope['source'].value !== null && scope['source'].value !== '') ? false : true;
Alert("Changes Saved", "Your changes to inventory group " + scope['name'] + " were successfully saved.", 'alert-info');
}
});
if (scope.removeFormSaveSuccess) { if (scope.removeFormSaveSuccess) {
scope.removeFormSaveSuccess(); scope.removeFormSaveSuccess();
} }
@@ -778,6 +791,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
} }
catch(err) { catch(err) {
parseError = true; parseError = true;
scope.$emit('SaveComplete', true);
Alert("Error", "Error parsing extra variables. Parser returned: " + err); Alert("Error", "Error parsing extra variables. Parser returned: " + err);
} }
} }
@@ -785,21 +799,16 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
if (!parseError) { if (!parseError) {
Rest.setUrl(scope.source_url) Rest.setUrl(scope.source_url)
Rest.put(data) Rest.put(data)
.success( function(data, status, headers, config) {
scope.$emit('SaveComplete', false);
})
.error( function(data, status, headers, config) { .error( function(data, status, headers, config) {
saveError = true; scope.$emit('SaveComplete', true);
ProcessErrors(scope, data, status, form, ProcessErrors(scope, data, status, form,
{ hdr: 'Error!', msg: 'Failed to update group inventory source. PUT status: ' + status }); { hdr: 'Error!', msg: 'Failed to update group inventory source. PUT status: ' + status });
}); });
} }
} }
if (!saveError && !parseError) {
// Reset the form, adjust buttons and let user know changese saved
scope[form.name + '_form'].$setPristine();
scope['groupUpdateHide'] = (scope['source'].value !== null && scope['source'].value !== '') ? false : true;
Alert("Changes Saved", "Your changes to inventory group " + scope['name'] + " were successfully saved.", 'alert-info');
}
}); });
// Save changes to the parent // Save changes to the parent
@@ -835,7 +844,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
Rest.put(json_data) Rest.put(json_data)
.error( function(data, status, headers, config) { .error( function(data, status, headers, config) {
ProcessErrors(scope, data, status, form, ProcessErrors(scope, data, status, form,
{ hdr: 'Error!', msg: 'Failed to update group varaibles. PUT status: ' + status }); { hdr: 'Error!', msg: 'Failed to update group variables. PUT status: ' + status });
}); });
} }
RefreshGroupName(scope['selectedNode'], data.name, data.description); RefreshGroupName(scope['selectedNode'], data.name, data.description);

View File

@@ -109,7 +109,7 @@ angular.module('InventorySummaryDefinition', [])
dataPlacement: 'top' dataPlacement: 'top'
}, },
help: { help: {
dataPlacement: 'top', dataPlacement: 'left',
icon: "icon-question-sign", icon: "icon-question-sign",
mode: 'all', mode: 'all',
'class': 'btn-xs btn-info btn-help', 'class': 'btn-xs btn-info btn-help',