From dae862fc5589937dfe9d2a635f5d3bcb047913fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Thu, 2 Nov 2023 00:41:42 +0000 Subject: [PATCH] add and use $advent22.alert_user_error --- ui/src/App.vue | 2 +- ui/src/components/AdminButton.vue | 2 +- ui/src/components/Calendar.vue | 2 +- ui/src/components/UserView.vue | 2 +- ui/src/components/admin/DoorMapEditor.vue | 4 ++-- ui/src/plugins/advent22.ts | 4 ++++ 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ui/src/App.vue b/ui/src/App.vue index 284ec32..4bb1b07 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -64,7 +64,7 @@ export default class extends Vue { this.subtitle = subtitle; this.footer = footer; }) - .catch((error) => alert(this.$advent22.format_user_error(error))); + .catch(this.$advent22.alert_user_error); } } diff --git a/ui/src/components/AdminButton.vue b/ui/src/components/AdminButton.vue index feac184..09f0978 100644 --- a/ui/src/components/AdminButton.vue +++ b/ui/src/components/AdminButton.vue @@ -44,7 +44,7 @@ export default class extends Vue { this.store .login(creds) - .catch((error) => alert(this.$advent22.format_user_error(error))) + .catch(this.$advent22.alert_user_error) .finally(() => (this.is_busy = false)); } diff --git a/ui/src/components/Calendar.vue b/ui/src/components/Calendar.vue index 8b48546..7cacefa 100644 --- a/ui/src/components/Calendar.vue +++ b/ui/src/components/Calendar.vue @@ -64,7 +64,7 @@ export default class extends Vue { this.$advent22 .api_get("user/next_door") .then((next_door) => (this.next_door = next_door)) - .catch((error) => alert(this.$advent22.format_user_error(error))); + .catch(this.$advent22.alert_user_error); } public modal_handle(modal: MultiModal) { diff --git a/ui/src/components/UserView.vue b/ui/src/components/UserView.vue index 6d19a1f..cf7fe3b 100644 --- a/ui/src/components/UserView.vue +++ b/ui/src/components/UserView.vue @@ -27,7 +27,7 @@ export default class extends Vue { this.doors.push(Door.load(value)); } }) - .catch((error) => alert(this.$advent22.format_user_error(error))); + .catch(this.$advent22.alert_user_error); } } diff --git a/ui/src/components/admin/DoorMapEditor.vue b/ui/src/components/admin/DoorMapEditor.vue index 4152d05..924fb33 100644 --- a/ui/src/components/admin/DoorMapEditor.vue +++ b/ui/src/components/admin/DoorMapEditor.vue @@ -116,7 +116,7 @@ export default class extends Vue { resolve(); }) .catch((error) => { - alert(this.$advent22.format_user_error(error)); + this.$advent22.alert_user_error(error); reject(); }); }); @@ -134,7 +134,7 @@ export default class extends Vue { .api_put("admin/doors", data) .then(resolve) .catch((error) => { - alert(this.$advent22.format_user_error(error)); + this.$advent22.alert_user_error(error); reject(); }); }); diff --git a/ui/src/plugins/advent22.ts b/ui/src/plugins/advent22.ts index 4aad478..d9d3152 100644 --- a/ui/src/plugins/advent22.ts +++ b/ui/src/plugins/advent22.ts @@ -77,6 +77,10 @@ export class Advent22 { return result(); } + public alert_user_error(param: [unknown, string]): void { + alert(this.format_user_error(param)); + } + public api_url(): string; public api_url(endpoint: string): string; public api_url(endpoint?: string): string {