ccp-features #8
|
@ -277,10 +277,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)
|
||||
|
@ -306,6 +309,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) {
|
||||
|
|
|
@ -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>`
|
||||
|
|
Loading…
Reference in New Issue