From 6adf04efe8b02886c0b205e39d845d373c8faa15 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Mon, 9 Jan 2023 16:21:45 -0800 Subject: [PATCH] generalize disk populating Signed-off-by: Arthur Lu --- scripts/config.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/config.js b/scripts/config.js index 9f7cdd4..3ac1063 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -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++; } }