From f38a5e56729fdb4ffd55db7f32b8aa8fe161b78a Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Tue, 2 May 2017 10:55:43 -0400 Subject: [PATCH 1/2] Fixed various inventory related bugs --- .../src/inventories/adhoc/adhoc.route.js | 3 +++ .../edit/inventory-edit.controller.js | 2 +- .../src/inventories/groups/groups.form.js | 4 ++++ .../nested-groups-list.controller.js | 2 +- .../nested-hosts-list.controller.js | 2 +- .../groups/nested-hosts/nested-hosts.form.js | 6 ++++++ .../client/src/inventories/hosts/host.form.js | 7 ++++++- .../client/src/inventories/inventory.form.js | 6 ++++++ .../related-hosts/related-host.form.js | 6 ++++++ .../sources/add/sources-add.controller.js | 10 +-------- .../sources/edit/sources-edit.controller.js | 14 ++----------- .../src/inventories/sources/sources.form.js | 21 ------------------- awx/ui/client/src/shared/form-generator.js | 8 +++---- 13 files changed, 41 insertions(+), 50 deletions(-) diff --git a/awx/ui/client/src/inventories/adhoc/adhoc.route.js b/awx/ui/client/src/inventories/adhoc/adhoc.route.js index 392de3965e..19eb396296 100644 --- a/awx/ui/client/src/inventories/adhoc/adhoc.route.js +++ b/awx/ui/client/src/inventories/adhoc/adhoc.route.js @@ -15,6 +15,9 @@ export default { squash: true } }, + data: { + formChildState: true + }, name: 'inventories.edit.adhoc', views: { 'adhocForm@inventories': { diff --git a/awx/ui/client/src/inventories/edit/inventory-edit.controller.js b/awx/ui/client/src/inventories/edit/inventory-edit.controller.js index 0558be203a..3e449f2cd0 100644 --- a/awx/ui/client/src/inventories/edit/inventory-edit.controller.js +++ b/awx/ui/client/src/inventories/edit/inventory-edit.controller.js @@ -13,7 +13,7 @@ function InventoriesEdit($scope, $location, $stateParams, InventoryForm, Rest, ProcessErrors, ClearScope, GetBasePath, ParseTypeChange, Wait, ToJSON, - ParseVariableString, $state, OrgAdminLookup) { + ParseVariableString, $state, OrgAdminLookup) {$scope.$state = $state; // Inject dynamic view var defaultUrl = GetBasePath('inventory'), diff --git a/awx/ui/client/src/inventories/groups/groups.form.js b/awx/ui/client/src/inventories/groups/groups.form.js index 4f6a178a71..6a15edd02e 100644 --- a/awx/ui/client/src/inventories/groups/groups.form.js +++ b/awx/ui/client/src/inventories/groups/groups.form.js @@ -83,6 +83,8 @@ function(i18n, nestedGroupListState, nestedHostsListState, buildHostAddState){ related: { nested_groups: { name: 'nested_groups', + awToolTip: i18n._('Please save before defining groups'), + dataPlacement: 'top', ngClick: "$state.go('inventories.edit.groups.edit.nested_groups')", include: "NestedGroupListDefinition", includeForm: "NestedGroupFormDefinition", @@ -92,6 +94,8 @@ function(i18n, nestedGroupListState, nestedHostsListState, buildHostAddState){ }, nested_hosts: { name: 'nested_hosts', + awToolTip: i18n._('Please save before defining hosts'), + dataPlacement: 'top', ngClick: "$state.go('inventories.edit.groups.edit.nested_hosts')", include: "NestedHostsListDefinition", title: i18n._('Hosts'), diff --git a/awx/ui/client/src/inventories/groups/nested-groups/nested-groups-list.controller.js b/awx/ui/client/src/inventories/groups/nested-groups/nested-groups-list.controller.js index 237757efa8..1bcf0824c6 100644 --- a/awx/ui/client/src/inventories/groups/nested-groups/nested-groups-list.controller.js +++ b/awx/ui/client/src/inventories/groups/nested-groups/nested-groups-list.controller.js @@ -167,7 +167,7 @@ return item.name; }).value().join(':'); - $state.go('^.adhoc', {pattern: pattern}); + $state.go('^.^.^.adhoc', {pattern: pattern}); }; }]; diff --git a/awx/ui/client/src/inventories/groups/nested-hosts/nested-hosts-list.controller.js b/awx/ui/client/src/inventories/groups/nested-hosts/nested-hosts-list.controller.js index 20196b1647..39b8ee6660 100644 --- a/awx/ui/client/src/inventories/groups/nested-hosts/nested-hosts-list.controller.js +++ b/awx/ui/client/src/inventories/groups/nested-hosts/nested-hosts-list.controller.js @@ -153,7 +153,7 @@ export default ['$scope', 'NestedHostsListDefinition', '$rootScope', 'GetBasePat return item.name; }).value().join(':'); - $state.go('^.adhoc', {pattern: pattern}); + $state.go('^.^.^.adhoc', {pattern: pattern}); }; $scope.copyMoveHost = function(id) { diff --git a/awx/ui/client/src/inventories/groups/nested-hosts/nested-hosts.form.js b/awx/ui/client/src/inventories/groups/nested-hosts/nested-hosts.form.js index d2ffe33e05..56fe871d7a 100644 --- a/awx/ui/client/src/inventories/groups/nested-hosts/nested-hosts.form.js +++ b/awx/ui/client/src/inventories/groups/nested-hosts/nested-hosts.form.js @@ -107,11 +107,15 @@ function(i18n, nestedGroupListState) { related: { ansible_facts: { name: 'ansible_facts', + awToolTip: i18n._('Please save before viewing facts'), + dataPlacement: 'top', title: i18n._('Facts'), skipGenerator: true }, nested_groups: { name: 'nested_groups', + awToolTip: i18n._('Please save before defining groups'), + dataPlacement: 'top', ngClick: "$state.go('inventories.edit.groups.edit.nested_hosts.edit.nested_groups')", include: "NestedGroupListDefinition", includeForm: "NestedGroupFormDefinition", @@ -121,6 +125,8 @@ function(i18n, nestedGroupListState) { }, insights: { name: 'insights', + awToolTip: i18n._('Please save before viewing Insights'), + dataPlacement: 'top', title: i18n._('Insights'), skipGenerator: true } diff --git a/awx/ui/client/src/inventories/hosts/host.form.js b/awx/ui/client/src/inventories/hosts/host.form.js index fdc8df1d56..93f381c1f3 100644 --- a/awx/ui/client/src/inventories/hosts/host.form.js +++ b/awx/ui/client/src/inventories/hosts/host.form.js @@ -106,12 +106,15 @@ function(i18n, nestedGroupListState) { related: { ansible_facts: { name: 'ansible_facts', + awToolTip: i18n._('Please save before viewing facts'), + dataPlacement: 'top', title: i18n._('Facts'), skipGenerator: true }, nested_groups: { name: 'nested_groups', - // ngClick: "$state.go('hosts.edit.nested_groups')", + awToolTip: i18n._('Please save before defining groups'), + dataPlacement: 'top', ngClick: "groupsTab()", include: "NestedGroupListDefinition", includeForm: "NestedGroupFormDefinition", @@ -121,6 +124,8 @@ function(i18n, nestedGroupListState) { }, insights: { name: 'insights', + awToolTip: i18n._('Please save before viewing Insights'), + dataPlacement: 'top', title: i18n._('Insights'), skipGenerator: true } diff --git a/awx/ui/client/src/inventories/inventory.form.js b/awx/ui/client/src/inventories/inventory.form.js index 822f561163..270511f06c 100644 --- a/awx/ui/client/src/inventories/inventory.form.js +++ b/awx/ui/client/src/inventories/inventory.form.js @@ -159,6 +159,8 @@ function(i18n, buildGroupsListState, buildGroupsAddState, buildGroupsEditState, }, groups: { name: 'groups', + awToolTip: i18n._('Please save before creating groups'), + dataPlacement: 'top', include: "GroupList", title: i18n._('Groups'), iterator: 'group', @@ -168,6 +170,8 @@ function(i18n, buildGroupsListState, buildGroupsAddState, buildGroupsEditState, }, hosts: { name: 'hosts', + awToolTip: i18n._('Please save before creating hosts'), + dataPlacement: 'top', include: "RelatedHostsListDefinition", title: i18n._('Hosts'), iterator: 'host', @@ -177,6 +181,8 @@ function(i18n, buildGroupsListState, buildGroupsAddState, buildGroupsEditState, }, inventory_sources: { name: 'inventory_sources', + awToolTip: i18n._('Please save before defining inventory sources'), + dataPlacement: 'top', include: "SourcesListDefinition", includeForm: "SourcesFormDefinition", title: i18n._('Sources'), diff --git a/awx/ui/client/src/inventories/related-hosts/related-host.form.js b/awx/ui/client/src/inventories/related-hosts/related-host.form.js index 9e7d30927b..0e71a6f0bb 100644 --- a/awx/ui/client/src/inventories/related-hosts/related-host.form.js +++ b/awx/ui/client/src/inventories/related-hosts/related-host.form.js @@ -107,11 +107,15 @@ function(i18n,nestedGroupListState) { related: { ansible_facts: { name: 'ansible_facts', + awToolTip: i18n._('Please save before viewing facts'), + dataPlacement: 'top', title: i18n._('Facts'), skipGenerator: true }, nested_groups: { name: 'nested_groups', + awToolTip: i18n._('Please save before defining groups'), + dataPlacement: 'top', ngClick: "$state.go('inventories.edit.hosts.edit.nested_groups')", include: "NestedGroupListDefinition", includeForm: "NestedGroupFormDefinition", @@ -121,6 +125,8 @@ function(i18n,nestedGroupListState) { }, insights: { name: 'insights', + awToolTip: i18n._('Please save before viewing Insights'), + dataPlacement: 'top', title: i18n._('Insights'), skipGenerator: true } diff --git a/awx/ui/client/src/inventories/sources/add/sources-add.controller.js b/awx/ui/client/src/inventories/sources/add/sources-add.controller.js index ad98656eec..806f850f4c 100644 --- a/awx/ui/client/src/inventories/sources/add/sources-add.controller.js +++ b/awx/ui/client/src/inventories/sources/add/sources-add.controller.js @@ -24,13 +24,7 @@ export default ['$state', '$stateParams', '$scope', 'SourcesFormDefinition', .then(function(canAdd) { $scope.canAdd = canAdd; }); - $scope.parseType = 'yaml'; $scope.envParseType = 'yaml'; - ParseTypeChange({ - scope: $scope, - field_id: 'inventory_source_variables', - variable: 'variables', - }); initSources(); } @@ -50,8 +44,7 @@ export default ['$state', '$stateParams', '$scope', 'SourcesFormDefinition', }; $scope.formSave = function() { - var params, json_data; - json_data = ToJSON($scope.parseType, $scope.variables, true); + var params; params = { name: $scope.name, @@ -64,7 +57,6 @@ export default ['$state', '$stateParams', '$scope', 'SourcesFormDefinition', overwrite_vars: $scope.overwrite_vars, update_on_launch: $scope.update_on_launch, update_cache_timeout: $scope.update_cache_timeout || 0, - variables: json_data, // comma-delimited strings group_by: _.map($scope.group_by, 'value').join(','), source_regions: _.map($scope.source_regions, 'value').join(',') diff --git a/awx/ui/client/src/inventories/sources/edit/sources-edit.controller.js b/awx/ui/client/src/inventories/sources/edit/sources-edit.controller.js index 220e89a0f9..98517f9e56 100644 --- a/awx/ui/client/src/inventories/sources/edit/sources-edit.controller.js +++ b/awx/ui/client/src/inventories/sources/edit/sources-edit.controller.js @@ -36,17 +36,8 @@ export default ['$state', '$stateParams', '$scope', 'ParseVariableString', $scope.canAdd = val; }); - // init codemirror(s) - $scope.variables = $scope.variables === null || $scope.variables === '' ? '---' : ParseVariableString($scope.variables); - $scope.parseType = 'yaml'; $scope.envParseType = 'yaml'; - ParseTypeChange({ - scope: $scope, - field_id: 'inventory_source_variables', - variable: 'variables', - }); - initSources(); } @@ -76,10 +67,10 @@ export default ['$state', '$stateParams', '$scope', 'ParseVariableString', $state.go('^'); }; $scope.formSave = function() { - var params, json_data; - json_data = ToJSON($scope.parseType, $scope.variables, true); + var params; params = { + id: inventorySourceData.id, name: $scope.name, description: $scope.description, inventory: inventoryData.id, @@ -90,7 +81,6 @@ export default ['$state', '$stateParams', '$scope', 'ParseVariableString', overwrite_vars: $scope.overwrite_vars, update_on_launch: $scope.update_on_launch, update_cache_timeout: $scope.update_cache_timeout || 0, - variables: json_data, // comma-delimited strings group_by: _.map($scope.group_by, 'value').join(','), source_regions: _.map($scope.source_regions, 'value').join(',') diff --git a/awx/ui/client/src/inventories/sources/sources.form.js b/awx/ui/client/src/inventories/sources/sources.form.js index 32968fc3db..20ef58bae1 100644 --- a/awx/ui/client/src/inventories/sources/sources.form.js +++ b/awx/ui/client/src/inventories/sources/sources.form.js @@ -38,27 +38,6 @@ export default { ngDisabled: '!(group_obj.summary_fields.user_capabilities.edit || canAdd)', tab: 'properties' }, - variables: { - label: 'Variables', - type: 'textarea', - class: 'Form-textAreaLabel Form-formGroup--fullWidth', - rows: 6, - 'default': '---', - dataTitle: 'Group Variables', - dataPlacement: 'right', - parseTypeName: 'parseType', - awPopOver: "

Variables defined here apply to all child groups and hosts.

" + - "

Enter variables using either JSON or YAML syntax. Use the " + - "radio button to toggle between the two.

" + - "JSON:
\n" + - "
{
  \"somevar\": \"somevalue\",
 \"password\": \"magic\"
}
\n" + - "YAML:
\n" + - "
---
somevar: somevalue
password: magic
\n" + - '

View JSON examples at www.json.org

' + - '

View YAML examples at docs.ansible.com

', - dataContainer: 'body', - tab: 'properties' - }, source: { label: 'Source', type: 'select', diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js index 8691596e52..5206f8221e 100644 --- a/awx/ui/client/src/shared/form-generator.js +++ b/awx/ui/client/src/shared/form-generator.js @@ -1560,9 +1560,9 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat for (itm in this.form.related) { collection = this.form.related[itm]; - html += "
" + (collection.title || collection.editTitle) + "
\n"; } @@ -1676,7 +1676,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat html += "
Date: Tue, 2 May 2017 11:40:16 -0400 Subject: [PATCH 2/2] Removed extra debug line --- awx/ui/client/src/inventories/edit/inventory-edit.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/client/src/inventories/edit/inventory-edit.controller.js b/awx/ui/client/src/inventories/edit/inventory-edit.controller.js index 3e449f2cd0..0558be203a 100644 --- a/awx/ui/client/src/inventories/edit/inventory-edit.controller.js +++ b/awx/ui/client/src/inventories/edit/inventory-edit.controller.js @@ -13,7 +13,7 @@ function InventoriesEdit($scope, $location, $stateParams, InventoryForm, Rest, ProcessErrors, ClearScope, GetBasePath, ParseTypeChange, Wait, ToJSON, - ParseVariableString, $state, OrgAdminLookup) {$scope.$state = $state; + ParseVariableString, $state, OrgAdminLookup) { // Inject dynamic view var defaultUrl = GetBasePath('inventory'),