mirror of
https://github.com/ansible/awx.git
synced 2026-03-07 19:51:08 -03:30
Fixed extra_vars on job_templates and jobs detail pages. No longer attempts to compile string into a JSON object. Assumes user will enter valid JSON or key=value pairs. Updated help text to reflect this and link to ansibleworks.com documentation on --extra-vars parameter.
This commit is contained in:
@@ -233,33 +233,26 @@ function JobTemplatesAdd ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
|
|
||||||
// Save
|
// Save
|
||||||
scope.formSave = function() {
|
scope.formSave = function() {
|
||||||
try {
|
Rest.setUrl(defaultUrl);
|
||||||
// Make sure we have valid JSON
|
var data = {}
|
||||||
var myjson = JSON.parse(scope.extra_vars);
|
for (var fld in form.fields) {
|
||||||
Rest.setUrl(defaultUrl);
|
if (form.fields[fld].type == 'select' && fld != 'playbook') {
|
||||||
var data = {}
|
data[fld] = scope[fld].value;
|
||||||
for (var fld in form.fields) {
|
}
|
||||||
if (form.fields[fld].type == 'select' && fld != 'playbook') {
|
else {
|
||||||
data[fld] = scope[fld].value;
|
data[fld] = scope[fld];
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
data[fld] = scope[fld];
|
Rest.post(data)
|
||||||
}
|
.success( function(data, status, headers, config) {
|
||||||
}
|
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||||
Rest.post(data)
|
(base == 'job_templates') ? ReturnToCaller() : ReturnToCaller(1);
|
||||||
.success( function(data, status, headers, config) {
|
})
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
.error( function(data, status, headers, config) {
|
||||||
(base == 'job_templates') ? ReturnToCaller() : ReturnToCaller(1);
|
ProcessErrors(scope, data, status, form,
|
||||||
})
|
{ hdr: 'Error!', msg: 'Failed to add new project. POST returned status: ' + status });
|
||||||
.error( function(data, status, headers, config) {
|
});
|
||||||
ProcessErrors(scope, data, status, form,
|
};
|
||||||
{ hdr: 'Error!', msg: 'Failed to add new project. POST returned status: ' + status });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch(err) {
|
|
||||||
Alert("Error", "Error parsing extra variables. Expecting valid JSON. Parser returned " + err);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Reset
|
// Reset
|
||||||
scope.formReset = function() {
|
scope.formReset = function() {
|
||||||
@@ -419,33 +412,26 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
|
|||||||
|
|
||||||
// Save changes to the parent
|
// Save changes to the parent
|
||||||
scope.formSave = function() {
|
scope.formSave = function() {
|
||||||
try {
|
var data = {}
|
||||||
// Make sure we have valid JSON
|
for (var fld in form.fields) {
|
||||||
var myjson = JSON.parse(scope.extra_vars);
|
if (form.fields[fld].type == 'select' && fld != 'playbook') {
|
||||||
Rest.setUrl(defaultUrl + $routeParams.id + '/');
|
data[fld] = scope[fld].value;
|
||||||
var data = {}
|
}
|
||||||
for (var fld in form.fields) {
|
else {
|
||||||
if (form.fields[fld].type == 'select' && fld != 'playbook') {
|
data[fld] = scope[fld];
|
||||||
data[fld] = scope[fld].value;
|
}
|
||||||
}
|
}
|
||||||
else {
|
Rest.setUrl(defaultUrl + $routeParams.id + '/');
|
||||||
data[fld] = scope[fld];
|
Rest.put(data)
|
||||||
}
|
.success( function(data, status, headers, config) {
|
||||||
}
|
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||||
Rest.put(data)
|
(base == 'job_templates') ? ReturnToCaller() : ReturnToCaller(1);
|
||||||
.success( function(data, status, headers, config) {
|
})
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
.error( function(data, status, headers, config) {
|
||||||
(base == 'job_templates') ? ReturnToCaller() : ReturnToCaller(1);
|
ProcessErrors(scope, data, status, form,
|
||||||
})
|
{ hdr: 'Error!', msg: 'Failed to update team: ' + $routeParams.id + '. PUT status: ' + status });
|
||||||
.error( function(data, status, headers, config) {
|
});
|
||||||
ProcessErrors(scope, data, status, form,
|
};
|
||||||
{ hdr: 'Error!', msg: 'Failed to update team: ' + $routeParams.id + '. PUT status: ' + status });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch(err) {
|
|
||||||
Alert("Error", "Error parsing extra variables. Expecting valid JSON. Parser returned " + err);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Cancel
|
// Cancel
|
||||||
scope.formReset = function() {
|
scope.formReset = function() {
|
||||||
|
|||||||
@@ -136,11 +136,9 @@ angular.module('JobTemplateFormDefinition', [])
|
|||||||
editRequired: false,
|
editRequired: false,
|
||||||
"default": "\{\}",
|
"default": "\{\}",
|
||||||
column: 2,
|
column: 2,
|
||||||
awPopOver: "<p>Enter variables as JSON. Both the key and value must be wrapped in double quotes. " +
|
awPopOver: "<p>Pass extra command line variables to the playbook. This is the -e or --extra-vars command line parameter " +
|
||||||
"Separate variables with commas, and wrap the entire string with { }. " +
|
"for ansible-playbook. Provide key=value pairs or JSON. <p><a href=\"http://www.ansibleworks.com/docs/playbooks2.html" +
|
||||||
" For example:</p><p>{<br\>"ntp_server": "ntp.example.com",<br \>" +
|
"#passing-variables-on-the-command-line\" target=\"_blank\">Click here to view documentation and examples.</a></p>",
|
||||||
'"proxy": "proxy.example.com"<br \>}</p><p>See additional JSON examples at <a href="' +
|
|
||||||
'http://www.json.org" target="_blank">www.json.org</a></p>',
|
|
||||||
dataTitle: 'Extra Variables',
|
dataTitle: 'Extra Variables',
|
||||||
dataPlacement: 'left'
|
dataPlacement: 'left'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,6 +129,9 @@ angular.module('JobFormDefinition', [])
|
|||||||
"class": 'span12',
|
"class": 'span12',
|
||||||
addRequired: false,
|
addRequired: false,
|
||||||
editRequired: false,
|
editRequired: false,
|
||||||
|
awPopOver: "<p>Pass extra command line variables to the playbook. This is the -e or --extra-vars command line parameter " +
|
||||||
|
"for ansible-playbook. Provide key=value pairs or JSON. <p><a href=\"http://www.ansibleworks.com/docs/playbooks2.html" +
|
||||||
|
"#passing-variables-on-the-command-line\" target=\"_blank\">Click here to view documentation and examples.</a></p>",
|
||||||
column: 2
|
column: 2
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user