diff --git a/awx/ui/client/src/job-results/job-results-stdout/job-results-stdout.directive.js b/awx/ui/client/src/job-results/job-results-stdout/job-results-stdout.directive.js index 0d1674b267..77c87c74da 100644 --- a/awx/ui/client/src/job-results/job-results-stdout/job-results-stdout.directive.js +++ b/awx/ui/client/src/job-results/job-results-stdout/job-results-stdout.directive.js @@ -90,23 +90,14 @@ export default [ 'templateUrl', '$timeout', '$location', '$anchorScroll', var visItem, parentItem; - var containerHeight = $container.height(); - var containerTop = $container.position().top; - var containerNetHeight = containerHeight + containerTop; - // iterate through each line of standard out - $container.find('.JobResultsStdOut-aLineOfStdOut') + $container.find('.JobResultsStdOut-aLineOfStdOut:visible') .each( function () { var $this = $(this); - var lineHeight = $this.height(); - var lineTop = $this.position().top; - var lineNetHeight = lineHeight + lineTop; - // check to see if the line is the first visible // line in the viewport... - if (lineNetHeight > containerTop && - lineTop < containerNetHeight) { + if ($this.position().top >= 0) { // ...if it is, return the line number // for this line 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 adfe541bc4..a11e7cf7be 100644 --- a/awx/ui/client/src/job-results/job-results.controller.js +++ b/awx/ui/client/src/job-results/job-results.controller.js @@ -1,4 +1,5 @@ -export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count', '$scope', 'ParseTypeChange', 'ParseVariableString', 'jobResultsService', 'eventQueue', '$compile', '$log', 'Dataset', '$q', 'Rest', '$state', 'QuerySet', function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTypeChange, ParseVariableString, jobResultsService, eventQueue, $compile, $log, Dataset, $q, Rest, $state, QuerySet) { +export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count', '$scope', 'ParseTypeChange', 'ParseVariableString', 'jobResultsService', 'eventQueue', '$compile', '$log', 'Dataset', '$q', 'Rest', '$state', 'QuerySet', '$rootScope', function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTypeChange, ParseVariableString, jobResultsService, eventQueue, $compile, $log, Dataset, $q, Rest, $state, QuerySet, $rootScope) { + // used for tag search $scope.job_event_dataset = Dataset.data; @@ -47,7 +48,6 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count' } }; - $scope.status_label = getTowerLabel('status'); $scope.type_label = getTowerLabel('job_type'); $scope.verbosity_label = getTowerLabel('verbosity'); }; @@ -63,6 +63,27 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count' $scope.labels = jobLabels; $scope.jobFinished = jobFinished; + // update label in left pane and tooltip in right pane when the job_status + // changes + $scope.$watch('job_status', function(status) { + if (status) { + $scope.status_label = $scope.jobOptions.status.choices + .filter(val => val[0] === status) + .map(val => val[1])[0]; + $scope.status_tooltip = "Job " + $scope.status_label; + } + }); + + // update the job_status value. Use the cached rootScope value if there + // is one. This is a workaround when the rest call for the jobData is + // made before some socket events come in for the job status + if ($rootScope['lastSocketStatus' + jobData.id]) { + $scope.job_status = $rootScope['lastSocketStatus' + jobData.id]; + delete $rootScope['lastSocketStatus' + jobData.id]; + } else { + $scope.job_status = jobData.status; + } + // turn related api browser routes into tower routes getTowerLinks(); @@ -114,7 +135,6 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count' $scope.relaunchJob = function() { jobResultsService.relaunchJob($scope); - $state.reload(); }; $scope.lessLabels = false; @@ -420,13 +440,19 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count' $scope.$on(`ws-jobs`, function(e, data) { if (parseInt(data.unified_job_id, 10) === parseInt($scope.job.id,10)) { - $scope.job.status = data.status; - } - if (parseInt(data.project_id, 10) === + // controller is defined, so set the job_status + $scope.job_status = data.status; + } else if (parseInt(data.project_id, 10) === parseInt($scope.job.project,10)) { + // this is a project status update message, so set the + // project status in the left pane $scope.project_status = data.status; $scope.project_update_link = `/#/scm_update/${data .unified_job_id}`; + } else { + // controller was previously defined, but is not yet defined + // for this job. cache the socket status on root scope + $rootScope['lastSocketStatus' + data.unified_job_id] = data.status; } }); }]; diff --git a/awx/ui/client/src/job-results/job-results.partial.html b/awx/ui/client/src/job-results/job-results.partial.html index 5357c77749..6fe760b55e 100644 --- a/awx/ui/client/src/job-results/job-results.partial.html +++ b/awx/ui/client/src/job-results/job-results.partial.html @@ -70,7 +70,7 @@