From ca8df3ba10978a9012f317ab276a8c24583544ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Fri, 3 Nov 2023 17:07:25 +0000 Subject: [PATCH] move user/next_door call to "store" --- ui/src/components/Calendar.vue | 14 -------------- ui/src/components/CountDown.vue | 10 +++------- ui/src/components/UserView.vue | 24 +++++++++++------------- ui/src/components/admin/ConfigView.vue | 14 ++++++++------ ui/src/plugins/store.ts | 18 ++++++++++++++---- 5 files changed, 36 insertions(+), 44 deletions(-) diff --git a/ui/src/components/Calendar.vue b/ui/src/components/Calendar.vue index 7cacefa..224cc22 100644 --- a/ui/src/components/Calendar.vue +++ b/ui/src/components/Calendar.vue @@ -4,10 +4,6 @@
{{ figure_caption }} -
@@ -33,7 +29,6 @@ import { Door } from "@/lib/door"; import { advent22Store } from "@/plugins/store"; import { Options, Vue } from "vue-class-component"; -import CountDown from "./CountDown.vue"; import MultiModal from "./MultiModal.vue"; import BulmaButton from "./bulma/Button.vue"; import CalendarDoor from "./calendar/CalendarDoor.vue"; @@ -41,7 +36,6 @@ import ThouCanvas from "./calendar/ThouCanvas.vue"; @Options({ components: { - CountDown, MultiModal, BulmaButton, ThouCanvas, @@ -58,14 +52,6 @@ export default class extends Vue { private multi_modal?: MultiModal; public figure_caption = this.idle_caption; - public next_door: number | null = null; - - public mounted(): void { - this.$advent22 - .api_get("user/next_door") - .then((next_door) => (this.next_door = next_door)) - .catch(this.$advent22.alert_user_error); - } public modal_handle(modal: MultiModal) { this.multi_modal = modal; diff --git a/ui/src/components/CountDown.vue b/ui/src/components/CountDown.vue index 6836801..e68163a 100644 --- a/ui/src/components/CountDown.vue +++ b/ui/src/components/CountDown.vue @@ -8,7 +8,7 @@ import { Options, Vue } from "vue-class-component"; @Options({ props: { - millis: Number, + until: Number, tick_time: { type: Number, default: 200, @@ -16,18 +16,14 @@ import { Options, Vue } from "vue-class-component"; }, }) export default class extends Vue { - private millis!: number; + private until!: number; private tick_time!: number; private interval_id: number | null = null; public string_repr = ""; - private get target_date_ms(): number { - return Date.now() + this.millis; - } - private tick(): void { - const distance_ms = this.target_date_ms - Date.now(); + const distance_ms = this.until - Date.now(); if (distance_ms <= 0) { this.string_repr = "Jetzt!"; diff --git a/ui/src/components/UserView.vue b/ui/src/components/UserView.vue index 05a1986..e745bfd 100644 --- a/ui/src/components/UserView.vue +++ b/ui/src/components/UserView.vue @@ -1,34 +1,32 @@