populate vm name

This commit is contained in:
Arthur Lu 2022-12-20 17:07:58 -08:00
parent aa4085f312
commit 1f3ee1c456
2 changed files with 13 additions and 8 deletions

View File

@ -12,9 +12,12 @@
<div class="center-div"> <div class="center-div">
<form> <form>
<fieldset> <fieldset>
<legend>Change Configuration</legend> <legend>Name</legend>
<div class="labels-inputs" id="user-configurable"> <div class="labels-inputs" id="name"></div>
</div> </fieldset>
<fieldset>
<legend>Resources</legend>
<div class="labels-inputs" id="resources"></div>
</fieldset> </fieldset>
<fieldset> <fieldset>
<div class="btn-group" id="form-actions"> <div class="btn-group" id="form-actions">

View File

@ -24,21 +24,23 @@ 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", "Cores", {type: "number", value: config.data.cores, min: 1, max: 8192}); addFormLine("name", "name", "Name:", {type: "text", value: config.data.name});
addFormLine("memory", "Memory", {type: "number", value: config.data.memory, min: 16});
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});
let i = 0; let i = 0;
while(Object.hasOwn(config.data, `sata${i}`)){ while(Object.hasOwn(config.data, `sata${i}`)){
let sata = config.data[`sata${i}`]; let sata = config.data[`sata${i}`];
sata = `{"${sata.replaceAll(":", '":"').replaceAll("=", '":"').replaceAll(",", '","')}"}`; sata = `{"${sata.replaceAll(":", '":"').replaceAll("=", '":"').replaceAll(",", '","')}"}`;
sata = JSON.parse(sata); sata = JSON.parse(sata);
addFormLine(`sata${i}`, `SATA ${i}`, {type: "text", value: sata.size}); addFormLine("resources", `sata${i}`, `SATA ${i}`, {type: "text", value: sata.size});
i++; i++;
} }
} }
function addFormLine (id, labelName, inputAttr) { function addFormLine (fieldset, id, labelName, inputAttr) {
let form = document.querySelector("#user-configurable"); let form = document.querySelector(`#${fieldset}`);
let label = document.createElement("label"); let label = document.createElement("label");
label.for = id; label.for = id;