ccp-features #8
|
@ -115,7 +115,7 @@ class CCPExecutionHistory extends HTMLElement {
|
|||
<span class="badge" name="runtime" alt="Runtime" title="Runtime"></span>
|
||||
</div>
|
||||
<div style="margin:5px 0 5px 0">
|
||||
<d4s-ccp-logterminal maxlines="10"></d4s-ccp-logterminal>
|
||||
<d4s-ccp-logterminal maxstoredlines="100" maxlines="10"></d4s-ccp-logterminal>
|
||||
</div>
|
||||
<ul>
|
||||
<li></li>
|
||||
|
@ -278,7 +278,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
|
||||
|
@ -312,7 +312,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{
|
||||
|
@ -648,6 +648,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 : [
|
||||
|
|
|
@ -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(){
|
||||
|
|
Loading…
Reference in New Issue