mirror of
https://github.com/ansible/awx.git
synced 2026-06-26 17:08:03 -02:30
Group and Host variables working.
This commit is contained in:
@@ -175,27 +175,35 @@ function HostsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
if ($routeParams.inventory_id) {
|
||||
data['inventory'] = $routeParams.inventory_id;
|
||||
}
|
||||
Rest.post(data)
|
||||
.success( function(data, status, headers, config) {
|
||||
if (scope.variables) {
|
||||
Rest.setUrl(GetBasePath('hosts') + data.id + '/variable_data/');
|
||||
Rest.post({data: scope.variables})
|
||||
.success( function(data, status, headers, config) {
|
||||
ReturnToCaller(1);
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
ProcessErrors(scope, data, status, form,
|
||||
{ hdr: 'Error!', msg: 'Failed to add host varaibles. POST returned status: ' + status });
|
||||
});
|
||||
}
|
||||
else {
|
||||
ReturnToCaller(1);
|
||||
}
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
ProcessErrors(scope, data, status, form,
|
||||
{ hdr: 'Error!', msg: 'Failed to add new host. POST returned status: ' + status });
|
||||
});
|
||||
try {
|
||||
// Make sure we have valid JSON
|
||||
var myjson = JSON.parse(scope.variables);
|
||||
Rest.post(data)
|
||||
.success( function(data, status, headers, config) {
|
||||
if (scope.variables) {
|
||||
Rest.setUrl(data.related.variable_data);
|
||||
Rest.put({data: scope.variables})
|
||||
.success( function(data, status, headers, config) {
|
||||
ReturnToCaller(1);
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
ProcessErrors(scope, data, status, form,
|
||||
{ hdr: 'Error!', msg: 'Failed to add host varaibles. POST returned status: ' + status });
|
||||
});
|
||||
}
|
||||
else {
|
||||
ReturnToCaller(1);
|
||||
}
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
ProcessErrors(scope, data, status, form,
|
||||
{ hdr: 'Error!', msg: 'Failed to add new host. POST returned status: ' + status });
|
||||
});
|
||||
}
|
||||
catch(err) {
|
||||
Alert("Error", "Error parsing host variables. Expecting valid JSON. Parser returned " + err);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Cancel
|
||||
@@ -236,7 +244,12 @@ function HostsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
Rest.setUrl(scope.variable_url);
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
scope.variables = data.data;
|
||||
if ($.isEmptyObject(data.data)) {
|
||||
scope.variables = "\{\}";
|
||||
}
|
||||
else {
|
||||
scope.variables = data.data;
|
||||
}
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
scope.variables = null;
|
||||
@@ -245,7 +258,7 @@ function HostsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
});
|
||||
}
|
||||
else {
|
||||
scope.variables = null;
|
||||
scope.variables = "\{\}";
|
||||
}
|
||||
});
|
||||
|
||||
@@ -283,28 +296,37 @@ function HostsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
var data = {}
|
||||
for (var fld in form.fields) {
|
||||
data[fld] = scope[fld];
|
||||
}
|
||||
Rest.put(data)
|
||||
.success( function(data, status, headers, config) {
|
||||
if (scope.variables) {
|
||||
Rest.setUrl(GetBasePath('hosts') + data.id + '/variable_data/');
|
||||
Rest.put({data: scope.variables})
|
||||
.success( function(data, status, headers, config) {
|
||||
(base == 'hosts') ? ReturnToCaller() : ReturnToCaller(1);
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
ProcessErrors(scope, data, status, form,
|
||||
{ hdr: 'Error!', msg: 'Failed to update host varaibles. PUT returned status: ' + status });
|
||||
});
|
||||
}
|
||||
else {
|
||||
(base == 'hosts') ? ReturnToCaller() : ReturnToCaller(1);
|
||||
}
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
ProcessErrors(scope, data, status, form,
|
||||
{ hdr: 'Error!', msg: 'Failed to update host: ' + id + '. PUT status: ' + status });
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
// Make sure we have valid JSON
|
||||
var myjson = JSON.parse(scope.variables);
|
||||
Rest.put(data)
|
||||
.success( function(data, status, headers, config) {
|
||||
if (scope.variables) {
|
||||
Rest.setUrl(GetBasePath('hosts') + data.id + '/variable_data/');
|
||||
Rest.put({data: scope.variables})
|
||||
.success( function(data, status, headers, config) {
|
||||
(base == 'hosts') ? ReturnToCaller() : ReturnToCaller(1);
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
ProcessErrors(scope, data, status, form,
|
||||
{ hdr: 'Error!', msg: 'Failed to update host varaibles. PUT returned status: ' + status });
|
||||
});
|
||||
}
|
||||
else {
|
||||
(base == 'hosts') ? ReturnToCaller() : ReturnToCaller(1);
|
||||
}
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
ProcessErrors(scope, data, status, form,
|
||||
{ hdr: 'Error!', msg: 'Failed to update host: ' + id + '. PUT status: ' + status });
|
||||
});
|
||||
}
|
||||
catch(err) {
|
||||
Alert("Error", "Error parsing host variables. Expecting valid JSON. Parser returned " + err);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Cancel
|
||||
|
||||
Reference in New Issue
Block a user