1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 09:51:09 +03:00

YAML parsing groups and hosts extra variables

YAML parsing got lost in translation in the 3.0 scuffle
This commit is contained in:
Jared Tabor 2016-10-07 14:58:31 -07:00
parent 77a56b3dfd
commit dbe6f5200f
4 changed files with 22 additions and 18 deletions

View File

@ -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

View File

@ -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 = {

View File

@ -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,

View File

@ -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