mirror of
https://github.com/ansible/awx.git
synced 2026-02-21 05:00:07 -03:30
Added variable data fied to Host detail page. Save/edit work -made changes in the Hosts controller for this. Still need to validate text blob is valid JSON.
This commit is contained in:
@@ -168,18 +168,33 @@ function HostsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
Rest.setUrl(defaultUrl);
|
||||
var data = {}
|
||||
for (var fld in form.fields) {
|
||||
data[fld] = scope[fld];
|
||||
if (fld != 'varaibles') {
|
||||
data[fld] = scope[fld];
|
||||
}
|
||||
}
|
||||
if ($routeParams.inventory_id) {
|
||||
data['inventory'] = $routeParams.inventory_id;
|
||||
}
|
||||
Rest.post(data)
|
||||
.success( function(data, status, headers, config) {
|
||||
ReturnToCaller(1);
|
||||
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 });
|
||||
{ hdr: 'Error!', msg: 'Failed to add new host. POST returned status: ' + status });
|
||||
});
|
||||
};
|
||||
|
||||
@@ -217,6 +232,21 @@ function HostsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
for (var set in relatedSets) {
|
||||
scope.search(relatedSets[set].iterator);
|
||||
}
|
||||
if (scope.variable_url) {
|
||||
Rest.setUrl(scope.variable_url);
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
scope.variables = data.data;
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
scope.variables = null;
|
||||
ProcessErrors(scope, data, status, form,
|
||||
{ hdr: 'Error!', msg: 'Failed to retrieve host variables. GET returned status: ' + status });
|
||||
});
|
||||
}
|
||||
else {
|
||||
scope.variables = null;
|
||||
}
|
||||
});
|
||||
|
||||
// Retrieve detail record and prepopulate the form
|
||||
@@ -236,6 +266,7 @@ function HostsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
relatedSets[set] = { url: related[set], iterator: form.related[set].iterator };
|
||||
}
|
||||
}
|
||||
scope.variable_url = data.related.variable_data;
|
||||
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
||||
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
||||
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
|
||||
@@ -255,7 +286,20 @@ function HostsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
}
|
||||
Rest.put(data)
|
||||
.success( function(data, status, headers, config) {
|
||||
(base == 'hosts') ? ReturnToCaller() : ReturnToCaller(1);
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user