add node vmid cores and memory limits to inputs in instance create form

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
Arthur Lu 2023-05-12 21:14:49 +00:00
parent c459dad024
commit 759571535e
2 changed files with 15 additions and 7 deletions

View File

@ -15,13 +15,13 @@ async function init () {
if (cookie === "") {
goToPage("login.html");
}
let user = await requestAPI("/user");
let resources = user.resources;
let instances = user.instances;
let resources = await requestAPI("/user/resources");
let instances = await requestAPI("/user/instances");
let nodes = await requestAPI("/user/nodes");
document.querySelector("#username").innerText = `Username: ${getCookie("username")}`;
document.querySelector("#pool").innerText = `Pool: ${instances.pool}`;
document.querySelector("#vmid").innerText = `VMID Range: ${instances.vmid.min} - ${instances.vmid.max}`;
document.querySelector("#nodes").innerText = `Nodes: ${user.nodes.toString()}`;
document.querySelector("#nodes").innerText = `Nodes: ${nodes.toString()}`;
buildResourceTable(resources, "#resource-table");
}

View File

@ -125,6 +125,13 @@ async function handleInstanceAdd () {
}
});
let userResources = await requestAPI("/user/resources", "GET");
let userInstances = await requestAPI("/user/instances", "GET")
d.querySelector("#cores").max = userResources.avail.cores;
d.querySelector("#memory").max = userResources.avail.memory;
d.querySelector("#vmid").min = userInstances.vmid.min;
d.querySelector("#vmid").max = userInstances.vmid.max;
let typeSelect = d.querySelector("#type");
typeSelect.selectedIndex = -1;
typeSelect.addEventListener("change", () => {
@ -151,9 +158,10 @@ async function handleInstanceAdd () {
rootfsStorage.selectedIndex = -1;
let nodeSelect = d.querySelector("#node");
let nodes = await requestPVE("/nodes", "GET");
nodes.data.forEach((element) => {
if (element.status === "online") {
let clusterNodes = await requestPVE("/nodes", "GET");
let allowedNodes = await requestAPI("/user/nodes", "GET");
clusterNodes.data.forEach((element) => {
if (element.status === "online" && allowedNodes.includes(element.node)) {
nodeSelect.add(new Option(element.node));
}
});