From 778fe0717907ab9bedc8fabd355a2676efac0bb0 Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Mon, 4 Nov 2013 15:02:06 +0000 Subject: [PATCH] AC-403 changed Host add/update to stringify variable data and include it directly in the Post or Put operation, bypassing use of host/N/variables. Now host names can include a :port. --- awx/ui/static/js/helpers/Hosts.js | 47 ++++++++++++------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/awx/ui/static/js/helpers/Hosts.js b/awx/ui/static/js/helpers/Hosts.js index 332ea82b84..c79e5edb6c 100644 --- a/awx/ui/static/js/helpers/Hosts.js +++ b/awx/ui/static/js/helpers/Hosts.js @@ -145,25 +145,20 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H data[fld] = scope[fld]; } } + data['inventory'] = inventory_id; + if ($.isEmptyObject(json_data)) { + data['variables'] = ""; + } + else { + data['variables'] = JSON.stringify(json_data, undefined, '\t'); + } + Rest.setUrl(defaultUrl); Rest.post(data) .success( function(data, status, headers, config) { - if (scope.variables) { - Rest.setUrl(data.related.variable_data); - Rest.put(json_data) - .success( function(data, status, headers, config) { - finished(); - }) - .error( function(data, status, headers, config) { - ProcessErrors(scope, data, status, form, - { hdr: 'Error!', msg: 'Failed to add host varaibles. PUT returned status: ' + status }); - }); - } - else { - finished(); - } + finished(); }) .error( function(data, status, headers, config) { scope.formModalActionDisabled = false; @@ -306,24 +301,18 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H data[fld] = scope[fld]; } data['inventory'] = inventory_id; + + if ($.isEmptyObject(json_data)) { + data['variables'] = ""; + } + else { + data['variables'] = JSON.stringify(json_data, undefined, '\t'); + } + Rest.setUrl(defaultUrl); Rest.put(data) .success( function(data, status, headers, config) { - if (scope.variables) { - //update host variables - Rest.setUrl(GetBasePath('hosts') + data.id + '/variable_data/'); - Rest.put(json_data) - .success( function(data, status, headers, config) { - finished(); - }) - .error( function(data, status, headers, config) { - ProcessErrors(scope, data, status, form, - { hdr: 'Error!', msg: 'Failed to update host varaibles. PUT returned status: ' + status }); - }); - } - else { - finished(); - } + finished(); }) .error( function(data, status, headers, config) { ProcessErrors(scope, data, status, form,