From 186ab7814febad8c2be1637768fea69694ecd627 Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Tue, 19 Aug 2014 13:17:11 -0400 Subject: [PATCH] Job detail page Fix for https://trello.com/c/WZ18zIqG/337-completed-job-detail-statistics-differ-between-realtime-and-page-refresh --- awx/ui/static/js/app.js | 4 ++++ awx/ui/static/js/controllers/JobDetail.js | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/awx/ui/static/js/app.js b/awx/ui/static/js/app.js index 8a73ae16ba..95d087f556 100644 --- a/awx/ui/static/js/app.js +++ b/awx/ui/static/js/app.js @@ -583,6 +583,10 @@ angular.module('Tower', [ $log.debug('Job ' + data.unified_job_id + ' status changed to ' + data.status); $rootScope.$emit('JobStatusChange', data); }); + sock.on("summary_complete", function(data) { + $log.debug('Job summary_complete ' + data.unified_job_id); + $rootScope.$emit('JobSummaryComplete', data); + }); } openSocket(); diff --git a/awx/ui/static/js/controllers/JobDetail.js b/awx/ui/static/js/controllers/JobDetail.js index 4222fbf5ba..f12c7871fb 100644 --- a/awx/ui/static/js/controllers/JobDetail.js +++ b/awx/ui/static/js/controllers/JobDetail.js @@ -70,6 +70,7 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar scope.host_summary.total = 0; scope.jobData = {}; + scope.jobData.hostSummaries = {}; verbosity_options = [ { value: 0, label: 'Default' }, @@ -140,6 +141,15 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar } }); + if ($rootScope.removeJobSummaryComplete) { + $rootScope.removeJobSummaryComplete(); + } + $rootScope.removeJobSummaryComplete = $rootScope.$on('JobSummaryComplete', function() { + // the job host summary should now be available from the API + $log.debug('Trigging reload of job_host_summaries'); + scope.$emit('LoadHostSummaries'); + }); + if (scope.removeInitialLoadComplete) { scope.removeInitialLoadComplete(); @@ -189,12 +199,14 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar var url = scope.job.related.job_host_summaries + '?'; url += '&page_size=' + scope.hostSummariesMaxRows + '&order=host_name'; - scope.jobData.hostSummaries = {}; - Rest.setUrl(url); Rest.get() .success(function(data) { scope.next_host_summaries = data.next; + if (data.results.length > 0) { + // only dump what's in memory when job_host_summaries is available. + scope.jobData.hostSummaries = {}; + } data.results.forEach(function(event) { var name; if (event.host_name) {