sort nodes and instances

This commit is contained in:
Arthur Lu 2022-12-11 15:24:19 -08:00
parent 3a3d405c6d
commit 42aa765533

View File

@ -12,13 +12,17 @@ async function init () {
} }
let nodes = await request("/nodes", "GET", null); let nodes = await request("/nodes", "GET", null);
nodes.data.sort((a, b) => (a.node > b.node) ? 1 : -1);
let nodeContainer = document.getElementById("node-container") let nodeContainer = document.getElementById("node-container")
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];
let qemu = await request(`/nodes/${nodes.data[i].node}/qemu`, "GET", null); let qemu = await request(`/nodes/${nodes.data[i].node}/qemu`, "GET", null);
qemu.data.sort((a, b) => (a.vmid > b.vmid) ? 1 : -1);
let lxc = await request(`/nodes/${nodes.data[i].node}/lxc`, "GET", null); let lxc = await request(`/nodes/${nodes.data[i].node}/lxc`, "GET", null);
lxc.data.sort((a, b) => (a.vmid > b.vmid) ? 1 : -1);
newNode.qemu = qemu.data; newNode.qemu = qemu.data;
newNode.lxc = lxc.data; newNode.lxc = lxc.data;