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 bceb816478
commit 93b1450d8c
4 changed files with 28 additions and 9 deletions

View File

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

View File

@ -242,6 +242,8 @@ async function handleDiskMove () {
let dialog = document.createElement("dialog-form"); let dialog = document.createElement("dialog-form");
document.body.append(dialog); document.body.append(dialog);
dialog.header = `Move ${this.id}`;
let label = document.createElement("label"); let label = document.createElement("label");
label.for = "storage-select"; label.for = "storage-select";
label.innerText = "Storage"; label.innerText = "Storage";
@ -257,7 +259,23 @@ async function handleDiskMove () {
dialog.append(storageSelect); 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(); 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/form.css" type="text/css">
<link rel="stylesheet" href="css/dialog.css" type="text/css"> <link rel="stylesheet" href="css/dialog.css" type="text/css">
<dialog> <dialog>
<p id="header"></p> <p id="prompt"></p>
<hr> <hr>
<form method="dialog" class="input-grid" style="grid-template-columns: auto 1fr;" id="form"> <form method="dialog" class="input-grid" style="grid-template-columns: auto 1fr;" id="form">
</form> </form>
@ -161,7 +161,7 @@ export class Dialog extends HTMLElement {
} }
set header (header) { set header (header) {
this.shadowElement.querySelector("#header").innerText = header; this.shadowElement.querySelector("#prompt").innerText = header;
} }
append (element) { append (element) {

View File

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