From 5e46481f72d2d6863926fab0bb048b44515c63bf Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Sun, 18 Dec 2022 17:06:05 -0800 Subject: [PATCH] add loading icon --- images/actions/loading.svg | 26 ++++++++++++++++++++++++++ scripts/elements.js | 4 +++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 images/actions/loading.svg diff --git a/images/actions/loading.svg b/images/actions/loading.svg new file mode 100644 index 0000000..51f38bb --- /dev/null +++ b/images/actions/loading.svg @@ -0,0 +1,26 @@ + + + + + + + + diff --git a/scripts/elements.js b/scripts/elements.js index 703c1a4..e62b54b 100644 --- a/scripts/elements.js +++ b/scripts/elements.js @@ -69,6 +69,9 @@ class Instance extends HTMLElement { let targetAction = this.status === "running" ? "shutdown" : "start"; let targetStatus = this.status === "running" ? "stopped" : "running"; + let typeImg = this.shadowElement.querySelector("#instance-type"); + typeImg.src = "images/actions/loading.svg"; + await request(`/nodes/${this.node}/${this.type}/${this.vmid}/status/${targetAction}`, "POST", {node: this.node, vmid: this.vmid}); while (true) { @@ -81,7 +84,6 @@ class Instance extends HTMLElement { this.status = targetStatus; - let typeImg = this.shadowElement.querySelector("#instance-type"); typeImg.src = `images/instances/${this.type}/${this.status}.svg`; let powerButton = this.shadowElement.querySelector("#power-btn");