2022-12-11 06:49:10 +00:00
|
|
|
import {requestTicket, setTicket, request} from "./utils.js";
|
|
|
|
|
2022-12-11 02:02:29 +00:00
|
|
|
window.addEventListener("DOMContentLoaded", init);
|
|
|
|
|
|
|
|
async function init () {
|
|
|
|
let cookie = document.cookie;
|
2022-12-11 06:49:10 +00:00
|
|
|
if (cookie === '') {
|
2022-12-12 22:57:43 +00:00
|
|
|
window.location.href = "login.html";
|
2022-12-11 02:02:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let nodes = await request("/nodes", "GET", null);
|
2022-12-11 23:24:19 +00:00
|
|
|
nodes.data.sort((a, b) => (a.node > b.node) ? 1 : -1);
|
|
|
|
|
2022-12-11 06:49:10 +00:00
|
|
|
let nodeContainer = document.getElementById("node-container")
|
|
|
|
for (let i = 0; i < nodes.data.length; i++) {
|
2022-12-12 04:20:32 +00:00
|
|
|
let newNode = document.createElement("node-article");
|
2022-12-11 06:49:10 +00:00
|
|
|
newNode.data = nodes.data[i];
|
2022-12-11 23:06:10 +00:00
|
|
|
|
2022-12-11 22:54:50 +00:00
|
|
|
let qemu = await request(`/nodes/${nodes.data[i].node}/qemu`, "GET", null);
|
2022-12-11 23:24:19 +00:00
|
|
|
qemu.data.sort((a, b) => (a.vmid > b.vmid) ? 1 : -1);
|
2022-12-11 22:54:50 +00:00
|
|
|
let lxc = await request(`/nodes/${nodes.data[i].node}/lxc`, "GET", null);
|
2022-12-11 23:24:19 +00:00
|
|
|
lxc.data.sort((a, b) => (a.vmid > b.vmid) ? 1 : -1);
|
2022-12-11 23:07:44 +00:00
|
|
|
newNode.qemu = qemu.data;
|
|
|
|
newNode.lxc = lxc.data;
|
2022-12-11 23:06:10 +00:00
|
|
|
|
|
|
|
nodeContainer.append(newNode);
|
2022-12-11 02:02:29 +00:00
|
|
|
}
|
|
|
|
}
|