From da766edd5278b484a2d551eb9ea003374ae1c9b4 Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Wed, 4 Jun 2014 11:45:11 -0400 Subject: [PATCH] Inventory refactor bug Calculating initial container heights and rowsize on the inventory page was not working correctly on first page load. Issue was misalignment of function declaration and injector. Also needed to add e.stopPropagtion() call in the search helper. Without it the group search refresh gets called multiple times whenever the host list is refreshed. --- awx/ui/static/js/controllers/Inventories.js | 23 +++++++++++++++++++-- awx/ui/static/js/helpers/Hosts.js | 2 +- awx/ui/static/js/helpers/inventory.js | 16 +++++++++++++- awx/ui/static/js/helpers/search.js | 5 ++++- 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/awx/ui/static/js/controllers/Inventories.js b/awx/ui/static/js/controllers/Inventories.js index 6fd489bedb..252acb5e2e 100644 --- a/awx/ui/static/js/controllers/Inventories.js +++ b/awx/ui/static/js/controllers/Inventories.js @@ -534,6 +534,26 @@ function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateLis } }); + if ($scope.removeRowCountReady) { + $scope.removeRowCountReady(); + } + $scope.removeRowCountReady = $scope.$on('RowCountReady', function(e, rows) { + // Add hosts view + $scope.show_failures = false; + InjectHosts({ + group_scope: $scope, + host_scope: hostScope, + inventory_id: $scope.inventory.id, + tree_id: null, + group_id: null, + pageSize: rows + }); + + SearchInit({ scope: $scope, set: 'groups', list: InventoryGroups, url: $scope.inventory.related.root_groups }); + PaginateInit({ scope: $scope, list: InventoryGroups , url: $scope.inventory.related.root_groups, pageSize: rows }); + $scope.search(InventoryGroups.iterator, null, true); + }); + if ($scope.removeInventoryLoaded) { $scope.removeInventoryLoaded(); } @@ -570,7 +590,6 @@ function InventoriesEdit ($scope, $location, $routeParams, $compile, GenerateLis hostScope.host_page_size = rows; $scope.group_page_size = rows; - // Add hosts view $scope.show_failures = false; InjectHosts({ group_scope: $scope, @@ -965,5 +984,5 @@ InventoriesEdit.$inject = ['$scope', '$location', '$routeParams', '$compile', 'G 'GetBasePath', 'ProcessErrors', 'Breadcrumbs', 'InventoryGroups', 'InjectHosts', 'Find', 'HostsReload', 'SearchInit', 'PaginateInit', 'GetSyncStatusMsg', 'GetHostsStatusMsg', 'GroupsEdit', 'InventoryUpdate', 'GroupsCancelUpdate', 'ViewUpdateStatus', 'GroupsDelete', 'Store', 'HostsEdit', 'HostsDelete', 'EditInventoryProperties', 'ToggleHostEnabled', 'Stream', 'ShowJobSummary', 'InventoryGroupsHelp', 'HelpDialog', 'ViewJob', 'WatchInventoryWindowResize', - 'SetContainerHeights', 'GetHostContainerRows', 'GetGroupContainerRows', 'GetGroupContainerHeight', 'GroupsCopy', 'HostsCopy' + 'GetHostContainerRows', 'GetGroupContainerRows', 'GetGroupContainerHeight', 'GroupsCopy', 'HostsCopy' ]; \ No newline at end of file diff --git a/awx/ui/static/js/helpers/Hosts.js b/awx/ui/static/js/helpers/Hosts.js index 8353857e07..10a52333bf 100644 --- a/awx/ui/static/js/helpers/Hosts.js +++ b/awx/ui/static/js/helpers/Hosts.js @@ -237,7 +237,7 @@ function(GenerateList, InventoryHosts, HostsReload) { generator.inject(InventoryHosts, { scope: host_scope, mode: 'edit', id: 'hosts-container', breadCrumbs: false, searchSize: 'col-lg-6 col-md-6 col-sm-6' }); // Load data - HostsReload({ scope: host_scope, group_id: group_id, inventory_id: inventory_id, parent_scope: group_scope, cpageSize: pageSize }); + HostsReload({ scope: host_scope, group_id: group_id, inventory_id: inventory_id, parent_scope: group_scope, pageSize: pageSize }); }; }]) diff --git a/awx/ui/static/js/helpers/inventory.js b/awx/ui/static/js/helpers/inventory.js index 759e0eda76..1b5bf4cbee 100644 --- a/awx/ui/static/js/helpers/inventory.js +++ b/awx/ui/static/js/helpers/inventory.js @@ -17,8 +17,22 @@ angular.module('InventoryHelper', ['RestServices', 'Utilities', 'OrganizationLis .factory('GetGroupContainerHeight', [ function() { return function() { + + /*console.log('window height: ' + $(window).height()); + console.log('main-menu: ' + $('.main-menu').outerHeight()); + console.log('main_tabs: ' + $('#main_tabs').outerHeight()); + console.log('breadcrumbs: ' + $('#breadcrumbs').outerHeight()); + console.log('footer: ' + $('.site-footer').outerHeight()); + console.log('group-breadcrumbs: ' + $('.group-breadcrumbs').outerHeight()); + console.log('searchwidget: ' + $('#groups-container #search-widget-container').outerHeight()); + console.log('group table head: ' + $('#groups_table thead').height()); + console.log('subtotal: ' + ( $(window).height() - $('.main-menu').outerHeight() - $('#main_tabs').outerHeight() - $('#breadcrumbs').outerHeight() - + $('.site-footer').outerHeight() - $('.group-breadcrumbs').outerHeight() - $('#groups-container #search-widget-container').outerHeight() - + $('#groups_table thead').height() )); + */ return $(window).height() - $('.main-menu').outerHeight() - $('#main_tabs').outerHeight() - $('#breadcrumbs').outerHeight() - - $('.site-footer').outerHeight() - $('.group-breadcrumbs').outerHeight() - $('#groups-container #search-widget-container').outerHeight() - $('#groups_table thead').height() - 70; + $('.site-footer').outerHeight() - $('.group-breadcrumbs').outerHeight() - $('#groups-container #search-widget-container').outerHeight() - + $('#groups_table thead').height() - 70; }; }]) diff --git a/awx/ui/static/js/helpers/search.js b/awx/ui/static/js/helpers/search.js index 04db2bc5c6..f60e1d8401 100644 --- a/awx/ui/static/js/helpers/search.js +++ b/awx/ui/static/js/helpers/search.js @@ -291,6 +291,7 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper']) deferWaitStop: deferWaitStop }); } + e.stopPropagation(); }); @@ -343,7 +344,9 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper']) } } } + e.stopPropagation(); scope.$emit('prepareSearch2', iterator, page, load, calcOnly, deferWaitStop); + }); if (scope.removePrepareSearch2) { @@ -433,7 +436,7 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper']) scope[iterator + 'SearchParams'] += (scope[iterator + 'SearchParams']) ? '&' : ''; scope[iterator + 'SearchParams'] += 'order_by=' + encodeURI(sort_order); } - + e.stopPropagation(); scope.$emit('doSearch', iterator, page, load, calcOnly, deferWaitStop); });