From db43341f96387d7e06874254fdfe4d8bfcf1399c Mon Sep 17 00:00:00 2001 From: mabashian Date: Mon, 24 Feb 2020 16:41:35 -0500 Subject: [PATCH] Consume finished timestamp from websocket message and update the relevant job row. Also adds logic to attempt to re-order the list when the sort order is -finished since we have enough information client-side to do that. --- .../client/features/jobs/jobsList.controller.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/awx/ui/client/features/jobs/jobsList.controller.js b/awx/ui/client/features/jobs/jobsList.controller.js index 986ad12f8e..5720a53b80 100644 --- a/awx/ui/client/features/jobs/jobsList.controller.js +++ b/awx/ui/client/features/jobs/jobsList.controller.js @@ -119,10 +119,19 @@ function ListJobsController ( for (let i = 0; i < vm.jobs.length; i++) { if (vm.jobs[i].id === msg.unified_job_id) { // Update the job status. - // If/when we get more info in the message we can - // update those fields here as well. vm.jobs[i].status = msg.status; - i = vm.jobs.length; + if (msg.finished) { + vm.jobs[i].finished = msg.finished; + const orderByValue = _.get($state.params, 'job_search.order_by'); + if (orderByValue === '-finished') { + // Attempt to sort the rows in the list by their finish + // timestamp in descending order + vm.jobs.sort((a, b) => + (!b.finished) - (!a.finished) + || new Date(b.finished) - new Date(a.finished)); + } + } + break; } } };