set proper alt for instance type/status and power action
This commit is contained in:
parent
5e46481f72
commit
0c5f20677e
@ -66,11 +66,17 @@ class Instance extends HTMLElement {
|
|||||||
powerButton.addEventListener("click", async () => {
|
powerButton.addEventListener("click", async () => {
|
||||||
if (!this.actionLock) {
|
if (!this.actionLock) {
|
||||||
this.actionLock = true;
|
this.actionLock = true;
|
||||||
|
|
||||||
let targetAction = this.status === "running" ? "shutdown" : "start";
|
let targetAction = this.status === "running" ? "shutdown" : "start";
|
||||||
|
let targetActionDesc = targetAction === "start" ? "starting" : "shutting down";
|
||||||
let targetStatus = this.status === "running" ? "stopped" : "running";
|
let targetStatus = this.status === "running" ? "stopped" : "running";
|
||||||
|
|
||||||
let typeImg = this.shadowElement.querySelector("#instance-type");
|
let typeImg = this.shadowElement.querySelector("#instance-type");
|
||||||
typeImg.src = "images/actions/loading.svg";
|
typeImg.src = "images/actions/loading.svg";
|
||||||
|
typeImg.alt = `instance is ${targetActionDesc}`;
|
||||||
|
let powerButton = this.shadowElement.querySelector("#power-btn");
|
||||||
|
powerButton.src = "images/actions/loading.svg";
|
||||||
|
powerButton.alt = `instance is ${targetActionDesc}`;
|
||||||
|
|
||||||
await request(`/nodes/${this.node}/${this.type}/${this.vmid}/status/${targetAction}`, "POST", {node: this.node, vmid: this.vmid});
|
await request(`/nodes/${this.node}/${this.type}/${this.vmid}/status/${targetAction}`, "POST", {node: this.node, vmid: this.vmid});
|
||||||
|
|
||||||
@ -85,10 +91,11 @@ class Instance extends HTMLElement {
|
|||||||
this.status = targetStatus;
|
this.status = targetStatus;
|
||||||
|
|
||||||
typeImg.src = `images/instances/${this.type}/${this.status}.svg`;
|
typeImg.src = `images/instances/${this.type}/${this.status}.svg`;
|
||||||
|
typeImg.alt = `${this.status} instance`;
|
||||||
|
|
||||||
let powerButton = this.shadowElement.querySelector("#power-btn");
|
|
||||||
powerButton.src = this.status === "running" ? "images/actions/stop.svg" : "images/actions/start.svg";
|
powerButton.src = this.status === "running" ? "images/actions/stop.svg" : "images/actions/start.svg";
|
||||||
powerButton.alt = this.status === "running" ? "shutdown instance" : "start instance";
|
powerButton.alt = this.status === "running" ? "shutdown instance" : "start instance";
|
||||||
|
|
||||||
this.actionLock = false;
|
this.actionLock = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user