ProxmoxAAS-Dashboard/scripts/index.js

29 lines
902 B
JavaScript
Raw Normal View History

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;
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-14 21:37:30 +00:00
let instances = [];
2022-12-11 23:24:19 +00:00
2022-12-14 21:37:30 +00:00
let instanceContainer = document.getElementById("instance-container")
for (let i = 0; i < nodes.data.length; i++) {
let qemu = await request(`/nodes/${nodes.data[i].node}/qemu`, "GET");
let lxc = await request(`/nodes/${nodes.data[i].node}/lxc`, "GET");
2022-12-14 21:40:19 +00:00
instances = instances.concat(qemu.data, lxc.data);
2022-12-14 21:37:30 +00:00
}
instances.sort((a, b) => (a.vmid > b.vmid) ? 1 : -1);
2022-12-11 23:06:10 +00:00
2022-12-14 21:37:30 +00:00
for(let i = 0; i < instances.length; i++) {
let newInstance = document.createElement("instance-article");
newInstance.data = instances[i];
instanceContainer.append(newInstance);
2022-12-11 02:02:29 +00:00
}
}