diff --git a/awx/ui/static/js/controllers/Groups.js b/awx/ui/static/js/controllers/Groups.js index db67718449..aba3b95414 100644 --- a/awx/ui/static/js/controllers/Groups.js +++ b/awx/ui/static/js/controllers/Groups.js @@ -8,11 +8,9 @@ */ function InventoryGroups ($scope, $rootScope, $compile, $location, $log, $routeParams, InventoryGroupsForm, - GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, - RelatedPaginateInit, ReturnToCaller, ClearScope, LookUpInit, Prompt, - OrganizationList, TreeInit, GetBasePath, GroupsList, GroupsAdd, GroupsEdit, LoadInventory, - GroupsDelete, HostsList, HostsAdd, HostsEdit, HostsDelete, RefreshGroupName, ParseTypeChange, - HostsReload, EditInventory, RefreshTree, LoadSearchTree, EditHostGroups) + GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, Prompt, + TreeInit, GetBasePath, GroupsList, GroupsAdd, GroupsEdit, LoadInventory, + GroupsDelete, RefreshGroupName, EditInventory) { ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior //scope. @@ -38,7 +36,7 @@ function InventoryGroups ($scope, $rootScope, $compile, $location, $log, $routeP } }); - LoadInventory({ scope: scope, doPostSteps: true }); + LoadInventory({ scope: scope, doPostSteps: false }); scope.treeController = function($node) { @@ -184,11 +182,9 @@ function InventoryGroups ($scope, $rootScope, $compile, $location, $log, $routeP } -InventoryGroups.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'InventoryGroupsForm', - 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', - 'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'LookUpInit', 'Prompt', - 'OrganizationList', 'TreeInit', 'GetBasePath', 'GroupsList', 'GroupsAdd', 'GroupsEdit', 'LoadInventory', - 'GroupsDelete', 'HostsList', 'HostsAdd', 'HostsEdit', 'HostsDelete', 'RefreshGroupName', - 'ParseTypeChange', 'HostsReload', 'EditInventory', 'RefreshTree', 'LoadSearchTree', 'EditHostGroups' +InventoryGroups.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'InventoryGroupsForm', + 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'Prompt', + 'TreeInit', 'GetBasePath', 'GroupsList', 'GroupsAdd', 'GroupsEdit', 'LoadInventory', + 'GroupsDelete', 'RefreshGroupName', 'EditInventory' ]; \ No newline at end of file diff --git a/awx/ui/static/js/helpers/inventory.js b/awx/ui/static/js/helpers/inventory.js index f0b25ab4a4..18862f8e2d 100644 --- a/awx/ui/static/js/helpers/inventory.js +++ b/awx/ui/static/js/helpers/inventory.js @@ -31,6 +31,7 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi var treeData = []; // Ater inventory top-level hosts, load top-level groups + /* if (scope.inventoryLoadedRemove) { scope.inventoryLoadedRemove(); } @@ -67,6 +68,7 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi Alert('Error', 'Failed to laod tree data. Url: ' + groups + ' GET status: ' + status); }); }); + */ treeData = [{ @@ -78,7 +80,6 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi id: 'inventory-node', url: inventory_url, 'inventory_id': inventory_id, - hosts: hosts, name: inventory_name, description: inventory_descr, "data-failures": inventory.has_active_failures @@ -86,8 +87,44 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi state: 'open', children:[] }]; - scope.$emit('inventoryLoaded'); - + + function addNodes(tree, data) { + for (var i=0; i < data.length; i++) { + tree.children.push({ + data: { + title: data[i].name + }, + attr: { + id: idx, + group_id: data[i].id, + type: 'group', + name: data[i].name, + description: data[i].description, + "data-failures": data[i].has_active_failures, + inventory: data[i].inventory + }, + state: 'open', + children:[] + }); + idx++; + if (data[i].children.length > 0) { + var node = tree.children.length - 1; + addNodes(tree.children[node], data[i].children); + } + } + } + + Rest.setUrl(scope.treeData); + Rest.get() + .success( function(data, status, headers, config) { + addNodes(treeData[0], data); + scope.$emit('buildTree', treeData, idx); + }) + .error( function(data, status, headers, config) { + ProcessErrors(scope, data, status, form, + { hdr: 'Error!', msg: 'Failed to retrieve inventory tree data. GET returned status: ' + status }); + }); + } }]) @@ -127,7 +164,8 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi "select_limit": 1 }, "json_data": { - data: treeData, + data: treeData + /*, ajax: { url: function(node){ scope.selected_node = node; @@ -161,6 +199,7 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi return response; } } + */ }, "dnd": { }, "crrm": { @@ -354,7 +393,8 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi scope.TreeParams = { scope: scope, inventory: data }; scope.variable_url = data.related.variable_data; scope.relatedSets['hosts'] = { url: data.related.hosts, iterator: 'host' }; - + scope.treeData = data.related.tree; + // Load the tree view if (params.doPostSteps) { RelatedSearchInit({ scope: scope, form: form, relatedSets: scope.relatedSets }); diff --git a/awx/ui/static/js/lists/Inventories.js b/awx/ui/static/js/lists/Inventories.js index 31629fbe92..a2230cfcd8 100644 --- a/awx/ui/static/js/lists/Inventories.js +++ b/awx/ui/static/js/lists/Inventories.js @@ -63,7 +63,7 @@ angular.module('InventoriesListDefinition', []) hosts: { label: 'Hosts', ngClick: "editHosts(\{\{ inventory.id \}\})", - icon: 'icon-th-large', + icon: 'icon-laptop', "class": 'btn-xs btn-default', awToolTip: 'Edit Hosts' }, @@ -71,7 +71,7 @@ angular.module('InventoriesListDefinition', []) groups: { label: 'Groups', ngClick: "editGroups(\{\{ inventory.id \}\})", - icon: 'icon-group', + icon: 'icon-sitemap', "class": 'btn-xs btn-default', awToolTip: 'Edit Groups' }, diff --git a/awx/ui/static/lib/ansible/form-generator.js b/awx/ui/static/lib/ansible/form-generator.js index cfb8412f47..b2a5febc5d 100644 --- a/awx/ui/static/lib/ansible/form-generator.js +++ b/awx/ui/static/lib/ansible/form-generator.js @@ -1022,7 +1022,7 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies']) html += "