From 0f435eb42c0597db03a3a1d1156e79f5fd231896 Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Thu, 19 Jun 2014 22:20:25 -0400 Subject: [PATCH] Job detail page refactor Cleaning up end of job processing to make sure we only reload things 1x at the end. Now drawing graph each time DOM is updated. --- awx/ui/static/js/controllers/JobDetail.js | 16 ++++++---------- awx/ui/static/js/helpers/JobDetail.js | 11 ++++++++--- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/awx/ui/static/js/controllers/JobDetail.js b/awx/ui/static/js/controllers/JobDetail.js index 0448b1be2e..95d446697f 100644 --- a/awx/ui/static/js/controllers/JobDetail.js +++ b/awx/ui/static/js/controllers/JobDetail.js @@ -80,10 +80,10 @@ function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log, if (parseInt(data.unified_job_id, 10) === parseInt(job_id,10)) { if (data.status === 'failed' || data.status === 'canceled' || data.status === 'error' || data.status === 'successful') { - $log.debug('Job completed!'); - $log.debug(scope.jobData); - window.clearInterval($rootScope.jobDetailInterval); - UpdateDOM({ scope: scope }); + if ($rootScope.jobDetailInterval) { + window.clearInterval($rootScope.jobDetailInterval); + } + $scope.$emit('LoadJob'); } } }); @@ -96,7 +96,6 @@ function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log, var url; Wait('stop'); if (JobIsFinished(scope)) { - UpdateDOM({ scope: scope }); url = scope.job.related.job_events + '?event=playbook_on_stats'; Rest.setUrl(url); Rest.get() @@ -106,7 +105,7 @@ function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log, scope: scope, data: data.results[0].event_data }); - DrawGraph({ scope: scope, resize: true }); + UpdateDOM({ scope: scope }); } }) .error(function(data, status) { @@ -114,13 +113,10 @@ function JobDetailController ($rootScope, $scope, $compile, $routeParams, $log, msg: 'Call to ' + url + '. GET returned: ' + status }); }); + $log.debug('Job completed!'); $log.debug(scope.jobData); } else { - if (scope.host_summary.total > 0) { - // Draw the graph based on summary values in memory - DrawGraph({ scope: scope, resize: true }); - } api_complete = true; //trigger events to start processing $rootScope.jobDetailInterval = setInterval(function() { diff --git a/awx/ui/static/js/helpers/JobDetail.js b/awx/ui/static/js/helpers/JobDetail.js index 691d85a3d6..5919465387 100644 --- a/awx/ui/static/js/helpers/JobDetail.js +++ b/awx/ui/static/js/helpers/JobDetail.js @@ -189,7 +189,8 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge }); break; - case 'playbook_on_stats': + // We will respond to the job status change event. No need to do this 2x. + /*case 'playbook_on_stats': scope.job_status.finished = event.modified; scope.job_status.elapsed = GetElapsed({ start: scope.job_status.started, @@ -199,7 +200,7 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge scope.job_status.status_class = ""; //LoadHostSummary({ scope: scope, data: event.event_data }); //DrawGraph({ scope: scope, resize: true }); - break; + break;*/ } }; }]) @@ -999,13 +1000,17 @@ function($rootScope, $log, UpdatePlayStatus, UpdateHostStatus, AddHostResult, Ge }; }]) -.factory('UpdateDOM', ['DrawPlays', 'DrawTasks', 'DrawHostResults', function(DrawPlays, DrawTasks, DrawHostResults) { +.factory('UpdateDOM', ['DrawPlays', 'DrawTasks', 'DrawHostResults', 'DrawGraph', function(DrawPlays, DrawTasks, DrawHostResults, DrawGraph) { return function(params) { var scope = params.scope; DrawPlays({ scope: scope }); DrawTasks({ scope: scope }); DrawHostResults({ scope: scope }); + + if (scope.host_summary.total > 0) { + DrawGraph({ scope: scope, resize: true }); + } }; }])