From dbe6f5200f8c4ff307d78c34e4701e673defb234 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Fri, 7 Oct 2016 14:58:31 -0700 Subject: [PATCH] YAML parsing groups and hosts extra variables YAML parsing got lost in translation in the 3.0 scuffle --- .../manage/groups/groups-add.controller.js | 11 +++++------ .../manage/groups/groups-edit.controller.js | 11 +++++++---- .../inventories/manage/hosts/hosts-add.controller.js | 9 +++++---- .../inventories/manage/hosts/hosts-edit.controller.js | 9 +++++---- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/awx/ui/client/src/inventories/manage/groups/groups-add.controller.js b/awx/ui/client/src/inventories/manage/groups/groups-add.controller.js index d1272f508b..627e253de0 100644 --- a/awx/ui/client/src/inventories/manage/groups/groups-add.controller.js +++ b/awx/ui/client/src/inventories/manage/groups/groups-add.controller.js @@ -5,10 +5,8 @@ *************************************************/ export default - ['$state', '$stateParams', '$scope', 'GroupForm', 'CredentialList', 'inventoryScriptsListObject', 'ParseTypeChange', 'GenerateForm', 'inventoryData', 'LookUpInit', - 'GroupManageService', 'GetChoices', 'GetBasePath', 'CreateSelect2', 'GetSourceTypeOptions', - function($state, $stateParams, $scope, GroupForm, CredentialList, InventoryScriptsList, ParseTypeChange, GenerateForm, inventoryData, LookUpInit, - GroupManageService, GetChoices, GetBasePath, CreateSelect2, GetSourceTypeOptions){ + ['$state', '$stateParams', '$scope', 'GroupForm', 'CredentialList', 'inventoryScriptsListObject', 'ParseTypeChange', 'GenerateForm', 'inventoryData', 'LookUpInit', 'GroupManageService', 'GetChoices', 'GetBasePath', 'CreateSelect2', 'GetSourceTypeOptions','ToJSON', + function($state, $stateParams, $scope, GroupForm, CredentialList, InventoryScriptsList, ParseTypeChange, GenerateForm, inventoryData, LookUpInit, GroupManageService, GetChoices, GetBasePath, CreateSelect2, GetSourceTypeOptions, ToJSON){ var generator = GenerateForm, form = GroupForm(); @@ -20,10 +18,11 @@ $state.go('^'); }; $scope.formSave = function(){ - var params, source; + var params, source, + json_data = ToJSON($scope.parseType, $scope.variables, true); // group fields var group = { - variables: $scope.variables === '---' || $scope.variables === '{}' ? null : $scope.variables, + variables: json_data, name: $scope.name, description: $scope.description, inventory: inventoryData.id diff --git a/awx/ui/client/src/inventories/manage/groups/groups-edit.controller.js b/awx/ui/client/src/inventories/manage/groups/groups-edit.controller.js index 941789f39d..2b7deefad4 100644 --- a/awx/ui/client/src/inventories/manage/groups/groups-edit.controller.js +++ b/awx/ui/client/src/inventories/manage/groups/groups-edit.controller.js @@ -7,10 +7,10 @@ export default ['$state', '$stateParams', '$scope', 'GroupForm', 'CredentialList', 'inventoryScriptsListObject', 'ToggleNotification', 'ParseVariableString', 'ParseTypeChange', 'GenerateForm', 'LookUpInit', 'RelatedSearchInit', 'RelatedPaginateInit', 'NotificationsListInit', - 'GroupManageService','GetChoices', 'GetBasePath', 'CreateSelect2', 'GetSourceTypeOptions', 'groupData', 'inventorySourceData', + 'GroupManageService','GetChoices', 'GetBasePath', 'CreateSelect2', 'GetSourceTypeOptions', 'groupData', 'inventorySourceData', 'ToJSON', function($state, $stateParams, $scope, GroupForm, CredentialList, InventoryScriptsList, ToggleNotification, ParseVariableString, ParseTypeChange, GenerateForm, LookUpInit, RelatedSearchInit, RelatedPaginateInit, NotificationsListInit, - GroupManageService, GetChoices, GetBasePath, CreateSelect2, GetSourceTypeOptions, groupData, inventorySourceData){ + GroupManageService, GetChoices, GetBasePath, CreateSelect2, GetSourceTypeOptions, groupData, inventorySourceData, ToJSON){ var generator = GenerateForm, form = GroupForm(); @@ -22,15 +22,18 @@ $state.go('^'); }; $scope.formSave = function(){ - var params, source; + var params, source, + json_data = ToJSON($scope.parseType, $scope.variables, true); + // group fields var group = { - variables: $scope.variables === '---' || $scope.variables === '{}' ? null : $scope.variables, + variables: json_data, name: $scope.name, description: $scope.description, inventory: $scope.inventory, id: groupData.id }; + if ($scope.source){ // inventory_source fields params = { diff --git a/awx/ui/client/src/inventories/manage/hosts/hosts-add.controller.js b/awx/ui/client/src/inventories/manage/hosts/hosts-add.controller.js index d0dd6c3c86..1958a24353 100644 --- a/awx/ui/client/src/inventories/manage/hosts/hosts-add.controller.js +++ b/awx/ui/client/src/inventories/manage/hosts/hosts-add.controller.js @@ -5,8 +5,8 @@ *************************************************/ export default - ['$state', '$stateParams', '$scope', 'HostForm', 'ParseTypeChange', 'GenerateForm', 'HostManageService', - function($state, $stateParams, $scope, HostForm, ParseTypeChange, GenerateForm, HostManageService){ + ['$state', '$stateParams', '$scope', 'HostForm', 'ParseTypeChange', 'GenerateForm', 'HostManageService', 'ToJSON', + function($state, $stateParams, $scope, HostForm, ParseTypeChange, GenerateForm, HostManageService, ToJSON){ var generator = GenerateForm, form = HostForm; $scope.parseType = 'yaml'; @@ -17,8 +17,9 @@ $scope.host.enabled = !$scope.host.enabled; }; $scope.formSave = function(){ - var params = { - variables: $scope.variables === '---' || $scope.variables === '{}' ? null : $scope.variables, + var json_data = ToJSON($scope.parseType, $scope.variables, true), + params = { + variables: json_data,// $scope.variables === '---' || $scope.variables === '{}' ? null : $scope.variables, name: $scope.name, description: $scope.description, enabled: $scope.host.enabled, diff --git a/awx/ui/client/src/inventories/manage/hosts/hosts-edit.controller.js b/awx/ui/client/src/inventories/manage/hosts/hosts-edit.controller.js index bc96df0eaf..7480349505 100644 --- a/awx/ui/client/src/inventories/manage/hosts/hosts-edit.controller.js +++ b/awx/ui/client/src/inventories/manage/hosts/hosts-edit.controller.js @@ -5,8 +5,8 @@ *************************************************/ export default - ['$state', '$stateParams', '$scope', 'HostForm', 'ParseTypeChange', 'GenerateForm', 'HostManageService', 'host', 'ParseVariableString', - function($state, $stateParams, $scope, HostForm, ParseTypeChange, GenerateForm, HostManageService, host, ParseVariableString){ + ['$state', '$stateParams', '$scope', 'HostForm', 'ParseTypeChange', 'GenerateForm', 'HostManageService', 'host', 'ParseVariableString', 'ToJSON', + function($state, $stateParams, $scope, HostForm, ParseTypeChange, GenerateForm, HostManageService, host, ParseVariableString, ToJSON){ var generator = GenerateForm, form = HostForm; $scope.parseType = 'yaml'; @@ -17,9 +17,10 @@ $scope.host.enabled = !$scope.host.enabled; }; $scope.formSave = function(){ - var host = { + var json_data = ToJSON($scope.parseType, $scope.variables, true), + host = { id: $scope.host.id, - variables: $scope.variables === '---' || $scope.variables === '{}' ? null : $scope.variables, + variables: json_data, name: $scope.name, description: $scope.description, enabled: $scope.host.enabled