diff --git a/css/instance.css b/css/instance.css index 983a560..d36934f 100644 --- a/css/instance.css +++ b/css/instance.css @@ -4,7 +4,7 @@ article { margin: 0px; } -.instance-div { +.summary-div { display: flex; align-items: center; justify-content: space-between; diff --git a/index.html b/index.html index 36b40b3..2cc2793 100644 --- a/index.html +++ b/index.html @@ -11,4 +11,20 @@
+ + \ No newline at end of file diff --git a/scripts/elements.js b/scripts/elements.js index 4ee9200..305bb5e 100644 --- a/scripts/elements.js +++ b/scripts/elements.js @@ -3,8 +3,9 @@ class Instance extends HTMLElement { super(); let shadowRoot = this.attachShadow({mode: "open"}); - let instanceArticle = document.createElement("article"); - shadowRoot.append(instanceArticle); + let instanceTemplate = document.querySelector("#instance-template"); + let instanceTemplateContent = instanceTemplate.textContent; + shadowRoot.append(instanceTemplateContent.cloneNode(true)); let styleLink = document.createElement("link"); styleLink.rel = "stylesheet"; @@ -24,40 +25,20 @@ class Instance extends HTMLElement { set data (data) { let instanceArticle = this.shadowElement.querySelector("article"); - let summaryDiv = document.createElement("div"); - summaryDiv.classList.add("instance-div"); - - let instanceSubDiv = document.createElement("div"); - instanceSubDiv.classList.add("summary-sub-div"); - - let typeImg = document.createElement("img"); + let typeImg = document.querySelector("#instance-type"); typeImg.src = `images/instances/${data.type}/${data.status}.svg`; - instanceSubDiv.append(typeImg); - let vmidParagraph = document.createElement("p"); + let vmidParagraph = document.querySelector("#instance-id"); vmidParagraph.innerText = data.vmid; - instanceSubDiv.append(vmidParagraph); - let nameParagraph = document.createElement("p"); + let nameParagraph = document.querySelector("#instance-name"); nameParagraph.innerText = data.name; - instanceSubDiv.append(nameParagraph); - summaryDiv.append(instanceSubDiv); - - let nodeSubDiv = document.createElement("div"); - nodeSubDiv.classList.add("summary-sub-div"); - - let nodeImg = document.createElement("img"); + let nodeImg = document.querySelector("#node-status"); nodeImg.src = `images/nodes/${data.node.status}.svg`; - nodeSubDiv.append(nodeImg); - let nodeParagraph = document.createElement("p"); + let nodeParagraph = document.querySelector("#node-name"); nodeParagraph.innerText = data.node.name; - nodeSubDiv.append(nodeParagraph); - - summaryDiv.append(nodeSubDiv); - - instanceArticle.append(summaryDiv); } }