diff --git a/awx/ui/client/features/output/index.controller.js b/awx/ui/client/features/output/index.controller.js index e84c93d708..b4d01c5a90 100644 --- a/awx/ui/client/features/output/index.controller.js +++ b/awx/ui/client/features/output/index.controller.js @@ -67,7 +67,6 @@ function init () { }); render.init({ - get: () => resource.model.get(`related.${resource.related}.results`), compile: html => $compile(html)($scope), isStreamActive: engine.isActive, }); @@ -95,21 +94,24 @@ function init () { } }); - $scope.$on(resource.ws.events, handleJobEvent); - $scope.$on(resource.ws.status, handleStatusEvent); - if (!status.state.running) { - next(); + return next(); } + + $scope.$on(resource.ws.events, (scope, data) => handleJobEvent(data)); + $scope.$on(resource.ws.status, (scope, data) => handleStatusEvent(data)); + + return resource.model + .get(`related.${resource.related}.results`) + .forEach(handleJobEvent); } -function handleStatusEvent (scope, data) { +function handleStatusEvent (data) { status.pushStatusEvent(data); } -function handleJobEvent (scope, data) { +function handleJobEvent (data) { engine.pushJobEvent(data); - status.pushJobEvent(data); } diff --git a/awx/ui/client/features/output/index.js b/awx/ui/client/features/output/index.js index 813d1c2af3..a8d635ed3a 100644 --- a/awx/ui/client/features/output/index.js +++ b/awx/ui/client/features/output/index.js @@ -70,13 +70,20 @@ function resolveResource ( return null; } - const params = { page_size: PAGE_SIZE, order_by: 'start_line' }; - const config = { pageCache: PAGE_CACHE, pageLimit: PAGE_LIMIT, params }; + const params = { + page_size: PAGE_SIZE, + order_by: 'start_line', + }; + + const config = { + params, + pageCache: PAGE_CACHE, + pageLimit: PAGE_LIMIT, + }; if (job_event_search) { // eslint-disable-line camelcase - const queryParams = qs.encodeQuerysetObject(qs.decodeArr(job_event_search)); - - Object.assign(config.params, queryParams); + const query = qs.encodeQuerysetObject(qs.decodeArr(job_event_search)); + Object.assign(config.params, query); } Wait('start'); @@ -89,7 +96,6 @@ function resolveResource ( } promises.push(model.extend('get', related, config)); - return Promise.all(promises); }) .then(([stats, model]) => ({ @@ -107,18 +113,19 @@ function resolveResource ( size: PAGE_SIZE, pageLimit: PAGE_LIMIT } - })) - .finally(() => Wait('stop')); + })); if (!handleErrors) { - return resourcePromise; + return resourcePromise + .finally(() => Wait('stop')); } return resourcePromise .catch(({ data, status }) => { - $state.go($state.current, $state.params, { reload: true }); qs.error(data, status); - }); + return $state.go($state.current, $state.params, { reload: true }); + }) + .finally(() => Wait('stop')); } function resolveWebSocketConnection ($stateParams, SocketService) { diff --git a/awx/ui/client/features/output/render.service.js b/awx/ui/client/features/output/render.service.js index 9981cac65b..08a3498fd2 100644 --- a/awx/ui/client/features/output/render.service.js +++ b/awx/ui/client/features/output/render.service.js @@ -30,11 +30,11 @@ const re = new RegExp(pattern); const hasAnsi = input => re.test(input); function JobRenderService ($q, $sce, $window) { - this.init = ({ compile, apply, isStreamActive }) => { + this.init = ({ compile, isStreamActive }) => { this.parent = null; this.record = {}; this.el = $(ELEMENT_TBODY); - this.hooks = { isStreamActive, compile, apply }; + this.hooks = { isStreamActive, compile }; }; this.sortByLineNumber = (a, b) => { @@ -239,8 +239,6 @@ function JobRenderService ($q, $sce, $window) { return list; }; - this.getEvents = () => this.hooks.get(); - this.insert = (events, insert) => { const result = this.transformEventGroup(events); const html = this.trustHtml(result.html);