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-11 02:02:29 +00:00
|
|
|
let username = prompt("username: ");
|
|
|
|
let password = prompt("password: ")
|
|
|
|
let ticket = await requestTicket(username, password);
|
|
|
|
setTicket(ticket.data.ticket);
|
|
|
|
}
|
|
|
|
|
|
|
|
let nodes = await request("/nodes", "GET", null);
|
2022-12-11 06:49:10 +00:00
|
|
|
let nodeContainer = document.getElementById("node-container")
|
|
|
|
for (let i = 0; i < nodes.data.length; i++) {
|
|
|
|
let newNode = document.createElement("node-card");
|
|
|
|
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);
|
|
|
|
let lxc = await request(`/nodes/${nodes.data[i].node}/lxc`, "GET", null);
|
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
|
|
|
}
|
|
|
|
}
|