populate cores and memory in config

This commit is contained in:
Arthur Lu 2022-12-19 17:59:34 -08:00
parent 727c23cec3
commit bd81fdb8e6

View File

@ -13,4 +13,30 @@ async function init () {
async function populateForm (node, type, vmid) { async function populateForm (node, type, vmid) {
let config = await request(`/nodes/${node}/${type}/${vmid}/config`); let config = await request(`/nodes/${node}/${type}/${vmid}/config`);
console.log(config); console.log(config);
addFormLine("cores", {innerText: "Cores:"}, {type: "number", value: config.data.cores, min: 1, max: 8192});
addFormLine("memory", {innerText: "Memory"}, {type: "number", value: config.data.memory, min: 16});
}
function addFormLine (id, labelAttr, inputAttr) {
let labelWrapperDiv = document.createElement("div");
let label = document.createElement("label");
label.for = id;
for (k in labelAttr) {
label.k = labelAttr.k;
}
labelWrapperDiv.append(label);
let labelContainer = document.querySelector("#labels");
labelContainer.append(labelWrapperDiv);
let inputWrapperDiv = document.createElement("div");
let input = document.createElement("input");
input.id = id;
input.name = id;
for (k in inputAttr) {
input.k = inputAttr.k;
}
inputWrapperDiv.append(input);
let inputContainer = document.querySelector("#inputs");
inputContainer.append(inputWrapperDiv);
} }