From bd81fdb8e6bf732c9fd54d342a44ea8c5a600bf7 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Mon, 19 Dec 2022 17:59:34 -0800 Subject: [PATCH] populate cores and memory in config --- scripts/config.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/scripts/config.js b/scripts/config.js index 68aeddb..81752ec 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -13,4 +13,30 @@ async function init () { async function populateForm (node, type, vmid) { let config = await request(`/nodes/${node}/${type}/${vmid}/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); } \ No newline at end of file