mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 12:20:45 -03:30
Fixes pagination on IG/Instance jobs lists
This commit is contained in:
parent
979eaeddfa
commit
7a509a4dcb
@ -4,7 +4,7 @@ function IndexJobsController ($scope, strings, dataset) {
|
||||
vm.count = dataset.data.count;
|
||||
|
||||
$scope.$on('updateCount', (e, count) => {
|
||||
if (count) {
|
||||
if (typeof count === 'number') {
|
||||
vm.count = count;
|
||||
}
|
||||
});
|
||||
|
||||
@ -16,7 +16,8 @@ function ListJobsController (
|
||||
$filter,
|
||||
ProcessErrors,
|
||||
Wait,
|
||||
Rest
|
||||
Rest,
|
||||
SearchBasePath
|
||||
) {
|
||||
const vm = this || {};
|
||||
const [unifiedJob] = resolvedModels;
|
||||
@ -26,21 +27,21 @@ function ListJobsController (
|
||||
// smart-search
|
||||
const name = 'jobs';
|
||||
const iterator = 'job';
|
||||
const key = 'job_dataset';
|
||||
|
||||
let launchModalOpen = false;
|
||||
let refreshAfterLaunchClose = false;
|
||||
|
||||
$scope.list = { iterator, name };
|
||||
$scope.collection = { iterator, basePath: 'unified_jobs' };
|
||||
$scope[key] = Dataset.data;
|
||||
$scope[name] = Dataset.data.results;
|
||||
$scope.$emit('updateCount', Dataset.data.count, 'jobs');
|
||||
$scope.$on('updateDataset', (e, dataset) => {
|
||||
$scope[key] = dataset;
|
||||
$scope[name] = dataset.results;
|
||||
$scope.$emit('updateCount', dataset.count, 'jobs');
|
||||
vm.searchBasePath = SearchBasePath;
|
||||
|
||||
vm.list = { iterator, name };
|
||||
vm.job_dataset = Dataset.data;
|
||||
vm.jobs = Dataset.data.results;
|
||||
vm.querySet = $state.params.job_search;
|
||||
|
||||
$scope.$watch('vm.job_dataset.count', () => {
|
||||
$scope.$emit('updateCount', vm.job_dataset.count, 'jobs');
|
||||
});
|
||||
|
||||
$scope.$on('ws-jobs', () => {
|
||||
if (!launchModalOpen) {
|
||||
refreshJobs();
|
||||
@ -114,7 +115,7 @@ function ListJobsController (
|
||||
.then(() => {
|
||||
let reloadListStateParams = null;
|
||||
|
||||
if ($scope.jobs.length === 1 && $state.params.job_search &&
|
||||
if (vm.jobs.length === 1 && $state.params.job_search &&
|
||||
_.has($state, 'params.job_search.page') &&
|
||||
$state.params.job_search.page !== '1') {
|
||||
reloadListStateParams = _.cloneDeep($state.params);
|
||||
@ -155,7 +156,7 @@ function ListJobsController (
|
||||
.then(() => {
|
||||
let reloadListStateParams = null;
|
||||
|
||||
if ($scope.jobs.length === 1 && $state.params.job_search &&
|
||||
if (vm.jobs.length === 1 && $state.params.job_search &&
|
||||
!_.isEmpty($state.params.job_search.page) &&
|
||||
$state.params.job_search.page !== '1') {
|
||||
const page = `${(parseInt(reloadListStateParams
|
||||
@ -190,9 +191,10 @@ function ListJobsController (
|
||||
};
|
||||
|
||||
function refreshJobs () {
|
||||
qs.search(unifiedJob.path, $state.params.job_search)
|
||||
qs.search(SearchBasePath, $state.params.job_search)
|
||||
.then(({ data }) => {
|
||||
$scope.$emit('updateDataset', data);
|
||||
vm.jobs = data.results;
|
||||
vm.job_dataset = data;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -208,7 +210,8 @@ ListJobsController.$inject = [
|
||||
'$filter',
|
||||
'ProcessErrors',
|
||||
'Wait',
|
||||
'Rest'
|
||||
'Rest',
|
||||
'SearchBasePath'
|
||||
];
|
||||
|
||||
export default ListJobsController;
|
||||
|
||||
@ -3,19 +3,19 @@
|
||||
<smart-search
|
||||
class="at-List-search"
|
||||
django-model="jobs"
|
||||
base-path="unified_jobs"
|
||||
base-path="{{vm.searchBasePath}}"
|
||||
iterator="job"
|
||||
list="list"
|
||||
dataset="job_dataset"
|
||||
collection="collection"
|
||||
list="vm.list"
|
||||
dataset="vm.job_dataset"
|
||||
collection="vm.jobs"
|
||||
search-tags="searchTags"
|
||||
query-set="querySet"
|
||||
query-set="vm.querySet"
|
||||
search-bar-full-width="vm.isPortalMode">
|
||||
</smart-search>
|
||||
</div>
|
||||
<at-list results="jobs" empty-list-reason="{{ vm.emptyListReason }}">
|
||||
<at-list results="vm.jobs" empty-list-reason="{{ vm.emptyListReason }}">
|
||||
<!-- TODO: implement resources are missing red indicator as present in mockup -->
|
||||
<at-row ng-repeat="job in jobs" job-id="{{ job.id }}">
|
||||
<at-row ng-repeat="job in vm.jobs" job-id="{{ job.id }}">
|
||||
<div class="at-Row-items">
|
||||
<!-- TODO: include workflow tab as well -->
|
||||
<at-row-item
|
||||
@ -94,10 +94,10 @@
|
||||
</at-row>
|
||||
</at-list>
|
||||
<paginate
|
||||
collection="collection"
|
||||
dataset="job_dataset"
|
||||
collection="vm.jobs"
|
||||
dataset="vm.job_dataset"
|
||||
iterator="job"
|
||||
base-path="unified_jobs"
|
||||
query-set="querySet">
|
||||
base-path="{{vm.searchBasePath}}"
|
||||
query-set="vm.querySet">
|
||||
</paginate>
|
||||
</at-panel-body>
|
||||
|
||||
@ -53,6 +53,10 @@ export default {
|
||||
return qs.search(searchPath, searchParam)
|
||||
.finally(() => Wait('stop'));
|
||||
}
|
||||
],
|
||||
SearchBasePath: [
|
||||
'GetBasePath',
|
||||
(GetBasePath) => GetBasePath('unified_jobs')
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
@ -59,6 +59,10 @@ export default {
|
||||
return qs.search(searchPath, searchParam)
|
||||
.finally(() => Wait('stop'));
|
||||
}
|
||||
],
|
||||
SearchBasePath: [
|
||||
'$stateParams',
|
||||
($stateParams) => `api/v2/instance_groups/${$stateParams.instance_group_id}/jobs`
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
@ -59,6 +59,10 @@ export default {
|
||||
return qs.search(searchPath, searchParam)
|
||||
.finally(() => Wait('stop'));
|
||||
}
|
||||
],
|
||||
SearchBasePath: [
|
||||
'$stateParams',
|
||||
($stateParams) => `api/v2/instances/${$stateParams.instance_id}/jobs`
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
@ -58,6 +58,10 @@ export default {
|
||||
return qs.search(searchPath, searchParam)
|
||||
.finally(() => Wait('stop'));
|
||||
}
|
||||
],
|
||||
SearchBasePath: [
|
||||
'GetBasePath',
|
||||
(GetBasePath) => GetBasePath('unified_jobs')
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
@ -56,6 +56,10 @@ export default {
|
||||
.finally(() => Wait('stop'));
|
||||
}
|
||||
],
|
||||
SearchBasePath: [
|
||||
'GetBasePath',
|
||||
(GetBasePath) => GetBasePath('unified_jobs')
|
||||
]
|
||||
},
|
||||
views: {
|
||||
'@': {
|
||||
|
||||
@ -55,6 +55,10 @@ export default {
|
||||
return qs.search(searchPath, searchParam)
|
||||
.finally(() => Wait('stop'));
|
||||
}
|
||||
],
|
||||
SearchBasePath: [
|
||||
'GetBasePath',
|
||||
(GetBasePath) => GetBasePath('unified_jobs')
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
@ -54,6 +54,10 @@ export default {
|
||||
return qs.search(searchPath, searchParam)
|
||||
.finally(() => Wait('stop'));
|
||||
}
|
||||
],
|
||||
SearchBasePath: [
|
||||
'GetBasePath',
|
||||
(GetBasePath) => GetBasePath('unified_jobs')
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
@ -4,7 +4,7 @@ function IndexTemplatesController ($scope, strings, dataset) {
|
||||
vm.count = dataset.data.count;
|
||||
|
||||
$scope.$on('updateCount', (e, count) => {
|
||||
if (count) {
|
||||
if (typeof count === 'number') {
|
||||
vm.count = count;
|
||||
}
|
||||
});
|
||||
|
||||
@ -1,36 +1,39 @@
|
||||
|
||||
function InstanceGroupJobsContainerController (strings, $state) {
|
||||
function InstanceGroupJobsContainerController ($scope, strings, $state) {
|
||||
const vm = this || {};
|
||||
|
||||
init();
|
||||
function init() {
|
||||
const instanceGroupId = $state.params.instance_group_id;
|
||||
const instanceGroupId = $state.params.instance_group_id;
|
||||
|
||||
vm.panelTitle = strings.get('jobs.PANEL_TITLE');
|
||||
vm.strings = strings;
|
||||
vm.panelTitle = strings.get('jobs.PANEL_TITLE');
|
||||
vm.strings = strings;
|
||||
|
||||
vm.tab = {
|
||||
details: {
|
||||
_go: 'instanceGroups.edit',
|
||||
_params: { instance_group_id: instanceGroupId },
|
||||
_label: strings.get('tab.DETAILS')
|
||||
},
|
||||
instances: {
|
||||
_go: 'instanceGroups.instances',
|
||||
_params: { instance_group_id: instanceGroupId },
|
||||
_label: strings.get('tab.INSTANCES')
|
||||
},
|
||||
jobs: {
|
||||
_active: true,
|
||||
_params: { instance_group_id: instanceGroupId },
|
||||
_label: strings.get('tab.JOBS')
|
||||
}
|
||||
};
|
||||
}
|
||||
vm.tab = {
|
||||
details: {
|
||||
_go: 'instanceGroups.edit',
|
||||
_params: { instance_group_id: instanceGroupId },
|
||||
_label: strings.get('tab.DETAILS')
|
||||
},
|
||||
instances: {
|
||||
_go: 'instanceGroups.instances',
|
||||
_params: { instance_group_id: instanceGroupId },
|
||||
_label: strings.get('tab.INSTANCES')
|
||||
},
|
||||
jobs: {
|
||||
_active: true,
|
||||
_params: { instance_group_id: instanceGroupId },
|
||||
_label: strings.get('tab.JOBS')
|
||||
}
|
||||
};
|
||||
|
||||
$scope.$on('updateCount', (e, count) => {
|
||||
if (typeof count === 'number') {
|
||||
vm.count = count;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
InstanceGroupJobsContainerController.$inject = [
|
||||
'$scope',
|
||||
'InstanceGroupsStrings',
|
||||
'$state'
|
||||
];
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<at-panel>
|
||||
<at-panel-heading title="{{:: vm.panelTitle }}"></at-panel-heading>
|
||||
<at-panel-heading title="{{:: vm.panelTitle }}" badge="{{ vm.count }}"></at-panel-heading>
|
||||
|
||||
<at-tab-group class="at-TabGroup--padBelow">
|
||||
<at-tab state="vm.tab.details">{{:: vm.strings.get('tab.DETAILS') }}</at-tab>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
function InstanceGroupJobsContainerController (strings) {
|
||||
function InstanceGroupJobsContainerController ($scope, strings) {
|
||||
const vm = this || {};
|
||||
|
||||
init();
|
||||
@ -8,9 +8,15 @@ function InstanceGroupJobsContainerController (strings) {
|
||||
vm.strings = strings;
|
||||
}
|
||||
|
||||
$scope.$on('updateCount', (e, count) => {
|
||||
if (typeof count === 'number') {
|
||||
vm.count = count;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
InstanceGroupJobsContainerController.$inject = [
|
||||
'$scope',
|
||||
'InstanceGroupsStrings'
|
||||
];
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<at-panel>
|
||||
<at-panel-heading title="{{:: vm.panelTitle }}"></at-panel-heading>
|
||||
<at-panel-heading title="{{:: vm.panelTitle }}" badge="{{ vm.count }}"></at-panel-heading>
|
||||
|
||||
<div ui-view="jobsList"></div>
|
||||
</at-panel>
|
||||
|
||||
@ -73,8 +73,6 @@ xdescribe('Directive: lookupModal', () => {
|
||||
$parent.mock = 1; // resource id
|
||||
$parent.mock_name = 'Mock Resource 1'; // resource name
|
||||
|
||||
console.log($scope);
|
||||
|
||||
element = $compile(dom)($scope);
|
||||
$scope.$digest();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user