Merge branch 'ccp-features' of https://code-repo.d4science.org/gCubeSystem/cdn-experiments into ccp-features

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

View File

@ -277,10 +277,13 @@ class CCPExecutionHistory extends HTMLElement {
this.#socket = new WebSocket(this.#broadcasturl + "/executions"); this.#socket = new WebSocket(this.#broadcasturl + "/executions");
this.#socket.onmessage = event=>{ this.#socket.onmessage = event=>{
const data = JSON.parse(event.data) 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 return
} }
let exec = this.#data.filter(e=>e.id === data.jobID)[0] let exec = this.#data.filter(e=>e.id === data.jobID)[0]
if(exec){ if(exec){
this.refreshExecution(exec.id) this.refreshExecution(exec.id)
@ -306,6 +309,17 @@ class CCPExecutionHistory extends HTMLElement {
}, 30000) }, 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) { download(url, name) {
this.#boot.secureFetch(url).then(reply => { this.#boot.secureFetch(url).then(reply => {
if (!reply.ok) { if (!reply.ok) {

View File

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