streamline add disk code
This commit is contained in:
parent
1575fa33fd
commit
7799954b0f
@ -71,60 +71,12 @@ async function populateForm (node, type, vmid) {
|
|||||||
});
|
});
|
||||||
let def = diskConfig[type].prefixOrder[0];
|
let def = diskConfig[type].prefixOrder[0];
|
||||||
addDiskBus.value = def;
|
addDiskBus.value = def;
|
||||||
let entry = diskConfig[type][def];
|
handleDiskBusChange();
|
||||||
let limit = entry.limit;
|
|
||||||
let addDiskDevice = document.querySelector("#add-disk #device");
|
|
||||||
addDiskDevice.max = limit;
|
|
||||||
let nextAvaliable = getNextAvaliable(entry);
|
|
||||||
if (nextAvaliable > limit) {
|
|
||||||
addDiskDevice.value = 0;
|
|
||||||
addDiskDevice.style.border = "solid red 1px";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
addDiskDevice.value = nextAvaliable;
|
|
||||||
addDiskDevice.style.border = "solid white 1px";
|
|
||||||
}
|
|
||||||
|
|
||||||
addDiskBus.addEventListener("change", () => {
|
addDiskBus.addEventListener("change", handleDiskBusChange);
|
||||||
let value = document.querySelector("#add-disk #bus").value;
|
|
||||||
let entry = diskConfig[type][value];
|
|
||||||
let limit = entry.limit;
|
|
||||||
let addDiskDevice = document.querySelector("#add-disk #device");
|
|
||||||
addDiskDevice.max = limit;
|
|
||||||
let nextAvaliable = getNextAvaliable(entry);
|
|
||||||
if (nextAvaliable > limit) {
|
|
||||||
addDiskDevice.value = 0;
|
|
||||||
addDiskDevice.style.border = "solid red 1px";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
addDiskDevice.value = nextAvaliable;
|
|
||||||
addDiskDevice.style.border = "solid white 1px";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
addDiskDevice.addEventListener("input", () => {
|
addDiskDevice.addEventListener("input", handleDiskDeviceChange);
|
||||||
let value = document.querySelector("#add-disk #device").value;
|
addDiskDevice.addEventListener("focus", handleDiskDeviceChange);
|
||||||
let bus = document.querySelector("#add-disk #bus").value;
|
|
||||||
let entry = diskConfig[type][bus];
|
|
||||||
if(value in entry.used){
|
|
||||||
addDiskDevice.style.border = "solid red 1px";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
addDiskDevice.style.border = "solid white 1px";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
addDiskDevice.addEventListener("focus", () => {
|
|
||||||
let value = document.querySelector("#add-disk #device").value;
|
|
||||||
let bus = document.querySelector("#add-disk #bus").value;
|
|
||||||
let entry = diskConfig[type][bus];
|
|
||||||
if(value in entry.used){
|
|
||||||
addDiskDevice.style.border = "solid red 1px";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
addDiskDevice.style.border = "solid white 1px";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let addDiskStorage = document.querySelector("#add-disk #storage");
|
let addDiskStorage = document.querySelector("#add-disk #storage");
|
||||||
let addDiskSize = document.querySelector("#add-disk #size");
|
let addDiskSize = document.querySelector("#add-disk #size");
|
||||||
@ -148,6 +100,34 @@ function getNextAvaliable(entry){
|
|||||||
return nextAvaliable;
|
return nextAvaliable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleDiskBusChange () {
|
||||||
|
let bus = document.querySelector("#add-disk #bus").value;
|
||||||
|
let entry = diskConfig[type][bus];
|
||||||
|
let limit = entry.limit;
|
||||||
|
let addDiskDevice = document.querySelector("#add-disk #device");
|
||||||
|
addDiskDevice.max = limit;
|
||||||
|
let nextAvaliable = getNextAvaliable(entry);
|
||||||
|
if (nextAvaliable > limit) {
|
||||||
|
addDiskDevice.value = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addDiskDevice.value = nextAvaliable;
|
||||||
|
}
|
||||||
|
handleDiskDeviceChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDiskDeviceChange () {
|
||||||
|
let value = document.querySelector("#add-disk #device").value;
|
||||||
|
let bus = document.querySelector("#add-disk #bus").value;
|
||||||
|
let entry = diskConfig[type][bus];
|
||||||
|
if(value in entry.used){
|
||||||
|
addDiskDevice.style.border = "solid red 1px";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addDiskDevice.style.border = "solid white 1px";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function addMetaLine (fieldset, labelText, inputAttr) {
|
function addMetaLine (fieldset, labelText, inputAttr) {
|
||||||
let field = document.querySelector(`#${fieldset}`);
|
let field = document.querySelector(`#${fieldset}`);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user