change vars export naming

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
Arthur Lu 2023-01-27 21:49:50 +00:00
parent b75f390619
commit f752baa46a
3 changed files with 15 additions and 23 deletions

View File

@ -8,6 +8,8 @@ class Instance extends HTMLElement {
let shadowRoot = this.attachShadow({mode: "open"}); let shadowRoot = this.attachShadow({mode: "open"});
shadowRoot.innerHTML = ` shadowRoot.innerHTML = `
<link rel="stylesheet" href="css/style.css" type="text/css">
<link rel="stylesheet" href="css/instance.css" type="text/css">
<article> <article>
<div> <div>
<div> <div>
@ -28,18 +30,6 @@ class Instance extends HTMLElement {
</article> </article>
`; `;
let styleLink = document.createElement("link");
styleLink.rel = "stylesheet";
styleLink.href = "css/style.css";
styleLink.type = "text/css";
shadowRoot.append(styleLink);
let instanceLink = document.createElement("link");
instanceLink.rel = "stylesheet";
instanceLink.href = "css/instance.css";
instanceLink.type = "text/css";
shadowRoot.append(instanceLink);
this.shadowElement = shadowRoot; this.shadowElement = shadowRoot;
this.actionLock = false; this.actionLock = false;
} }
@ -81,11 +71,7 @@ class Instance extends HTMLElement {
let configButton = this.shadowElement.querySelector("#configure-btn"); let configButton = this.shadowElement.querySelector("#configure-btn");
configButton.src = instances[this.status].configButtonSrc; configButton.src = instances[this.status].configButtonSrc;
configButton.alt = instances[this.status].configButtonAlt; configButton.alt = instances[this.status].configButtonAlt;
configButton.addEventListener("click", () => { configButton.addEventListener("click", this.handleConfigButton.bind(this));
if (!this.actionLock && this.status !== "running") {
goToPage("config.html", {node: this.node.name, type: this.type, vmid: this.vmid});
}
});
if (this.node.status !== "online") { if (this.node.status !== "online") {
powerButton.classList.add("hidden"); powerButton.classList.add("hidden");
@ -131,12 +117,18 @@ class Instance extends HTMLElement {
this.actionLock = false; this.actionLock = false;
return; return;
} }
else{ else{ // task has not stopped
await waitFor(1000); await waitFor(1000);
} }
} }
} }
} }
handleConfigButton () {
if (!this.actionLock && this.status === "stopped") { // if the action lock is false, and the node is stopped, then navigate to the conig page with the node infor in the search query
goToPage("config.html", {node: this.node.name, type: this.type, vmid: this.vmid});
}
}
} }
customElements.define("instance-article", Instance); customElements.define("instance-article", Instance);

View File

@ -1,4 +1,4 @@
import {pveAPI, paasAPI} from "/vars.js"; import {PVE, API} from "/vars.js";
export class ResponseError extends Error { export class ResponseError extends Error {
constructor(message) { constructor(message) {
@ -98,7 +98,7 @@ export async function requestPVE (path, method, body = null) {
content.headers.CSRFPreventionToken = getCookie("CSRFPreventionToken"); content.headers.CSRFPreventionToken = getCookie("CSRFPreventionToken");
} }
let response = await request(`${pveAPI}${path}`, content); let response = await request(`${PVE}${path}`, content);
return response; return response;
} }
@ -117,7 +117,7 @@ export async function requestAPI (path, method, body = null) {
content.headers.CSRFPreventionToken = getCookie("CSRFPreventionToken"); content.headers.CSRFPreventionToken = getCookie("CSRFPreventionToken");
} }
let response = await request(`${paasAPI}${path}`, content); let response = await request(`${API}${path}`, content);
return response; return response;
} }

View File

@ -1,2 +1,2 @@
export const pveAPI = ""; export const PVE = ""; // the proxmox web api
export const paasAPI = "" export const API = ""; // the proxmox-aas api