populate name field using addMetaLine

This commit is contained in:
Arthur Lu 2023-01-08 20:32:15 -08:00
parent eb4970344f
commit b95187ee2c

View File

@ -25,7 +25,7 @@ async function populateForm (node, type, vmid) {
console.log(config); console.log(config);
let name = type === "qemu" ? "name" : "hostname"; let name = type === "qemu" ? "name" : "hostname";
addResourceLine("name", null, "Name", {type: "text", value: config.data[name]}); addMetaLine("name", "Name", {type: "text", value: config.data[name]});
addResourceLine("resources", "images/resources/cpu.svg", "Cores", {type: "number", value: config.data.cores, min: 1, max: 8192}, "Threads"); // TODO add max from quota API addResourceLine("resources", "images/resources/cpu.svg", "Cores", {type: "number", value: config.data.cores, min: 1, max: 8192}, "Threads"); // TODO add max from quota API
addResourceLine("resources", "images/resources/ram.svg", "Memory", {type: "number", value: config.data, min: 16, step: 1}, "MiB"); // TODO add max from quota API addResourceLine("resources", "images/resources/ram.svg", "Memory", {type: "number", value: config.data, min: 16, step: 1}, "MiB"); // TODO add max from quota API
if (type === "lxc") { if (type === "lxc") {
@ -41,6 +41,20 @@ async function populateForm (node, type, vmid) {
} }
} }
function addMetaLine (fieldset, labelText, inputAttr) {
let field = document.querySelector(`#${fieldset}`);
let label = document.createElement("label");
label.innerHTML = labelText;
field.append(label);
let input = document.createElement("input");
for (let k in inputAttr) {
input.setAttribute(k, inputAttr[k])
}
field.append(input);
}
function addResourceLine (fieldset, iconHref, labelText, inputAttr, unitText=null) { function addResourceLine (fieldset, iconHref, labelText, inputAttr, unitText=null) {
let field = document.querySelector(`#${fieldset}`); let field = document.querySelector(`#${fieldset}`);