fixed several issues with rendering and synch

This commit is contained in:
dcore94 2023-06-23 16:40:02 +02:00
parent 242753e3dc
commit c96c98c38b
2 changed files with 19 additions and 11 deletions

View File

@ -114,8 +114,7 @@ class CCPExecutionHistory extends HTMLElement {
<span style="text-overflow:ellipsis" class="badge badge-light text-info border border-info" name="infrastructure" alt="Infrastructure" title="Infrastructure"></span>
<span class="badge" name="runtime" alt="Runtime" title="Runtime"></span>
</div>
<div style="margin:5px 0 5px 0">
<d4s-ccp-logterminal maxstoredlines="100" maxlines="10"></d4s-ccp-logterminal>
<div name="logterminalcontainer" style="margin:5px 0 5px 0">
</div>
<ul>
<li></li>
@ -312,7 +311,7 @@ class CCPExecutionHistory extends HTMLElement {
appendLogs(data){
if(!data.length) return;
const exid = data[0]["attrs"]["execution"]
const lt = this.#rootdoc.querySelector(`d4s-ccp-logterminal[index=${exid}]`)
const lt = this.#rootdoc.querySelector(`d4s-ccp-logterminal[index='${exid}']`)
if(!lt){
console.error("No terminal found for adding logs of " + exid)
}else{
@ -649,9 +648,9 @@ class CCPExecutionHistory extends HTMLElement {
}
},
{
target : "d4s-ccp-logterminal",
target : "div[name=logterminalcontainer]",
apply : (e,d)=>{
e.setAttribute("index", d.id)
e.innerHTML = `<d4s-ccp-logterminal index="${d.id}" maxstoredlines="100" maxlines="10"></d4s-ccp-logterminal>`
}
},
{

View File

@ -6,12 +6,13 @@ class LogTerminal extends HTMLElement {
#lines = [];
#index = null;
static get observedAttributes() { return ['index']; }
constructor(){
super()
this.#maxlines = this.getAttribute("maxlines")
this.#rootdoc = this.attachShadow({ "mode" : "open"})
this.render()
this.#index = this.getAttribute("index")
}
connectedCallback(){
@ -19,6 +20,13 @@ class LogTerminal extends HTMLElement {
this.refresh()
}
attributeChangedCallback(name, oldValue, newValue) {
if(name === "index"){
this.#index = newValue
this.reloadLines()
}
}
get lines(){
return this.#lines
}
@ -30,8 +38,9 @@ class LogTerminal extends HTMLElement {
}
reloadLines(){
if(this.#index == null) return;
if(sessionStorage.getItem("logs-" + this.#index)){
this.#lines = sessionStorage.getItem("logs-" + this.#index)
this.#lines = JSON.parse(sessionStorage.getItem("logs-" + this.#index))
}else{
this.#lines = []
}
@ -41,7 +50,7 @@ class LogTerminal extends HTMLElement {
if(this.#lines.length > this.#maxstoredlines){
this.#lines.splice(0, this.#lines.length - this.#maxstoredlines)
}
sessionStorage.setItem("logs-" + this.#index, this.#lines)
sessionStorage.setItem("logs-" + this.#index, JSON.stringify(this.#lines))
}
render(){