push initial events on partially complete job initialization

This commit is contained in:
Jake McDermott
2018-05-10 21:39:55 -04:00
parent 4b5c09c07c
commit 2f5eefe809
3 changed files with 30 additions and 23 deletions

View File

@@ -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);
}

View File

@@ -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) {

View File

@@ -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);