From 4d66c6dd0aa34858937e81951fb469dedce176ac Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Fri, 13 Jan 2017 15:54:29 -0500 Subject: [PATCH 1/2] Generate the correct base path for groups and hosts so that paginate works properly --- .../inventories/manage/inventory-manage.route.js | 16 ++++++++++++---- .../src/shared/paginate/paginate.controller.js | 4 ++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/awx/ui/client/src/inventories/manage/inventory-manage.route.js b/awx/ui/client/src/inventories/manage/inventory-manage.route.js index ddcbf85e1d..87d2daacb4 100644 --- a/awx/ui/client/src/inventories/manage/inventory-manage.route.js +++ b/awx/ui/client/src/inventories/manage/inventory-manage.route.js @@ -98,9 +98,13 @@ export default { }, // target ui-views with name@inventoryManage state 'groupsList@inventoryManage': { - templateProvider: function(InventoryGroups, generateList, $templateRequest) { + templateProvider: function(InventoryGroups, generateList, $templateRequest, $stateParams, GetBasePath) { + let list = _.cloneDeep(InventoryGroups); + if($stateParams && $stateParams.group) { + list.basePath = GetBasePath('groups') + $stateParams.group[$stateParams.group.length-1] + '/children'; + } let html = generateList.build({ - list: InventoryGroups, + list: list, mode: 'edit' }); html = generateList.wrapPanel(html); @@ -112,9 +116,13 @@ export default { controller: GroupsListController }, 'hostsList@inventoryManage': { - templateProvider: function(InventoryHosts, generateList) { + templateProvider: function(InventoryHosts, generateList, $stateParams, GetBasePath) { + let list = _.cloneDeep(InventoryHosts); + if($stateParams && $stateParams.group) { + list.basePath = GetBasePath('groups') + $stateParams.group[$stateParams.group.length-1] + '/all_hosts'; + } let html = generateList.build({ - list: InventoryHosts, + list: list, mode: 'edit' }); return generateList.wrapPanel(html); diff --git a/awx/ui/client/src/shared/paginate/paginate.controller.js b/awx/ui/client/src/shared/paginate/paginate.controller.js index 407f9e10f6..bd9ff29032 100644 --- a/awx/ui/client/src/shared/paginate/paginate.controller.js +++ b/awx/ui/client/src/shared/paginate/paginate.controller.js @@ -18,7 +18,7 @@ export default ['$scope', '$stateParams', '$state', '$filter', 'GetBasePath', 'Q return; } path = GetBasePath($scope.basePath) || $scope.basePath; - queryset = _.merge($stateParams[`${$scope.iterator}_search`], { page: page.toString() }); + queryset = _.merge($stateParams[`${$scope.iterator}_search`], { page: page }); $state.go('.', { [$scope.iterator + '_search']: queryset }); @@ -59,7 +59,7 @@ export default ['$scope', '$stateParams', '$state', '$filter', 'GetBasePath', 'Q return `1 - ${pageSize}`; } else { let floor = (($scope.current() - 1) * parseInt(pageSize)) + 1; - let ceil = floor + parseInt(pageSize); + let ceil = floor + parseInt(pageSize) < $scope.dataset.count ? floor + parseInt(pageSize) : $scope.dataset.count; return `${floor} - ${ceil}`; } } From 66e5cf88ade3b8fca8b441bc22c47d878ee12743 Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Fri, 13 Jan 2017 18:49:42 -0500 Subject: [PATCH 2/2] Fixed basePath at the root level of the inventory manage (thanks @jared) --- .../src/inventories/manage/inventory-manage.route.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/src/inventories/manage/inventory-manage.route.js b/awx/ui/client/src/inventories/manage/inventory-manage.route.js index 87d2daacb4..ca7589a3e1 100644 --- a/awx/ui/client/src/inventories/manage/inventory-manage.route.js +++ b/awx/ui/client/src/inventories/manage/inventory-manage.route.js @@ -101,7 +101,11 @@ export default { templateProvider: function(InventoryGroups, generateList, $templateRequest, $stateParams, GetBasePath) { let list = _.cloneDeep(InventoryGroups); if($stateParams && $stateParams.group) { - list.basePath = GetBasePath('groups') + $stateParams.group[$stateParams.group.length-1] + '/children'; + list.basePath = GetBasePath('groups') + _.last($stateParams.group) + '/children'; + } + else { + //reaches here if the user is on the root level group + list.basePath = GetBasePath('inventory') + $stateParams.inventory_id + '/root_groups'; } let html = generateList.build({ list: list, @@ -119,7 +123,11 @@ export default { templateProvider: function(InventoryHosts, generateList, $stateParams, GetBasePath) { let list = _.cloneDeep(InventoryHosts); if($stateParams && $stateParams.group) { - list.basePath = GetBasePath('groups') + $stateParams.group[$stateParams.group.length-1] + '/all_hosts'; + list.basePath = GetBasePath('groups') + _.last($stateParams.group) + '/all_hosts'; + } + else { + //reaches here if the user is on the root level group + list.basePath = GetBasePath('inventory') + $stateParams.inventory_id + '/hosts'; } let html = generateList.build({ list: list,