mirror of
https://github.com/ansible/awx.git
synced 2026-03-13 23:17:32 -02:30
Fixed bug in Inventory Group Add. Save was failing. Also when group vars failed to parse, the error was not bubbled up to the GroupEdit code.
This commit is contained in:
@@ -14,7 +14,8 @@ function JobsList($scope, $compile, ClearScope, Breadcrumbs, LoadScope, RunningJ
|
|||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
var e, completed_scope, running_scope, queued_scope, schedule_scope;
|
var e, completed_scope, running_scope, queued_scope;
|
||||||
|
// schedule_scope;
|
||||||
|
|
||||||
// Add breadcrumbs
|
// Add breadcrumbs
|
||||||
e = angular.element(document.getElementById('breadcrumbs'));
|
e = angular.element(document.getElementById('breadcrumbs'));
|
||||||
|
|||||||
@@ -552,11 +552,11 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize) {
|
|||||||
.factory('GroupsEdit', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'GroupForm', 'GenerateForm',
|
.factory('GroupsEdit', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'GroupForm', 'GenerateForm',
|
||||||
'Prompt', 'ProcessErrors', 'GetBasePath', 'SetNodeName', 'ParseTypeChange', 'GetSourceTypeOptions', 'InventoryUpdate',
|
'Prompt', 'ProcessErrors', 'GetBasePath', 'SetNodeName', 'ParseTypeChange', 'GetSourceTypeOptions', 'InventoryUpdate',
|
||||||
'LookUpInit', 'Empty', 'Wait', 'GetChoices', 'UpdateGroup', 'SourceChange', 'Find','WatchInventoryWindowResize',
|
'LookUpInit', 'Empty', 'Wait', 'GetChoices', 'UpdateGroup', 'SourceChange', 'Find','WatchInventoryWindowResize',
|
||||||
'ParseVariableString', 'ToJSON', 'ScheduleList', 'SourceForm', 'SetSchedulesInnerDialogSize',
|
'ParseVariableString', 'ToJSON', 'ScheduleList', 'SourceForm', 'SetSchedulesInnerDialogSize', 'BuildTree',
|
||||||
function ($rootScope, $location, $log, $routeParams, Rest, Alert, GroupForm, GenerateForm, Prompt, ProcessErrors,
|
function ($rootScope, $location, $log, $routeParams, Rest, Alert, GroupForm, GenerateForm, Prompt, ProcessErrors,
|
||||||
GetBasePath, SetNodeName, ParseTypeChange, GetSourceTypeOptions, InventoryUpdate, LookUpInit, Empty, Wait,
|
GetBasePath, SetNodeName, ParseTypeChange, GetSourceTypeOptions, InventoryUpdate, LookUpInit, Empty, Wait,
|
||||||
GetChoices, UpdateGroup, SourceChange, Find, WatchInventoryWindowResize, ParseVariableString, ToJSON, ScheduleList,
|
GetChoices, UpdateGroup, SourceChange, Find, WatchInventoryWindowResize, ParseVariableString, ToJSON, ScheduleList,
|
||||||
SourceForm, SetSchedulesInnerDialogSize) {
|
SourceForm, SetSchedulesInnerDialogSize, BuildTree) {
|
||||||
return function (params) {
|
return function (params) {
|
||||||
|
|
||||||
var parent_scope = params.scope,
|
var parent_scope = params.scope,
|
||||||
@@ -933,6 +933,27 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize) {
|
|||||||
|
|
||||||
Wait('start');
|
Wait('start');
|
||||||
|
|
||||||
|
if (parent_scope.removeAddTreeRefreshed) {
|
||||||
|
parent_scope.removeAddTreeRefreshed();
|
||||||
|
}
|
||||||
|
parent_scope.removeAddTreeRefreshed = parent_scope.$on('GroupTreeRefreshed', function() {
|
||||||
|
//Clean up
|
||||||
|
if (modal_scope.searchCleanUp) {
|
||||||
|
modal_scope.searchCleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#group-modal-dialog').dialog('close');
|
||||||
|
|
||||||
|
// Change the selected group
|
||||||
|
if (groups_reload && parent_scope.selected_tree_id !== tree_id) {
|
||||||
|
parent_scope.showHosts(tree_id, group_id, false);
|
||||||
|
} else {
|
||||||
|
Wait('stop');
|
||||||
|
}
|
||||||
|
WatchInventoryWindowResize();
|
||||||
|
parent_scope.removeAddTreeRefreshed();
|
||||||
|
});
|
||||||
|
|
||||||
if (modal_scope.removeSaveComplete) {
|
if (modal_scope.removeSaveComplete) {
|
||||||
modal_scope.removeSaveComplete();
|
modal_scope.removeSaveComplete();
|
||||||
}
|
}
|
||||||
@@ -963,20 +984,17 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Clean up
|
if (mode === 'add') {
|
||||||
if (modal_scope.searchCleanUp) {
|
BuildTree({
|
||||||
modal_scope.searchCleanup();
|
scope: parent_scope,
|
||||||
|
inventory_id: inventory_id,
|
||||||
|
refresh: true,
|
||||||
|
new_group_id: group_id
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
$('#group-modal-dialog').dialog('close');
|
parent_scope.$emit('GroupTreeRefreshed');
|
||||||
|
|
||||||
// Change the selected group
|
|
||||||
if (groups_reload && parent_scope.selected_tree_id !== tree_id) {
|
|
||||||
parent_scope.showHosts(tree_id, group_id, false);
|
|
||||||
} else {
|
|
||||||
Wait('stop');
|
|
||||||
}
|
}
|
||||||
WatchInventoryWindowResize();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1015,28 +1033,15 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize) {
|
|||||||
|
|
||||||
if (!parseError) {
|
if (!parseError) {
|
||||||
Rest.setUrl(sources_scope.source_url);
|
Rest.setUrl(sources_scope.source_url);
|
||||||
if (mode === 'edit') {
|
Rest.put(data)
|
||||||
Rest.put(data)
|
.success(function () {
|
||||||
.success(function () {
|
modal_scope.$emit('SaveComplete', false);
|
||||||
modal_scope.$emit('SaveComplete', false);
|
})
|
||||||
})
|
.error(function (data, status) {
|
||||||
.error(function (data, status) {
|
modal_scope.$emit('SaveComplete', true);
|
||||||
modal_scope.$emit('SaveComplete', true);
|
ProcessErrors(sources_scope, data, status, SourceForm, { hdr: 'Error!',
|
||||||
ProcessErrors(sources_scope, data, status, SourceForm, { hdr: 'Error!',
|
msg: 'Failed to update group inventory source. PUT status: ' + status });
|
||||||
msg: 'Failed to update group inventory source. PUT status: ' + status });
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Rest.post(data)
|
|
||||||
.success(function () {
|
|
||||||
modal_scope.$emit('SaveComplete', false);
|
|
||||||
})
|
|
||||||
.error(function (data, status) {
|
|
||||||
modal_scope.$emit('SaveComplete', true);
|
|
||||||
ProcessErrors(sources_scope, data, status, SourceForm, { hdr: 'Error!',
|
|
||||||
msg: 'Failed to update group inventory source. PUT status: ' + status });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1074,51 +1079,58 @@ function(SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize) {
|
|||||||
Wait('start');
|
Wait('start');
|
||||||
var fld, data, json_data;
|
var fld, data, json_data;
|
||||||
|
|
||||||
json_data = ToJSON(properties_scope.parseType, properties_scope.variables);
|
try {
|
||||||
|
|
||||||
|
json_data = ToJSON(properties_scope.parseType, properties_scope.variables);
|
||||||
|
|
||||||
data = {};
|
data = {};
|
||||||
for (fld in GroupForm.fields) {
|
for (fld in GroupForm.fields) {
|
||||||
if (fld !== 'variables') {
|
if (fld !== 'variables') {
|
||||||
data[fld] = properties_scope[fld];
|
data[fld] = properties_scope[fld];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data.inventory = inventory_id;
|
||||||
|
|
||||||
|
Rest.setUrl(defaultUrl);
|
||||||
|
if (mode === 'edit') {
|
||||||
|
Rest.put(data)
|
||||||
|
.success(function () {
|
||||||
|
if (properties_scope.variables) {
|
||||||
|
modal_scope.$emit('updateVariables', json_data, properties_scope.variable_url);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
modal_scope.$emit('formSaveSuccess');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
Wait('stop');
|
||||||
|
ProcessErrors(properties_scope, data, status, GroupForm, { hdr: 'Error!',
|
||||||
|
msg: 'Failed to update group: ' + group_id + '. PUT status: ' + status
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Rest.post(data)
|
||||||
|
.success(function (data) {
|
||||||
|
if (properties_scope.variables) {
|
||||||
|
sources_scope.source_url = data.related.inventory_source;
|
||||||
|
modal_scope.$emit('updateVariables', json_data, data.related.variable_data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
modal_scope.$emit('formSaveSuccess');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
Wait('stop');
|
||||||
|
ProcessErrors(properties_scope, data, status, GroupForm, { hdr: 'Error!',
|
||||||
|
msg: 'Failed to create group: ' + group_id + '. POST status: ' + status
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch(e) {
|
||||||
data.inventory = inventory_id;
|
// ignore. ToJSON will have already alerted the user
|
||||||
|
|
||||||
Rest.setUrl(defaultUrl);
|
|
||||||
if (mode === 'edit') {
|
|
||||||
Rest.put(data)
|
|
||||||
.success(function () {
|
|
||||||
if (properties_scope.variables) {
|
|
||||||
modal_scope.$emit('updateVariables', json_data, properties_scope.variable_url);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
modal_scope.$emit('formSaveSuccess');
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.error(function (data, status) {
|
|
||||||
Wait('stop');
|
|
||||||
ProcessErrors(properties_scope, data, status, GroupForm, { hdr: 'Error!',
|
|
||||||
msg: 'Failed to update group: ' + group_id + '. PUT status: ' + status
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Rest.post(data)
|
|
||||||
.success(function () {
|
|
||||||
if (properties_scope.variables) {
|
|
||||||
modal_scope.$emit('updateVariables', json_data, properties_scope.variable_url);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
modal_scope.$emit('formSaveSuccess');
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.error(function (data, status) {
|
|
||||||
Wait('stop');
|
|
||||||
ProcessErrors(properties_scope, data, status, GroupForm, { hdr: 'Error!',
|
|
||||||
msg: 'Failed to create group: ' + group_id + '. POST status: ' + status
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -99,6 +99,9 @@ angular.module('VariablesHelper', ['Utilities'])
|
|||||||
if (typeof json_data !== 'object') {
|
if (typeof json_data !== 'object') {
|
||||||
ProcessErrors(null, variables, null, null, { hdr: 'Error!',
|
ProcessErrors(null, variables, null, null, { hdr: 'Error!',
|
||||||
msg: 'Failed to parse variables. Attempted to parse ' + parseType + ' Parser did not return an object.' });
|
msg: 'Failed to parse variables. Attempted to parse ' + parseType + ' Parser did not return an object.' });
|
||||||
|
setTimeout( function() {
|
||||||
|
throw { name: 'Parse error', message: 'Failed to parse variables. Attempted to parse ' + parseType + ' Parser did not return an object.' };
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
result = json_data;
|
result = json_data;
|
||||||
if (stringify) {
|
if (stringify) {
|
||||||
|
|||||||
Reference in New Issue
Block a user