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 8d2171bc78
commit c88f44bfdb

View File

@ -44,9 +44,16 @@ async function populateForm (node, type, vmid) {
for(let j = 0; j < diskPrefixes.length; j++){
let prefix = diskPrefixes[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;
while(Object.hasOwn(config.data, `${prefix}${i}`)){
addDiskLine("disks", `${prefix}${i}`, "images/resources/disk.svg", `${type} ${i}`, config.data[`${prefix}${i}`]);
i++;
}
}