diff --git a/ccp/js/executionhistorycontroller.js b/ccp/js/executionhistorycontroller.js
index 8cc3ee9..e46267c 100644
--- a/ccp/js/executionhistorycontroller.js
+++ b/ccp/js/executionhistorycontroller.js
@@ -112,7 +112,7 @@ class CCPExecutionHistory extends HTMLElement {
-
+
@@ -275,7 +275,7 @@ class CCPExecutionHistory extends HTMLElement {
this.#socket.onmessage = event=>{
const data = JSON.parse(event.data)
- if(data[0].source){
+ if(data[0] && data[0].source){
//has to be logs
this.appendLogs(data)
return
@@ -309,7 +309,7 @@ class CCPExecutionHistory extends HTMLElement {
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`)
+ const lt = this.#rootdoc.querySelector(`d4s-ccp-logterminal[index=${exid}]`)
if(!lt){
console.error("No terminal found for adding logs of " + exid)
}else{
@@ -630,6 +630,12 @@ class CCPExecutionHistory extends HTMLElement {
this.generateCode(id, lang, `${id}.${ext}`)
}
},
+ {
+ target : "d4s-ccp-logterminal",
+ apply : (e,d)=>{
+ e.setAttribute("index", d.id)
+ }
+ },
{
target : "ul",
recurse : [
diff --git a/ccp/js/logterminalcontroller.js b/ccp/js/logterminalcontroller.js
index a5e2747..0c70c8b 100644
--- a/ccp/js/logterminalcontroller.js
+++ b/ccp/js/logterminalcontroller.js
@@ -1,18 +1,22 @@
class LogTerminal extends HTMLElement {
#maxlines = 10;
+ #maxstoredlines = 100;
#rootdoc = null;
- #lines = []
+ #lines = [];
+ #index = null;
constructor(){
super()
this.#maxlines = this.getAttribute("maxlines")
this.#rootdoc = this.attachShadow({ "mode" : "open"})
this.render()
+ this.#index = this.getAttribute("index")
}
connectedCallback(){
-
+ this.reloadLines()
+ this.refresh()
}
get lines(){
@@ -22,6 +26,22 @@ class LogTerminal extends HTMLElement {
addLines(lines){
this.#lines = this.#lines.concat(lines)
this.refresh()
+ this.storeLines()
+ }
+
+ reloadLines(){
+ if(sessionStorage.getItem("logs-" + this.#index)){
+ this.#lines = sessionStorage.getItem("logs-" + this.#index)
+ }else{
+ this.#lines = []
+ }
+ }
+
+ storeLines(){
+ if(this.#lines.length > this.#maxstoredlines){
+ this.#lines.splice(0, this.#lines.length - this.#maxstoredlines)
+ }
+ sessionStorage.setItem("logs-" + this.#index, this.#lines)
}
render(){