From bf55c7e7e283eafc4e53198fdd9c9b914192909c Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Mon, 9 Jul 2018 09:48:55 -0400 Subject: [PATCH] use host_status_counts field for adhoc command jobs ui --- .../client/features/output/status.service.js | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/awx/ui/client/features/output/status.service.js b/awx/ui/client/features/output/status.service.js index 4ad8432d1a..d7b74d2279 100644 --- a/awx/ui/client/features/output/status.service.js +++ b/awx/ui/client/features/output/status.service.js @@ -42,18 +42,17 @@ function JobStatusService (moment, message) { }, }; - if (model.get('type') === 'job' || model.get('type') === 'project_update') { - if (model.has('playbook_counts')) { - this.setPlaybookCounts(model.get('playbook_counts')); - } - - if (model.has('host_status_counts')) { - this.setHostStatusCounts(model.get('host_status_counts')); - } + if (model.has('host_status_counts')) { + this.setHostStatusCounts(model.get('host_status_counts')); } else { const hostStatusCounts = this.createHostStatusCounts(this.state.status); this.setHostStatusCounts(hostStatusCounts); + } + + if (model.has('playbook_counts')) { + this.setPlaybookCounts(model.get('playbook_counts')); + } else { this.setPlaybookCounts({ task_count: 1, play_count: 1 }); } @@ -131,14 +130,25 @@ function JobStatusService (moment, message) { }; this.isExpectingStatsEvent = () => (this.jobType === 'job') || - (this.jobType === 'project_update'); + (this.jobType === 'project_update') || + (this.jobType === 'ad_hoc_command'); this.updateStats = () => { this.updateHostCounts(); if (this.statsEvent) { this.setFinished(this.statsEvent.created); - this.setJobStatus(this.statsEvent.failed ? 'failed' : 'successful'); + + const failures = _.get(this.statsEvent, ['event_data', 'failures'], {}); + const dark = _.get(this.statsEvent, ['event_data', 'dark'], {}); + + if (this.statsEvent.failed || + Object.keys(failures).length > 0 || + Object.keys(dark).length > 0) { + this.setJobStatus('failed'); + } else { + this.setJobStatus('successful'); + } } }; @@ -174,9 +184,9 @@ function JobStatusService (moment, message) { this.setJobStatus = status => { const isExpectingStats = this.isExpectingStatsEvent(); - const isIncomplete = _.includes(INCOMPLETE, status); - const isFinished = _.includes(FINISHED, status); - const isAlreadyFinished = _.includes(FINISHED, this.state.status); + const isIncomplete = INCOMPLETE.includes(status); + const isFinished = FINISHED.includes(status); + const isAlreadyFinished = FINISHED.includes(this.state.status); if (isAlreadyFinished) { return;