mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
AC-1035 UI now supports stringified YAML coming from the API on Job Template.
This commit is contained in:
@@ -594,8 +594,22 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
data.extra_vars === "" || data.extra_vars === null) {
|
data.extra_vars === "" || data.extra_vars === null) {
|
||||||
$scope.variables = "---";
|
$scope.variables = "---";
|
||||||
} else {
|
} else {
|
||||||
json_obj = JSON.parse(data.extra_vars);
|
$scope.variables = '---';
|
||||||
$scope.variables = jsyaml.safeDump(json_obj);
|
try {
|
||||||
|
json_obj = JSON.parse(data.extra_vars);
|
||||||
|
$scope.variables = jsyaml.safeDump(json_obj);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
$log.info('Attempt to parse extra_vars as JSON faild. Attempting to parse as YAML');
|
||||||
|
try {
|
||||||
|
json_obj = jsyaml.safeLoad(data.extra_vars);
|
||||||
|
$scope.variables = jsyaml.safeDump(json_obj);
|
||||||
|
}
|
||||||
|
catch(e2) {
|
||||||
|
ProcessErrors($scope, data.extra_vars, e2.message, null, { hdr: 'Error!',
|
||||||
|
msg: 'Attempts to parse variables as JSON and YAML failed. Last attempt returned: ' + e2.message });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
master.variables = $scope.variables;
|
master.variables = $scope.variables;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -379,8 +379,22 @@ function JobsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, J
|
|||||||
data.extra_vars === "" || data.extra_vars === null) {
|
data.extra_vars === "" || data.extra_vars === null) {
|
||||||
$scope.variables = "---";
|
$scope.variables = "---";
|
||||||
} else {
|
} else {
|
||||||
json_obj = JSON.parse(data.extra_vars);
|
$scope.variables = '---';
|
||||||
$scope.variables = jsyaml.safeDump(json_obj);
|
try {
|
||||||
|
json_obj = JSON.parse(data.extra_vars);
|
||||||
|
$scope.variables = jsyaml.safeDump(json_obj);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
$log.info('Attempt to parse extra_vars as JSON faild. Attempting to parse as YAML');
|
||||||
|
try {
|
||||||
|
json_obj = jsyaml.safeLoad(data.extra_vars);
|
||||||
|
$scope.variables = jsyaml.safeDump(json_obj);
|
||||||
|
}
|
||||||
|
catch(e2) {
|
||||||
|
ProcessErrors($scope, data.extra_vars, e2.message, null, { hdr: 'Error!',
|
||||||
|
msg: 'Attempts to parse variables as JSON and YAML failed. Last attempt returned: ' + e2.message });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (JobTemplateForm.fields[fld].type === 'lookup' && data.summary_fields[JobTemplateForm.fields[fld].sourceModel]) {
|
if (JobTemplateForm.fields[fld].type === 'lookup' && data.summary_fields[JobTemplateForm.fields[fld].sourceModel]) {
|
||||||
|
|||||||
@@ -133,10 +133,13 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
|
|||||||
return function (scope, data, status, form, defaultMsg) {
|
return function (scope, data, status, form, defaultMsg) {
|
||||||
var field, fieldErrors, msg;
|
var field, fieldErrors, msg;
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
if ($AnsibleConfig.debug_mode && console) {
|
if ($AnsibleConfig.debug_mode) {
|
||||||
console.log('Debug status: ' + status);
|
$log.debug('Debug status: ' + status);
|
||||||
console.log('Debug data: ');
|
$log.debug('Debug data: ');
|
||||||
console.log(data);
|
$log.debug(data);
|
||||||
|
if (defaultMsg.msg) {
|
||||||
|
$log.debug('Debug: ' + defaultMsg.msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (status === 403) {
|
if (status === 403) {
|
||||||
msg = 'The API responded with a 403 Access Denied error. ';
|
msg = 'The API responded with a 403 Access Denied error. ';
|
||||||
|
|||||||
Reference in New Issue
Block a user