populate handler for disk move

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
Arthur Lu 2023-02-02 18:26:44 +00:00
parent 4d66972aae
commit 426313a2ae
4 changed files with 28 additions and 9 deletions

View File

@ -2,6 +2,7 @@ dialog {
background-color: #000000;
border: 1px solid white;
border-radius: 5px;
padding: 10px;
}
dialog::backdrop {
@ -12,7 +13,8 @@ dialog .btn-group {
margin-top: 10px;
}
h1, h2, h3, p {
margin: 10px;
#prompt {
text-align: center;
margin-bottom: 10px;
margin-top: 0px;
}

View File

@ -242,6 +242,8 @@ async function handleDiskMove () {
let dialog = document.createElement("dialog-form");
document.body.append(dialog);
dialog.header = `Move ${this.id}`;
let label = document.createElement("label");
label.for = "storage-select";
label.innerText = "Storage";
@ -257,7 +259,23 @@ async function handleDiskMove () {
dialog.append(storageSelect);
dialog.callback = () => {
dialog.callback = async (result, form) => {
if(result === "confirm") {
let body = {
node: node,
type: type,
vmid: vmid,
action: JSON.stringify({storage: storageSelect.value, disk: this.id})
}
let result = await requestAPI("/disk/move", "POST", body);
if (result.status === 200) {
await getConfig();
populateDisk();
}
else{
console.error(result);
}
}
document.querySelector("dialog-form").remove();
};

View File

@ -143,7 +143,7 @@ export class Dialog extends HTMLElement {
<link rel="stylesheet" href="css/form.css" type="text/css">
<link rel="stylesheet" href="css/dialog.css" type="text/css">
<dialog>
<p id="header"></p>
<p id="prompt"></p>
<hr>
<form method="dialog" class="input-grid" style="grid-template-columns: auto 1fr;" id="form">
</form>
@ -161,7 +161,7 @@ export class Dialog extends HTMLElement {
}
set header (header) {
this.shadowElement.querySelector("#header").innerText = header;
this.shadowElement.querySelector("#prompt").innerText = header;
}
append (element) {

View File

@ -16,17 +16,16 @@ export class NetworkError extends Error {
export const resources = {
disk: {
//actionBarOrder: ["config", "move", "reassign", "resize", "delete_detach_attach"],
actionBarOrder: ["config", "move", "resize", "delete_detach_attach"], // handle reassign later
actionBarOrder: ["move", "resize", "delete_detach_attach"],
lxc: {
prefixOrder: ["rootfs", "mp", "unused"],
rootfs: {name: "ROOTFS", icon: "images/resources/drive.svg", actions: ["move", "resize"]},
mp: {name: "MP", icon: "images/resources/drive.svg", actions: ["config", "detach", "move", "reassign", "resize"]},
mp: {name: "MP", icon: "images/resources/drive.svg", actions: ["detach", "move", "reassign", "resize"]},
unused: {name: "UNUSED", icon: "images/resources/drive.svg", actions: ["attach", "delete", "reassign"]}
},
qemu: {
prefixOrder: ["ide", "sata", "unused"],
ide: {name: "IDE", icon: "images/resources/disk.svg", actions: ["config", "delete"]},
ide: {name: "IDE", icon: "images/resources/disk.svg", actions: ["delete"]},
sata: {name: "SATA", icon: "images/resources/drive.svg", actions: ["detach", "move", "reassign", "resize"]},
unused: {name: "UNUSED", icon: "images/resources/drive.svg", actions: ["attach", "delete", "reassign"]}
}