From 7539ff731b61f13c52fc34fde883f8d47da3ea25 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Fri, 17 Feb 2023 22:17:20 +0000 Subject: [PATCH] add saving cpu and memory resource values on exit Signed-off-by: Arthur Lu --- config.html | 2 +- scripts/config.js | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/config.html b/config.html index 0752a65..99b7bd1 100644 --- a/config.html +++ b/config.html @@ -28,7 +28,7 @@
- +
diff --git a/scripts/config.js b/scripts/config.js index 3c44663..8925bbb 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -26,14 +26,12 @@ async function init () { populateResources(); populateDisk(); - let cancelButton = document.querySelector("#cancel"); - cancelButton.addEventListener("click", () => { - goToPage("index.html"); - }); + document.querySelector("#exit").addEventListener("click", handleFormExit); } async function getConfig () { config = await requestPVE(`/nodes/${node}/${type}/${vmid}/config`, "GET"); + console.log(config); } function populateResources () { @@ -466,4 +464,23 @@ async function handleCDAdd () { }; dialog.show(); +} + +async function handleFormExit () { + let body = { + node: node, + type: type, + vmid: vmid, + cores: document.querySelector("#Cores").value, + memory: document.querySelector("#Memory").value + } + let result = await requestAPI("/resources", "POST", body); + if (result.status === 200) { + await getConfig(); + populateDisk(); + } + else { + console.error(result); + } + goToPage("index.html"); } \ No newline at end of file