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">
<form>
<fieldset>
<legend>Change Configuration</legend>
<div class="labels-inputs" id="user-configurable">
</div>
<legend>Name</legend>
<div class="labels-inputs" id="name"></div>
</fieldset>
<fieldset>
<legend>Resources</legend>
<div class="labels-inputs" id="resources"></div>
</fieldset>
<fieldset>
<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`);
console.log(config);
addFormLine("cores", "Cores", {type: "number", value: config.data.cores, min: 1, max: 8192});
addFormLine("memory", "Memory", {type: "number", value: config.data.memory, min: 16});
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});
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(`sata${i}`, `SATA ${i}`, {type: "text", value: sata.size});
addFormLine("resources", `sata${i}`, `SATA ${i}`, {type: "text", value: sata.size});
i++;
}
}
function addFormLine (id, labelName, inputAttr) {
let form = document.querySelector("#user-configurable");
function addFormLine (fieldset, id, labelName, inputAttr) {
let form = document.querySelector(`#${fieldset}`);
let label = document.createElement("label");
label.for = id;