diff --git a/config.html b/config.html index cb1f297..08086e1 100644 --- a/config.html +++ b/config.html @@ -13,11 +13,11 @@
Name -
+
Resources -
+
diff --git a/css/form.css b/css/form.css index 93f2b95..a2dddcc 100644 --- a/css/form.css +++ b/css/form.css @@ -29,9 +29,9 @@ button { margin-top: 0px; } -.labels-inputs { +.labels-inputs-units { display: grid; - grid-template-columns: auto auto; + grid-template-columns: auto auto auto; column-gap: 10px; } diff --git a/scripts/config.js b/scripts/config.js index 9cf4158..ff2357a 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -26,26 +26,26 @@ async function populateForm (node, type, vmid) { addFormLine("name", "name", "Name", {type: "text", value: config.data.name}); - addFormLine("resources", "cores", "Cores", {type: "number", value: config.data.cores, min: 1, max: 8192}); - addFormLine("resources", "memory", "Memory", {type: "number", value: config.data.memory, min: 16}); + addFormLine("resources", "cores", "Cores", {type: "number", value: config.data.cores, min: 1, max: 8192}, "Threads"); + addFormLine("resources", "memory", "Memory", {type: "number", value: config.data.memory / 1024, min: 16}, "GiB"); let i = 0; while(Object.hasOwn(config.data, `sata${i}`)){ let sata = config.data[`sata${i}`]; sata = `{"${sata.replaceAll(":", '":"').replaceAll("=", '":"').replaceAll(",", '","')}"}`; sata = JSON.parse(sata); - addFormLine("resources", `sata${i}`, `SATA ${i}`, {type: "text", value: sata.size}); + addFormLine("resources", `sata${i}`, `SATA ${i}`, {type: "text", value: sata.size.slice(0, sata.size.length - 1)}, sata.size.includes("G") ? "GiB" : "MiB"); i++; } } -function addFormLine (fieldset, id, labelName, inputAttr) { - let form = document.querySelector(`#${fieldset}`); +function addFormLine (fieldset, id, labelValue, inputAttr, unitValue="") { + let field = document.querySelector(`#${fieldset}`); let label = document.createElement("label"); label.for = id; - label.innerHTML = labelName; - form.append(label); + label.innerHTML = labelValue; + field.append(label); let input = document.createElement("input"); input.id = id; @@ -53,5 +53,9 @@ function addFormLine (fieldset, id, labelName, inputAttr) { for (let k in inputAttr) { input.setAttribute(k, inputAttr[k]) } - form.append(input); + field.append(input); + + let unit = document.createElement("p"); + unit.innerText = unitValue; + field.append(unit) } \ No newline at end of file