ProxmoxAAS-Dashboard/scripts/elements.js

59 lines
1.7 KiB
JavaScript
Raw Normal View History

2022-12-12 04:20:32 +00:00
class Instance extends HTMLElement {
constructor () {
super();
let shadowRoot = this.attachShadow({mode: "open"});
2022-12-14 21:37:30 +00:00
let instanceArticle = document.createElement("article");
shadowRoot.append(instanceArticle);
2022-12-12 04:20:32 +00:00
let styleLink = document.createElement("link");
styleLink.rel = "stylesheet";
styleLink.href = "css/style.css";
2022-12-12 04:20:32 +00:00
styleLink.type = "text/css";
shadowRoot.append(styleLink);
2022-12-14 22:30:46 +00:00
let instanceLink = document.createElement("link");
instanceLink.rel = "stylesheet";
instanceLink.href = "css/instance.css";
instanceLink.type = "text/css";
shadowRoot.append(instanceLink);
2022-12-12 04:20:32 +00:00
this.shadowElement = shadowRoot;
}
set data (data) {
2022-12-14 21:37:30 +00:00
let instanceArticle = this.shadowElement.querySelector("article");
2022-12-12 04:20:32 +00:00
2022-12-14 23:38:13 +00:00
let detailDiv = document.createElement("div");
detailDiv.classList.add("instance-div");
2022-12-14 23:32:22 +00:00
2022-12-14 23:28:22 +00:00
let typeImg = document.createElement("img");
typeImg.src = `images/instances/${data.type}/${data.status}.svg`;
2022-12-14 23:38:13 +00:00
detailDiv.append(typeImg);
2022-12-14 23:28:22 +00:00
let vmidParagraph = document.createElement("p");
vmidParagraph.innerText = data.vmid;
2022-12-14 23:38:13 +00:00
detailDiv.append(vmidParagraph);
2022-12-14 23:28:22 +00:00
let nameParagraph = document.createElement("p");
nameParagraph.innerText = data.name;
2022-12-14 23:38:13 +00:00
detailDiv.append(nameParagraph);
2022-12-14 23:32:22 +00:00
2022-12-14 23:38:13 +00:00
instanceArticle.append(detailDiv);
let nodeDiv = document.createElement("div");
nodeDiv.classList.add("instance-div");
2022-12-14 23:28:22 +00:00
let nodeImg = document.createElement("img");
2022-12-14 23:29:08 +00:00
nodeImg.src = `images/nodes/${data.node.status}.svg`;
2022-12-14 23:38:13 +00:00
nodeDiv.append(nodeImg);
2022-12-14 23:28:22 +00:00
let nodeParagraph = document.createElement("p");
nodeParagraph.innerText = data.node.name;
2022-12-14 23:38:13 +00:00
nodeDiv.append(nodeParagraph);
instanceArticle.append(nodeDiv);
2022-12-12 04:20:32 +00:00
}
}
2022-12-14 21:37:30 +00:00
customElements.define("instance-article", Instance);