mirror of
https://github.com/ansible/awx.git
synced 2026-03-04 10:11:05 -03:30
Merge pull request #4728 from mabashian/4027-inventory-groups-pagination
Generate the correct base path for groups and hosts so that paginate works properly
This commit is contained in:
@@ -98,9 +98,17 @@ export default {
|
|||||||
},
|
},
|
||||||
// target ui-views with name@inventoryManage state
|
// target ui-views with name@inventoryManage state
|
||||||
'groupsList@inventoryManage': {
|
'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') + _.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({
|
let html = generateList.build({
|
||||||
list: InventoryGroups,
|
list: list,
|
||||||
mode: 'edit'
|
mode: 'edit'
|
||||||
});
|
});
|
||||||
html = generateList.wrapPanel(html);
|
html = generateList.wrapPanel(html);
|
||||||
@@ -112,9 +120,17 @@ export default {
|
|||||||
controller: GroupsListController
|
controller: GroupsListController
|
||||||
},
|
},
|
||||||
'hostsList@inventoryManage': {
|
'hostsList@inventoryManage': {
|
||||||
templateProvider: function(InventoryHosts, generateList) {
|
templateProvider: function(InventoryHosts, generateList, $stateParams, GetBasePath) {
|
||||||
|
let list = _.cloneDeep(InventoryHosts);
|
||||||
|
if($stateParams && $stateParams.group) {
|
||||||
|
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({
|
let html = generateList.build({
|
||||||
list: InventoryHosts,
|
list: list,
|
||||||
mode: 'edit'
|
mode: 'edit'
|
||||||
});
|
});
|
||||||
return generateList.wrapPanel(html);
|
return generateList.wrapPanel(html);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export default ['$scope', '$stateParams', '$state', '$filter', 'GetBasePath', 'Q
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
path = GetBasePath($scope.basePath) || $scope.basePath;
|
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('.', {
|
$state.go('.', {
|
||||||
[$scope.iterator + '_search']: queryset
|
[$scope.iterator + '_search']: queryset
|
||||||
});
|
});
|
||||||
@@ -59,7 +59,7 @@ export default ['$scope', '$stateParams', '$state', '$filter', 'GetBasePath', 'Q
|
|||||||
return `1 - ${pageSize}`;
|
return `1 - ${pageSize}`;
|
||||||
} else {
|
} else {
|
||||||
let floor = (($scope.current() - 1) * parseInt(pageSize)) + 1;
|
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}`;
|
return `${floor} - ${ceil}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user