code cleanup

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
Arthur Lu 2023-05-15 20:16:38 +00:00
parent 56bf77df96
commit b5c181b818
5 changed files with 12 additions and 11 deletions

View File

@ -125,13 +125,6 @@ async function handleInstanceAdd () {
}
});
let userResources = await requestAPI("/user/resources", "GET");
let userInstances = await requestAPI("/user/instances", "GET")
d.querySelector("#cores").max = userResources.avail.cores;
d.querySelector("#memory").max = userResources.avail.memory;
d.querySelector("#vmid").min = userInstances.vmid.min;
d.querySelector("#vmid").max = userInstances.vmid.max;
let typeSelect = d.querySelector("#type");
typeSelect.selectedIndex = -1;
typeSelect.addEventListener("change", () => {
@ -193,4 +186,11 @@ async function handleInstanceAdd () {
});
templateImage.selectedIndex = -1;
});
let userResources = await requestAPI("/user/resources", "GET");
let userInstances = await requestAPI("/user/instances", "GET");
d.querySelector("#cores").max = userResources.avail.cores;
d.querySelector("#memory").max = userResources.avail.memory;
d.querySelector("#vmid").min = userInstances.vmid.min;
d.querySelector("#vmid").max = userInstances.vmid.max;
}

View File

@ -1,5 +1,6 @@
import {requestPVE, requestAPI, goToPage, goToURL, instances, nodes} from "./utils.js";
import {alert, dialog} from "./dialog.js";
import {PVE} from "../vars.js"
export class Instance extends HTMLElement {
constructor () {
@ -168,7 +169,7 @@ export class Instance extends HTMLElement {
if (!this.actionLock && this.status === "running") {
let data = {console: `${this.type === "qemu" ? "kvm" : "lxc"}`, vmid: this.vmid, vmname: this.name, node: this.node.name, resize: "off", cmd: ""};
data[`${this.type === "qemu" ? "novnc" : "xtermjs"}`] = 1;
goToURL("https://pve.tronnet.net", data, true);
goToURL(PVE, data, true);
}
}

View File

@ -1,4 +1,4 @@
import {requestTicket, NetworkError, goToPage, deleteAllCookies, requestPVE} from "./utils.js";
import {requestTicket, goToPage, deleteAllCookies, requestPVE} from "./utils.js";
import {alert} from "./dialog.js";
window.addEventListener("DOMContentLoaded", init);

View File

@ -197,6 +197,5 @@ export function getURIData () {
}
export async function deleteAllCookies () {
document.cookie.split(";").forEach(function(c) { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/;domain=.client.tronnet.net;"); });
await requestAPI("/ticket", "DELETE");
}

View File

@ -1 +1,2 @@
export const API = "https://client.mydomain.example/api"; // the proxmox-aas api
export const API = "https://client.mydomain.example/api"; // the proxmox-aas api
export const PVE = "https://pve.mydomain.example"; // the proxmox api