diff --git a/ccp/js/executionhistorycontroller.js b/ccp/js/executionhistorycontroller.js
index bb7fc12..8cc3ee9 100644
--- a/ccp/js/executionhistorycontroller.js
+++ b/ccp/js/executionhistorycontroller.js
@@ -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) {
diff --git a/ccp/js/logterminalcontroller.js b/ccp/js/logterminalcontroller.js
index 50f8418..a5e2747 100644
--- a/ccp/js/logterminalcontroller.js
+++ b/ccp/js/logterminalcontroller.js
@@ -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 = `
@@ -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 = `${d.line}`