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.
This commit is contained in:
Chris Houseknecht 2014-06-04 11:45:11 -04:00
parent c517332191
commit da766edd52
4 changed files with 41 additions and 5 deletions

View File

@ -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'
];

View File

@ -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 });
};
}])

View File

@ -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;
};
}])

View File

@ -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);
});