ccp-features #8

Merged
m.lettere merged 44 commits from ccp-features into master 2023-06-28 19:18:25 +02:00
2 changed files with 24 additions and 3 deletions
Showing only changes of commit aea66d38d8 - Show all commits

View File

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

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>`