add options to disk image selection
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
c0cd6a546e
commit
5ccf122ca6
@ -101,7 +101,7 @@ function addResourceLine (fieldset, iconHref, labelText, inputAttr, unitText=nul
|
||||
}
|
||||
}
|
||||
|
||||
function addDiskLine (fieldset, busPrefix, busName, device, diskDataParsed, storageOptions) {
|
||||
async function addDiskLine (fieldset, busPrefix, busName, device, diskDataParsed, storageOptions) {
|
||||
let field = document.querySelector(`#${fieldset}`);
|
||||
|
||||
let icon = document.createElement("img");
|
||||
@ -139,6 +139,7 @@ function addDiskLine (fieldset, busPrefix, busName, device, diskDataParsed, stor
|
||||
storageSelect.id = `${busPrefix}_${device}_storage`;
|
||||
field.append(storageSelect);
|
||||
|
||||
if (diskConfig[type][busPrefix].resizable) {
|
||||
let size = diskDataParsed.size;
|
||||
let sizeInput = document.createElement("input");
|
||||
sizeInput.type = "number";
|
||||
@ -146,19 +147,40 @@ function addDiskLine (fieldset, busPrefix, busName, device, diskDataParsed, stor
|
||||
sizeInput.minSize = size;
|
||||
sizeInput.max = 131072; // 128 TiB, everything should just use GiB
|
||||
sizeInput.value = size;
|
||||
if (!diskConfig[type][busPrefix].resizable) {
|
||||
sizeInput.disabled = true;
|
||||
sizeInput.classList.add("hidden");
|
||||
}
|
||||
sizeInput.id = `${busPrefix}_${device}_size`;
|
||||
field.append(sizeInput);
|
||||
|
||||
let sizeUnit = document.createElement("p");
|
||||
sizeUnit.innerText = "GiB";
|
||||
if (!diskConfig[type][busPrefix].resizable) {
|
||||
sizeUnit.classList.add("hidden");
|
||||
}
|
||||
field.append(sizeUnit);
|
||||
}
|
||||
else if (diskConfig[type][busPrefix].hasPath) {
|
||||
let pathInput = document.createElement("input");
|
||||
pathInput.value = diskDataParsed.mp;
|
||||
pathInput.id = `${busPrefix}_${device}_path`;
|
||||
field.append(pathInput);
|
||||
|
||||
let blank = document.createElement("div");
|
||||
field.append(blank);
|
||||
}
|
||||
else if (diskConfig[type][busPrefix].hasDiskImage) {
|
||||
let diskImageSelect = document.createElement("select");
|
||||
let diskImageOptions = await request(`/nodes/${node}/storage/${storage}/content?content=iso`);
|
||||
diskImageOptions.data.forEach((element) => {
|
||||
diskImageSelect.add(new Option(element.replace(`${storage}:`), element));
|
||||
});
|
||||
field.append(diskImageSelect);
|
||||
|
||||
let blank = document.createElement("div");
|
||||
field.append(blank);
|
||||
}
|
||||
else {
|
||||
let blank1 = document.createElement("div");
|
||||
field.append(blank1);
|
||||
|
||||
let blank2 = document.createElement("div");
|
||||
field.append(blank2);
|
||||
}
|
||||
|
||||
let deleteDiv = document.createElement("div");
|
||||
deleteDiv.classList.add("last-item");
|
||||
@ -201,3 +223,7 @@ function parseDisk (disk) { // disk in format: STORAGE: FILENAME, ARG1=..., ARG2
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
function getDiskImageOptions (storage) {
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user