add qemu and lxc instance populating

This commit is contained in:
Arthur Lu 2022-12-11 15:06:10 -08:00
parent 1f4c0310ca
commit bb06579219
2 changed files with 29 additions and 5 deletions

View File

@ -16,12 +16,12 @@ async function init () {
for (let i = 0; i < nodes.data.length; i++) {
let newNode = document.createElement("node-card");
newNode.data = nodes.data[i];
nodeContainer.append(newNode);
let qemu = await request(`/nodes/${nodes.data[i].node}/qemu`, "GET", null);
let lxc = await request(`/nodes/${nodes.data[i].node}/lxc`, "GET", null);
console.log(`${nodes.data[i].node} quemu:`);
console.log(qemu);
console.log(`${nodes.data[i].node} lxc:`);
console.log(lxc);
newNode.qemu = qemu;
newNode.lxc = lxc;
nodeContainer.append(newNode);
}
}

24
node.js
View File

@ -27,6 +27,30 @@ class Node extends HTMLElement {
onlineLabel.style.color = data.status === "online" ? "#00ff00" : "#ff0000";
articleElement.append(onlineLabel);
}
set qemu (qemu) {
let articleElement = this.shadowElement.querySelector("article");
let qemuDiv = document.createElement("div");
for (let i = 0; i < qemu.length; i++) {
let instanceParagraph = document.createElement("p");
instanceParagraph.innerText = `${qemu[i].vmid}: ${qemu[i].name}`;
qemuDiv.append(instanceParagraph);
}
articleElement.append(qemuDiv);
}
set lxc (lxc) {
let articleElement = this.shadowElement.querySelector("article");
let lxcDiv = document.createElement("div");
for (let i = 0; i < lxc.length; i++) {
let instanceParagraph = document.createElement("p");
instanceParagraph.innerText = `${lxc[i].vmid}: ${lxc[i].name}`;
lxcDiv.append(instanceParagraph);
}
articleElement.append(lxcDiv);
}
}
customElements.define("node-card", Node);