event processing for details panel and initial stats bar integration

This commit is contained in:
Jake McDermott
2018-03-19 12:01:17 -04:00
parent f65d170cab
commit b577f50930
12 changed files with 447 additions and 82 deletions
@@ -3,7 +3,7 @@ const JOB_END = 'playbook_on_stats';
const MAX_LAG = 120;
function JobStreamService ($q) {
this.init = ({ resource, scroll, page, render, listen }) => {
this.init = ({ resource, scroll, page, onStreamStart, onStreamFinish, render, listen }) => {
this.resource = resource;
this.scroll = scroll;
this.page = page;
@@ -23,8 +23,10 @@ function JobStreamService ($q) {
};
this.hooks = {
onStreamStart,
onStreamFinish,
render,
listen
listen,
};
this.lines = {
@@ -35,7 +37,7 @@ function JobStreamService ($q) {
max: 0
};
this.hooks.listen(resource.ws.namespace, this.listen);
this.hooks.listen(resource.ws.namespace, this.listener);
};
this.getBatchFactors = size => {
@@ -105,19 +107,25 @@ function JobStreamService ($q) {
}
};
this.listen = data => {
this.listener = data => {
this.lag++;
this.chain = this.chain
.then(() => {
// console.log(data);
if (!this.isActive()) {
this.start();
if (!this.isEnding()) {
this.hooks.onStreamStart(data);
}
} else if (data.event === JOB_END) {
if (this.isPaused()) {
this.end(true);
} else {
this.end();
}
this.hooks.onStreamFinish(data);
}
this.checkLines(data);