diff --git a/css/dialog.css b/css/dialog.css index 55105ff..b5fd25e 100644 --- a/css/dialog.css +++ b/css/dialog.css @@ -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; } \ No newline at end of file diff --git a/scripts/config.js b/scripts/config.js index 0950a41..75fc164 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -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(); }; diff --git a/scripts/elements.js b/scripts/elements.js index 3e4c9da..14d28f6 100644 --- a/scripts/elements.js +++ b/scripts/elements.js @@ -143,7 +143,7 @@ export class Dialog extends HTMLElement { - +


@@ -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) { diff --git a/scripts/utils.js b/scripts/utils.js index b50ba4c..b366f55 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -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"]} }