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++) { for (let i = 0; i < nodes.data.length; i++) {
let newNode = document.createElement("node-card"); let newNode = document.createElement("node-card");
newNode.data = nodes.data[i]; newNode.data = nodes.data[i];
nodeContainer.append(newNode);
let qemu = await request(`/nodes/${nodes.data[i].node}/qemu`, "GET", null); let qemu = await request(`/nodes/${nodes.data[i].node}/qemu`, "GET", null);
let lxc = await request(`/nodes/${nodes.data[i].node}/lxc`, "GET", null); let lxc = await request(`/nodes/${nodes.data[i].node}/lxc`, "GET", null);
console.log(`${nodes.data[i].node} quemu:`); newNode.qemu = qemu;
console.log(qemu); newNode.lxc = lxc;
console.log(`${nodes.data[i].node} lxc:`);
console.log(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"; onlineLabel.style.color = data.status === "online" ? "#00ff00" : "#ff0000";
articleElement.append(onlineLabel); 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); customElements.define("node-card", Node);