From 069c5dacaa3fcf1ed458bf210cfe90fb853e50a3 Mon Sep 17 00:00:00 2001 From: Haokun-Chen Date: Tue, 5 Jun 2018 10:29:09 -0400 Subject: [PATCH] add completed job section on host page host completed jobs added on both host page and related section under inventory edit --- .../jobs/routes/hostCompletedJobs.route.js | 58 +++++++++++++++++++ .../src/inventories-hosts/hosts/host.form.js | 5 ++ .../src/inventories-hosts/hosts/main.js | 7 ++- .../src/inventories-hosts/inventories/main.js | 7 ++- .../related/hosts/related-host.form.js | 5 ++ 5 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 awx/ui/client/features/jobs/routes/hostCompletedJobs.route.js diff --git a/awx/ui/client/features/jobs/routes/hostCompletedJobs.route.js b/awx/ui/client/features/jobs/routes/hostCompletedJobs.route.js new file mode 100644 index 0000000000..04d98996ea --- /dev/null +++ b/awx/ui/client/features/jobs/routes/hostCompletedJobs.route.js @@ -0,0 +1,58 @@ +import { N_ } from '../../../src/i18n'; +import jobsListController from '../jobsList.controller'; + +const jobsListTemplate = require('~features/jobs/jobsList.view.html'); + +export default { + url: '/completed_jobs', + params: { + job_search: { + value: { + page_size: '20', + job__hosts: '', + order_by: '-id' + }, + dynamic: true, + squash: '' + } + }, + ncyBreadcrumb: { + label: N_('COMPLETED JOBS') + }, + views: { + related: { + templateUrl: jobsListTemplate, + controller: jobsListController, + controllerAs: 'vm' + } + }, + resolve: { + resolvedModels: [ + 'UnifiedJobModel', + (UnifiedJob) => { + const models = [ + new UnifiedJob(['options']), + ]; + return Promise.all(models); + }, + ], + Dataset: [ + '$stateParams', + 'Wait', + 'GetBasePath', + 'QuerySet', + ($stateParams, Wait, GetBasePath, qs) => { + const hostId = $stateParams.host_id; + + const searchParam = _.assign($stateParams + .job_search, { job__hosts: hostId }); + + const searchPath = GetBasePath('unified_jobs'); + + Wait('start'); + return qs.search(searchPath, searchParam) + .finally(() => Wait('stop')); + } + ] + } +}; diff --git a/awx/ui/client/src/inventories-hosts/hosts/host.form.js b/awx/ui/client/src/inventories-hosts/hosts/host.form.js index 52c6f0d8c1..f66f48b4df 100644 --- a/awx/ui/client/src/inventories-hosts/hosts/host.form.js +++ b/awx/ui/client/src/inventories-hosts/hosts/host.form.js @@ -123,6 +123,11 @@ function(i18n) { title: i18n._('Insights'), skipGenerator: true, ngIf: "host.insights_system_id!==null && host.summary_fields.inventory.hasOwnProperty('insights_credential_id')" + }, + completed_jobs: { + name: 'completed_jobs', + title: i18n._('Completed Jobs'), + skipGenerator: true } } }; diff --git a/awx/ui/client/src/inventories-hosts/hosts/main.js b/awx/ui/client/src/inventories-hosts/hosts/main.js index c2675c2fda..575a2a8e49 100644 --- a/awx/ui/client/src/inventories-hosts/hosts/main.js +++ b/awx/ui/client/src/inventories-hosts/hosts/main.js @@ -14,6 +14,7 @@ import insightsRoute from '../inventories/insights/insights.route'; import hostGroupsRoute from './related/groups/hosts-related-groups.route'; import hostGroupsAssociateRoute from './related/groups/hosts-related-groups-associate.route'; + import hostCompletedJobsRoute from '~features/jobs/routes/hostCompletedJobs.route.js'; import hostGroups from './related/groups/main'; export default @@ -87,6 +88,9 @@ angular.module('host', [ let hostInsights = _.cloneDeep(insightsRoute); hostInsights.name = 'hosts.edit.insights'; + let hostCompletedJobs = _.cloneDeep(hostCompletedJobsRoute); + hostCompletedJobs.name = 'hosts.edit.completed_jobs'; + return Promise.all([ hostTree ]).then((generated) => { @@ -97,7 +101,8 @@ angular.module('host', [ stateExtender.buildDefinition(hostAnsibleFacts), stateExtender.buildDefinition(hostInsights), stateExtender.buildDefinition(hostGroupsRoute), - stateExtender.buildDefinition(hostGroupsAssociateRoute) + stateExtender.buildDefinition(hostGroupsAssociateRoute), + stateExtender.buildDefinition(hostCompletedJobs) ]) }; }); diff --git a/awx/ui/client/src/inventories-hosts/inventories/main.js b/awx/ui/client/src/inventories-hosts/inventories/main.js index 66ff152d23..88bb35c819 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/main.js +++ b/awx/ui/client/src/inventories-hosts/inventories/main.js @@ -45,6 +45,7 @@ import hostNestedGroupsAssociateRoute from './related/hosts/related/nested-group import groupNestedGroupsAssociateRoute from './related/groups/related/nested-groups/group-nested-groups-associate.route'; import nestedHostsAssociateRoute from './related/groups/related/nested-hosts/group-nested-hosts-associate.route'; import nestedHostsAddRoute from './related/groups/related/nested-hosts/group-nested-hosts-add.route'; +import hostCompletedJobsRoute from '~features/jobs/routes/hostCompletedJobs.route.js'; export default angular.module('inventory', [ @@ -292,6 +293,9 @@ angular.module('inventory', [ let smartInventoryAdhocCredential = _.cloneDeep(adhocCredentialRoute); smartInventoryAdhocCredential.name = 'inventories.editSmartInventory.adhoc.credential'; + let relatedHostCompletedJobs = _.cloneDeep(hostCompletedJobsRoute); + relatedHostCompletedJobs.name = 'inventories.edit.hosts.edit.completed_jobs'; + return Promise.all([ standardInventoryAdd, standardInventoryEdit, @@ -339,7 +343,8 @@ angular.module('inventory', [ stateExtender.buildDefinition(hostNestedGroupsAssociateRoute), stateExtender.buildDefinition(nestedHostsAssociateRoute), stateExtender.buildDefinition(nestedGroupsAdd), - stateExtender.buildDefinition(nestedHostsAddRoute) + stateExtender.buildDefinition(nestedHostsAddRoute), + stateExtender.buildDefinition(relatedHostCompletedJobs) ]) }; }); diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/related-host.form.js b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/related-host.form.js index 2ee6de78a2..3b10504b9e 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/related-host.form.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/related-host.form.js @@ -122,6 +122,11 @@ function(i18n) { title: i18n._('Insights'), skipGenerator: true, ngIf: "host.insights_system_id!==null && host.summary_fields.inventory.hasOwnProperty('insights_credential_id')" + }, + completed_jobs: { + name: 'completed_jobs', + title: i18n._('Completed Jobs'), + skipGenerator: true } } };