add lines to logterminal of correct execution

This commit is contained in:
dcore94 2023-06-23 15:03:04 +02:00
parent e0273618e5
commit d095d00d7d
2 changed files with 24 additions and 3 deletions

View File

@ -274,10 +274,13 @@ class CCPExecutionHistory extends HTMLElement {
this.#socket = new WebSocket(this.#broadcasturl + "/executions");
this.#socket.onmessage = event=>{
const data = JSON.parse(event.data)
if(!data.jobID){
console.log("New logs " + event.data)
if(data[0].source){
//has to be logs
this.appendLogs(data)
return
}
let exec = this.#data.filter(e=>e.id === data.jobID)[0]
if(exec){
this.refreshExecution(exec.id)
@ -303,6 +306,17 @@ class CCPExecutionHistory extends HTMLElement {
}, 30000)
}
appendLogs(data){
if(!data.length) return;
const exid = data[0]["attrs"]["execution"]
const lt = this.#rootdoc.querySelector(`li.ccp.execution-item#${exid} d4s-ccp-logterminal`)
if(!lt){
console.error("No terminal found for adding logs of " + exid)
}else{
lt.addLines(data)
}
}
download(url, name) {
this.#boot.secureFetch(url).then(reply => {
if (!reply.ok) {

View File

@ -19,6 +19,11 @@ class LogTerminal extends HTMLElement {
return this.#lines
}
addLines(lines){
this.#lines = this.#lines.concat(lines)
this.refresh()
}
render(){
this.#rootdoc.innerHTML = `
<link href="https://fonts.googleapis.com/css2?family=VT323&display=swap" rel="stylesheet">
@ -59,6 +64,8 @@ class LogTerminal extends HTMLElement {
refresh(){
BSS.apply(this.#terminal_bss, this.#rootdoc)
const lt = this.#rootdoc.querySelector("div.terminal")
lt.scrollTop = lt.scrollHeight;
}
#terminal_bss = {
@ -67,7 +74,7 @@ class LogTerminal extends HTMLElement {
in : ()=>this,
recurse : {
target : "div.line",
in: d=>d.lines,
in: (e,d)=>d.lines,
apply: (e,d,i)=>{
if(d.source === "stderr") e.classList.add("error");
e.innerHTML = `<span>${d.line}</span>`