add actionLock to element power action
This commit is contained in:
parent
e6290cc058
commit
bb10726eef
@ -24,6 +24,7 @@ class Instance extends HTMLElement {
|
|||||||
shadowRoot.append(instanceLink);
|
shadowRoot.append(instanceLink);
|
||||||
|
|
||||||
this.shadowElement = shadowRoot;
|
this.shadowElement = shadowRoot;
|
||||||
|
this.actionLock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
set data (data) {
|
set data (data) {
|
||||||
@ -63,6 +64,11 @@ class Instance extends HTMLElement {
|
|||||||
powerButton.src = data.status === "running" ? "images/actions/stop.svg" : "images/actions/start.svg";
|
powerButton.src = data.status === "running" ? "images/actions/stop.svg" : "images/actions/start.svg";
|
||||||
powerButton.alt = data.status === "running" ? "shutdown instance" : "start instance";
|
powerButton.alt = data.status === "running" ? "shutdown instance" : "start instance";
|
||||||
powerButton.addEventListener("click", async () => {
|
powerButton.addEventListener("click", async () => {
|
||||||
|
if (this.actionLock) {
|
||||||
|
console.log("already doing an action");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.actionLock = true;
|
||||||
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";
|
||||||
|
|
||||||
@ -84,6 +90,8 @@ class Instance extends HTMLElement {
|
|||||||
let powerButton = this.shadowElement.querySelector("#power-btn");
|
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;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let configButton = this.shadowElement.querySelector("#configure-btn");
|
let configButton = this.shadowElement.querySelector("#configure-btn");
|
||||||
|
Loading…
Reference in New Issue
Block a user