From ce5eea1dde60fb0b0309fed2c3a5c13bc0812529 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Wed, 15 Feb 2023 00:17:35 +0000 Subject: [PATCH] add disk add for both vm and container Signed-off-by: Arthur Lu --- scripts/config.js | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/scripts/config.js b/scripts/config.js index e29efcd..035149f 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -183,6 +183,7 @@ async function handleDiskDetach () { } } }; + dialog.show(); } @@ -222,6 +223,7 @@ async function handleDiskAttach () { } } }; + dialog.show(); } @@ -251,6 +253,7 @@ async function handleDiskResize () { } } }; + dialog.show(); } @@ -331,6 +334,7 @@ async function handleDiskDelete () { } } }; + dialog.show(); } @@ -356,8 +360,36 @@ async function handleDiskAdd () { `; - dialog.callback = () => { + dialog.callback = async (result, form) => { + if (result === "confirm") { + let device = form.get("device"); + let storage = form.get("storage-select"); + let size = form.get("size"); + let action = {}; + + if (type === "qemu") { // type is qemu, use sata + action[`sata${device}`] = `${storage}:${size}`; + } + else { // type is lxc, use mp and add mp and backup values + action[`mp${device}`] = `${storage}:${size},mp=/mp${device}/,backup=1`; + } + + let body = { + node: node, + type: type, + vmid: vmid, + action: JSON.stringify(action) + }; + let result = await requestAPI("/disk/create", "POST", body); + if (result.status === 200) { + await getConfig(); + populateDisk(); + } + else { + console.error(result); + } + } }; dialog.show();