add saving cpu and memory resource values on exit

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
Arthur Lu 2023-02-17 22:17:20 +00:00
parent 17f243a006
commit 8dbc9d5552
2 changed files with 22 additions and 5 deletions

View File

@ -28,7 +28,7 @@
</fieldset> </fieldset>
<fieldset class="fieldset-no-border"> <fieldset class="fieldset-no-border">
<div class="btn-group" id="form-actions"> <div class="btn-group" id="form-actions">
<button id="cancel" type="button">EXIT</button> <button id="exit" type="button">EXIT</button>
</div> </div>
</fieldset> </fieldset>
</form> </form>

View File

@ -26,14 +26,12 @@ async function init () {
populateResources(); populateResources();
populateDisk(); populateDisk();
let cancelButton = document.querySelector("#cancel"); document.querySelector("#exit").addEventListener("click", handleFormExit);
cancelButton.addEventListener("click", () => {
goToPage("index.html");
});
} }
async function getConfig () { async function getConfig () {
config = await requestPVE(`/nodes/${node}/${type}/${vmid}/config`, "GET"); config = await requestPVE(`/nodes/${node}/${type}/${vmid}/config`, "GET");
console.log(config);
} }
function populateResources () { function populateResources () {
@ -466,4 +464,23 @@ async function handleCDAdd () {
}; };
dialog.show(); 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");
} }