Got our custom tree working on both the Groups page and the Hosts page.

This commit is contained in:
chouseknecht
2013-10-21 15:15:12 -04:00
parent 8bd00cfacb
commit 4cf47bfa9e
5 changed files with 98 additions and 30 deletions

View File

@@ -33,7 +33,6 @@ function InventoryGroups ($scope, $rootScope, $compile, $location, $log, $routeP
}
scope.inventoryLoadedRemove = scope.$on('inventoryLoaded', function() {
LoadBreadCrumbs({ path: '/inventories/' + id, title: scope.inventory_name });
//TreeInit(scope.TreeParams);
BuildTree({
scope: scope,
inventory_id: id,

View File

@@ -13,10 +13,10 @@ function InventoryHosts ($scope, $rootScope, $compile, $location, $log, $routePa
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit,
RelatedPaginateInit, ReturnToCaller, ClearScope, LookUpInit, Prompt,
GetBasePath, HostsList, HostsAdd, HostsEdit, HostsDelete,
HostsReload, LoadSearchTree, EditHostGroups, InventoryHostsHelp, HelpDialog)
HostsReload, BuildTree, EditHostGroups, InventoryHostsHelp, HelpDialog)
{
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope.
//scope.
var generator = GenerateForm;
var form = InventoryHostsForm;
@@ -31,6 +31,7 @@ function InventoryHosts ($scope, $rootScope, $compile, $location, $log, $routePa
scope['hosts'] = null;
scope['helpCount'] = 0;
// buildAllGroups emits from TreeSelector.js after the inventory object is ready
if (scope.loadBreadCrumbsRemove) {
scope.loadBreadCrumbsRemove();
}
@@ -38,10 +39,6 @@ function InventoryHosts ($scope, $rootScope, $compile, $location, $log, $routePa
LoadBreadCrumbs({ path: '/inventories/' + id, title: inventory_name });
});
// Sets up the search tree and loads All Hosts for the inventory
LoadSearchTree({ scope: scope, inventory_id: scope['inventory_id'] });
scope.filterHosts = function() {
HostsReload({ scope: scope, inventory_id: scope['inventory_id'], group_id: scope['group_id'] });
}
@@ -112,11 +109,11 @@ function InventoryHosts ($scope, $rootScope, $compile, $location, $log, $routePa
HelpDialog({ defn: InventoryHostsHelp });
}
// Respond to the scope.$emit from awTree directive
// Refresh host is emitted each time a group on the selector tree is clicked
if (scope.refreshHostRemove) {
scope.refreshHostRemove();
}
scope.refreshHostRemove = scope.$on('refreshHost', function(e, group, title) {
scope.refreshHostRemove = scope.$on('refreshHost', function(e, id, group, title) {
scope.groupTitle = title;
scope.group_id = group;
scope.helpCount++;
@@ -135,12 +132,21 @@ function InventoryHosts ($scope, $rootScope, $compile, $location, $log, $routePa
scope['hostDeleteDisabledClass'] = 'disabled';
HostsReload({ scope: scope, inventory_id: scope['inventory_id'], group_id: group });
});
// Load the tree. See TreeSelector.js
BuildTree({
scope: scope,
inventory_id: id,
emit_on_select: 'refreshHost',
target_id: 'search-tree-container'
});
}
InventoryHosts.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'InventoryHostsForm',
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit',
'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'LookUpInit', 'Prompt',
'GetBasePath', 'HostsList', 'HostsAdd', 'HostsEdit', 'HostsDelete',
'HostsReload', 'LoadSearchTree', 'EditHostGroups', 'InventoryHostsHelp', 'HelpDialog'
'HostsReload', 'BuildTree', 'EditHostGroups', 'InventoryHostsHelp', 'HelpDialog'
];