update power action button in element updater
This commit is contained in:
parent
aacb2cb86d
commit
c5137481b7
@ -63,7 +63,9 @@ class Instance extends HTMLElement {
|
|||||||
powerButton.addEventListener("click", async () => {
|
powerButton.addEventListener("click", async () => {
|
||||||
let targetAction = this.status === "running" ? "shutdown" : "start";
|
let targetAction = this.status === "running" ? "shutdown" : "start";
|
||||||
let targetStatus = this.status === "running" ? "stopped" : "running";
|
let targetStatus = this.status === "running" ? "stopped" : "running";
|
||||||
|
|
||||||
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});
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
let data = await request(`/nodes/${this.node}/${this.type}/${this.vmid}/status/current`);
|
let data = await request(`/nodes/${this.node}/${this.type}/${this.vmid}/status/current`);
|
||||||
console.log(data);
|
console.log(data);
|
||||||
@ -72,9 +74,14 @@ class Instance extends HTMLElement {
|
|||||||
}
|
}
|
||||||
await waitFor(1000);
|
await waitFor(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.status = targetStatus;
|
this.status = targetStatus;
|
||||||
|
|
||||||
let typeImg = this.shadowElement.querySelector("#instance-type");
|
let typeImg = this.shadowElement.querySelector("#instance-type");
|
||||||
typeImg.src = `images/instances/${this.type}/${this.status}.svg`;
|
typeImg.src = `images/instances/${this.type}/${this.status}.svg`;
|
||||||
|
|
||||||
|
let powerButton = this.shadowElement.querySelector("#power-btn");
|
||||||
|
powerButton.src = this.status === "running" ? "images/actions/stop.svg" : "images/actions/start.svg";
|
||||||
});
|
});
|
||||||
|
|
||||||
let configButton = this.shadowElement.querySelector("#configure-btn");
|
let configButton = this.shadowElement.querySelector("#configure-btn");
|
||||||
|
Loading…
Reference in New Issue
Block a user