diff --git a/ui/src/components/DoorMapEditor.vue b/ui/src/components/DoorMapEditor.vue
index 01c55ae..ce278c2 100644
--- a/ui/src/components/DoorMapEditor.vue
+++ b/ui/src/components/DoorMapEditor.vue
@@ -27,6 +27,7 @@
class="card-footer-item is-danger"
@click="on_download"
icon="fa-solid fa-cloud-arrow-down"
+ :busy="loading_doors"
text="Laden"
/>
@@ -78,14 +80,22 @@ export default class extends Vue {
public current_step = 0;
public doors: Door[] = [];
- private load_doors(): Promise {
- return this.$advent22.api_get("admin/doors").then((data) => {
- this.doors.length = 0;
+ public loading_doors = false;
+ public saving_doors = false;
- for (const value of data) {
- this.doors.push(Door.load(value));
- }
- });
+ private load_doors(): Promise {
+ return this.$advent22
+ .api_get("admin/doors")
+ .then((data) => {
+ this.doors.length = 0;
+
+ for (const value of data) {
+ this.doors.push(Door.load(value));
+ }
+
+ this.is_loaded = true;
+ })
+ .catch(([reason, endpoint]) => alert(`Fehler: ${reason} in ${endpoint}`));
}
private save_doors(): Promise {
@@ -95,32 +105,24 @@ export default class extends Vue {
data.push(door.save());
}
- return this.$advent22.api_put("admin/doors", data);
+ return this.$advent22
+ .api_put("admin/doors", data)
+ .catch((reason) => alert(`Fehler: ${reason} in admin/doors`));
}
public on_open(): void {
this.is_loaded = false;
-
- this.load_doors()
- .then(() => (this.is_loaded = true))
- .catch(([reason, endpoint]) => {
- alert(`Fehler: ${reason} in ${endpoint}`);
- });
- }
-
- public mounted(): void {
- this.load_doors().catch(([reason, endpoint]) => {
- alert(`Fehler: ${reason} in ${endpoint}`);
- });
+ this.load_doors();
}
public on_download() {
if (confirm("Aktuelle Ă„nderungen verwerfen und Status vom Server laden?")) {
- this.load_doors()
- .then(() => alert("Erfolgeich!"))
- .catch(([reason, endpoint]) => {
- alert(`Fehler: ${reason} in ${endpoint}`);
- });
+ this.loading_doors = true;
+
+ this.load_doors().then(() => {
+ alert("Erfolgeich!");
+ this.loading_doors = false;
+ });
}
}
@@ -133,15 +135,14 @@ export default class extends Vue {
public on_upload() {
if (confirm("Aktuelle Ă„nderungen an den Server schicken?")) {
- this.save_doors()
- .then(() => {
- this.load_doors()
- .then(() => alert("Erfolgeich!"))
- .catch(([reason, endpoint]) =>
- alert(`Fehler: ${reason} in ${endpoint}`),
- );
- })
- .catch((reason) => alert(`Fehler: ${reason}`));
+ this.saving_doors = true;
+
+ this.save_doors().then(() => {
+ this.load_doors().then(() => {
+ alert("Erfolgeich!");
+ this.saving_doors = false;
+ });
+ });
}
}
}