From f3e6856cd3cd05bdf6d067d8d04eab9caffc9bf2 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Sun, 8 Jan 2023 20:32:15 -0800 Subject: [PATCH] populate name field using addMetaLine --- scripts/config.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/config.js b/scripts/config.js index 399871f..1fe42e2 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -25,7 +25,7 @@ async function populateForm (node, type, vmid) { console.log(config); 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/ram.svg", "Memory", {type: "number", value: config.data, min: 16, step: 1}, "MiB"); // TODO add max from quota API 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) { let field = document.querySelector(`#${fieldset}`);