mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 09:51:09 +03:00
AC-995 fixed typo and added extra error handling in case we actually cannot parse inventory variables. If that does happen, we now alert the user and keep the application stable and running.
This commit is contained in:
parent
82aa0ac85d
commit
e2aef64a4d
@ -137,13 +137,25 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi
|
|||||||
if (fld == 'inventory_variables') {
|
if (fld == 'inventory_variables') {
|
||||||
// Parse variables, converting to YAML.
|
// Parse variables, converting to YAML.
|
||||||
if ($.isEmptyObject(data.variables) || data.variables == "\{\}" ||
|
if ($.isEmptyObject(data.variables) || data.variables == "\{\}" ||
|
||||||
data.variables == "null" || data.data_variables == "") {
|
data.variables == "null" || data.variables == "") {
|
||||||
scope.inventory_variables = "---";
|
scope.inventory_variables = "---";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
try {
|
||||||
var json_obj = JSON.parse(data.variables);
|
var json_obj = JSON.parse(data.variables);
|
||||||
scope.inventory_variables = jsyaml.safeDump(json_obj);
|
scope.inventory_variables = jsyaml.safeDump(json_obj);
|
||||||
}
|
}
|
||||||
|
catch(err) {
|
||||||
|
Alert('Variable Parse Error', 'Attempted to parse variables for inventory: ' + inventory_id +
|
||||||
|
'. Parse returned: ' + err);
|
||||||
|
if (console) {
|
||||||
|
console.log(err);
|
||||||
|
console.log('data:');
|
||||||
|
console.log(data.variables);
|
||||||
|
}
|
||||||
|
scope.inventory_variables = '---';
|
||||||
|
}
|
||||||
|
}
|
||||||
master.inventory_variables = scope.variables;
|
master.inventory_variables = scope.variables;
|
||||||
}
|
}
|
||||||
else if (fld == 'inventory_name') {
|
else if (fld == 'inventory_name') {
|
||||||
|
Loading…
Reference in New Issue
Block a user