generalize disk populating

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
Arthur Lu 2023-01-09 16:21:45 -08:00
parent cd028002a0
commit 6adf04efe8

View File

@ -44,9 +44,16 @@ async function populateForm (node, type, vmid) {
for(let j = 0; j < diskPrefixes.length; j++){ for(let j = 0; j < diskPrefixes.length; j++){
let prefix = diskPrefixes[j]; let prefix = diskPrefixes[j];
let type = diskTypes[j]; let type = diskTypes[j];
Object.keys(config.data).forEach(element => {
if (element.startsWith(prefix)) {
addDiskLine("disks", element, "images/resources/disk.svg", `${type} ${element.replace(prefix, "")}`, config.data[element]);
}
})
let i = 0; let i = 0;
while(Object.hasOwn(config.data, `${prefix}${i}`)){ while(Object.hasOwn(config.data, `${prefix}${i}`)){
addDiskLine("disks", `${prefix}${i}`, "images/resources/disk.svg", `${type} ${i}`, config.data[`${prefix}${i}`]);
i++; i++;
} }
} }