fix bugs with draggable container value,
fix bugs with draggable item value after drop, fix bugs with boot entry details, improve addBootLine deleteBootLine updateBootLine
This commit is contained in:
parent
9b42fd236c
commit
e6f622d643
@ -12,7 +12,6 @@ let node;
|
|||||||
let type;
|
let type;
|
||||||
let vmid;
|
let vmid;
|
||||||
let config;
|
let config;
|
||||||
const bootEntries = {};
|
|
||||||
|
|
||||||
async function init () {
|
async function init () {
|
||||||
setTitleAndHeader();
|
setTitleAndHeader();
|
||||||
@ -267,7 +266,7 @@ async function handleDiskAttach () {
|
|||||||
}
|
}
|
||||||
await getConfig();
|
await getConfig();
|
||||||
populateDisk();
|
populateDisk();
|
||||||
addBootLine("disabled", { id: disk, prefix, value: config.data[disk] });
|
addBootLine("disabled", { id: disk, prefix, value: disk, detail: config.data[disk] });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -290,7 +289,7 @@ async function handleDiskResize () {
|
|||||||
await getConfig();
|
await getConfig();
|
||||||
populateDisk();
|
populateDisk();
|
||||||
const prefix = bootMetaData.eligiblePrefixes.find((pref) => disk.startsWith(pref));
|
const prefix = bootMetaData.eligiblePrefixes.find((pref) => disk.startsWith(pref));
|
||||||
updateBootLine(`boot-${disk}`, { id: disk, prefix, value: config.data[disk] });
|
updateBootLine(`boot-${disk}`, { id: disk, prefix, value: disk, detail: config.data[disk] });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -387,7 +386,7 @@ async function handleDiskAdd () {
|
|||||||
}
|
}
|
||||||
await getConfig();
|
await getConfig();
|
||||||
populateDisk();
|
populateDisk();
|
||||||
addBootLine("disabled", { id: disk, prefix, value: config.data[disk] });
|
addBootLine("disabled", { id: disk, prefix, value: disk, detail: config.data[disk] });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -424,7 +423,7 @@ async function handleCDAdd () {
|
|||||||
}
|
}
|
||||||
await getConfig();
|
await getConfig();
|
||||||
populateDisk();
|
populateDisk();
|
||||||
addBootLine("disabled", { id: disk, prefix: "ide", value: config.data[disk] });
|
addBootLine("disabled", { id: disk, prefix: "ide", value: disk, detail: config.data[disk] });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -571,7 +570,8 @@ async function handleNetworkAdd () {
|
|||||||
}
|
}
|
||||||
await getConfig();
|
await getConfig();
|
||||||
populateNetworks();
|
populateNetworks();
|
||||||
addBootLine("disabled", { id: `net${netID}`, prefix: "net", value: config.data[`net${netID}`] });
|
const id = `net${netID}`;
|
||||||
|
addBootLine("disabled", { id, prefix: "net", value: id, detail: config.data[`net${netID}`] });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -733,13 +733,13 @@ async function populateBoot () {
|
|||||||
const element = order[i];
|
const element = order[i];
|
||||||
const prefix = eligible.find((pref) => order[i].startsWith(pref));
|
const prefix = eligible.find((pref) => order[i].startsWith(pref));
|
||||||
const detail = config.data[element];
|
const detail = config.data[element];
|
||||||
bootable[i] = { id: element, prefix, detail };
|
bootable[i] = { id: element, value: element, prefix, detail };
|
||||||
}
|
}
|
||||||
Object.keys(config.data).forEach((element) => {
|
Object.keys(config.data).forEach((element) => {
|
||||||
const prefix = eligible.find((pref) => element.startsWith(pref));
|
const prefix = eligible.find((pref) => element.startsWith(pref));
|
||||||
const detail = config.data[element];
|
const detail = config.data[element];
|
||||||
if (prefix && !order.includes(element)) {
|
if (prefix && !order.includes(element)) {
|
||||||
bootable.disabled.push({ id: element, prefix, detail });
|
bootable.disabled.push({ id: element, value: element, prefix, detail });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Object.keys(bootable).sort();
|
Object.keys(bootable).sort();
|
||||||
@ -775,16 +775,30 @@ function addBootLine (container, data, before = null) {
|
|||||||
document.querySelector(`#${container}`).append(item);
|
document.querySelector(`#${container}`).append(item);
|
||||||
}
|
}
|
||||||
item.container = container;
|
item.container = container;
|
||||||
item.value = data.id;
|
item.value = data.value;
|
||||||
bootEntries[item.id] = item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteBootLine (id) {
|
function deleteBootLine (id) {
|
||||||
bootEntries[id].parentElement.removeChild(bootEntries[id]);
|
let enabled = document.querySelector("#enabled");
|
||||||
|
let disabled = document.querySelector("#disabled");
|
||||||
|
if (enabled.getItemByID(id)) {
|
||||||
|
enabled.deleteItemByID(id);
|
||||||
|
}
|
||||||
|
if (disabled.getItemByID(id)) {
|
||||||
|
disabled.deleteItemByID(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateBootLine (id, newData) {
|
function updateBootLine (id, newData) {
|
||||||
const element = bootEntries[id];
|
let enabled = document.querySelector("#enabled");
|
||||||
|
let disabled = document.querySelector("#disabled");
|
||||||
|
let element = null;
|
||||||
|
if (enabled.getItemByID(id)) {
|
||||||
|
element = enabled.getItemByID(id);
|
||||||
|
}
|
||||||
|
if (disabled.getItemByID(id)) {
|
||||||
|
element = disabled.getItemByID(id)
|
||||||
|
}
|
||||||
if (element) {
|
if (element) {
|
||||||
const container = element.container;
|
const container = element.container;
|
||||||
const before = element.nextSibling;
|
const before = element.nextSibling;
|
||||||
|
@ -29,6 +29,10 @@ class DraggableContainer extends HTMLElement {
|
|||||||
this.content.insertBefore(newNode, referenceNode);
|
this.content.insertBefore(newNode, referenceNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getItemByID (nodeid) {
|
||||||
|
return this.content.querySelector(`#${nodeid}`);
|
||||||
|
}
|
||||||
|
|
||||||
deleteItemByID (nodeid) {
|
deleteItemByID (nodeid) {
|
||||||
const node = this.content.querySelector(`#${nodeid}`);
|
const node = this.content.querySelector(`#${nodeid}`);
|
||||||
if (node) {
|
if (node) {
|
||||||
@ -117,14 +121,14 @@ class DraggableItem extends HTMLElement {
|
|||||||
event.target.borderTop = false;
|
event.target.borderTop = false;
|
||||||
}
|
}
|
||||||
if (event.target.classList.contains("drop-target")) {
|
if (event.target.classList.contains("drop-target")) {
|
||||||
const data = JSON.parse(event.dataTransfer.getData("application/json"));
|
const transfer = JSON.parse(event.dataTransfer.getData("application/json"));
|
||||||
const item = document.createElement("draggable-item");
|
const item = document.createElement("draggable-item");
|
||||||
item.data = data.data;
|
item.data = transfer.data;
|
||||||
item.innerHTML = data.content;
|
item.innerHTML = transfer.content;
|
||||||
item.draggable = true;
|
item.draggable = true;
|
||||||
item.classList.add("drop-target");
|
item.classList.add("drop-target");
|
||||||
item.id = `boot-${data.id}`;
|
item.id = `boot-${transfer.data.id}`;
|
||||||
item.value = data.value;
|
item.value = transfer.data.value;
|
||||||
event.target.parentElement.insertBefore(item, event.target);
|
event.target.parentElement.insertBefore(item, event.target);
|
||||||
}
|
}
|
||||||
this.content.attributeStyleMap.clear();
|
this.content.attributeStyleMap.clear();
|
||||||
|
Loading…
Reference in New Issue
Block a user