From bba253cdfcad6e00d86dd4726189e358b6f31419 Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Tue, 18 Oct 2016 13:39:07 -0400 Subject: [PATCH] added relaunch capability and end time of running job --- .../src/job-results/event-queue.service.js | 7 ++++-- .../src/job-results/job-results.controller.js | 25 ++++++++++--------- .../src/job-results/job-results.service.js | 6 ++++- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/awx/ui/client/src/job-results/event-queue.service.js b/awx/ui/client/src/job-results/event-queue.service.js index e34905a966..6092f39ad1 100644 --- a/awx/ui/client/src/job-results/event-queue.service.js +++ b/awx/ui/client/src/job-results/event-queue.service.js @@ -85,7 +85,8 @@ export default ['jobResultsService', '$q', function(jobResultsService, $q){ failures: 0, changed: 0 }; - mungedEvent.changes = ['count']; + mungedEvent.startTime = event.modified; + mungedEvent.changes = ['count', 'startTime']; } else if (event.event_name === 'playbook_on_play_start') { getPreviousCount(mungedEvent.counter, "play") .then(count => { @@ -129,10 +130,12 @@ export default ['jobResultsService', '$q', function(jobResultsService, $q){ mungedEvent.changes = ['count']; }); } else if (event.event_name === 'playbook_on_stats') { + console.log(event.modified); // get the data for populating the host status bar mungedEvent.count = jobResultsService .getCountsFromStatsEvent(event.event_data); - mungedEvent.changes = ['count', 'countFinished']; + mungedEvent.finishedTime = event.modified; + mungedEvent.changes = ['count', 'countFinished', 'finishedTime']; } else { } diff --git a/awx/ui/client/src/job-results/job-results.controller.js b/awx/ui/client/src/job-results/job-results.controller.js index 20fd0686b4..3dfb513e7a 100644 --- a/awx/ui/client/src/job-results/job-results.controller.js +++ b/awx/ui/client/src/job-results/job-results.controller.js @@ -71,6 +71,10 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'count', '$scope', 'Pa jobResultsService.cancelJob($scope.job); }; + $scope.relaunchJob = function() { + jobResultsService.relaunchJob($scope); + }; + // get initial count from resolve $scope.count = count.val; $scope.hostCount = getTotalHostCount(count.val); @@ -93,6 +97,10 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'count', '$scope', 'Pa mungedEvent.changes.forEach(change => { // we've got a change we need to make to the UI! // update the necessary scope and make the change + if (change === 'startTime' && !$scope.job.start) { + $scope.job.start = mungedEvent.startTime; + } + if (change === 'count' && !$scope.countFinished) { // for all events that affect the host count, // update the status bar as well as the host @@ -110,6 +118,10 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'count', '$scope', 'Pa $scope.taskCount = mungedEvent.taskCount; } + if (change === 'finishedTime' && !$scope.job.finished) { + $scope.job.finished = mungedEvent.finishedTime; + } + if (change === 'countFinished') { // the playbook_on_stats event actually lets // us know that we don't need to iteratively @@ -143,7 +155,7 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'count', '$scope', 'Pa }; getEvents($scope.job.related.job_events); - // Processing of job_events messages from the websocket + // Processing of job_events messages from the websocket $scope.$on(`ws-job_events-${$scope.job.id}`, function(e, data) { processEvent(data); }); @@ -154,15 +166,4 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'count', '$scope', 'Pa $scope.job.status = data.status; } }); - - // The code below was used in the old job detail controller, - // and is for processing the 'Job Summary' event that is delivered - // for a completed job. Not sure if we have an equivalent function - // at this point. TODO: write function to handle Job Summary - // scope.$on('ws-jobs-summary', function() { - // // the job host summary should now be available from the API - // $log.debug('Trigging reload of job_host_summaries'); - // scope.$emit('InitialLoadComplete'); - // }); - }]; diff --git a/awx/ui/client/src/job-results/job-results.service.js b/awx/ui/client/src/job-results/job-results.service.js index 81f4a99fb0..0109eeee55 100644 --- a/awx/ui/client/src/job-results/job-results.service.js +++ b/awx/ui/client/src/job-results/job-results.service.js @@ -5,7 +5,7 @@ *************************************************/ -export default ['$q', 'Prompt', '$filter', 'Wait', 'Rest', '$state', 'ProcessErrors', function ($q, Prompt, $filter, Wait, Rest, $state, ProcessErrors) { +export default ['$q', 'Prompt', '$filter', 'Wait', 'Rest', '$state', 'ProcessErrors', 'InitiatePlaybookRun', function ($q, Prompt, $filter, Wait, Rest, $state, ProcessErrors, InitiatePlaybookRun) { var val = { // the playbook_on_stats event returns the count data in a weird format. // format to what we need! @@ -185,6 +185,10 @@ export default ['$q', 'Prompt', '$filter', 'Wait', 'Rest', '$state', 'ProcessErr }, actionText: 'CANCEL' }); + }, + relaunchJob: function(scope) { + InitiatePlaybookRun({ scope: scope, id: scope.job.id, + relaunch: true }); } }; return val;