From 4bab74b8526c2d51441b348d1d730f4e73628516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Sun, 28 Dec 2025 16:35:10 +0000 Subject: [PATCH] =?UTF-8?q?=E2=86=A9=EF=B8=8F=20return=20type=20annotation?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/components/AdminButton.vue | 6 +++--- ui/src/components/Calendar.vue | 6 +++--- ui/src/components/MultiModal.vue | 8 ++++---- ui/src/components/admin/CalendarAssistant.vue | 6 +++--- ui/src/components/admin/ConfigView.vue | 6 +++--- ui/src/components/admin/DoorMapEditor.vue | 20 +++++++++---------- ui/src/components/bulma/Drawer.vue | 4 ++-- ui/src/components/bulma/Toast.vue | 4 ++-- ui/src/components/calendar/ThouCanvas.vue | 2 +- ui/src/components/editor/DoorCanvas.vue | 12 +++++------ ui/src/components/editor/PreviewDoor.vue | 6 +++--- ui/src/lib/api_error.ts | 4 ++-- ui/src/lib/helpers.ts | 4 ++-- ui/src/lib/store.ts | 6 +++--- ui/tests/unit/rectangle.spec.ts | 2 +- 15 files changed, 48 insertions(+), 48 deletions(-) diff --git a/ui/src/components/AdminButton.vue b/ui/src/components/AdminButton.vue index 7b9deb5..ee7a4da 100644 --- a/ui/src/components/AdminButton.vue +++ b/ui/src/components/AdminButton.vue @@ -23,7 +23,7 @@ const modal_visible = ref(false); const is_busy = ref(false); const store = advent22Store(); -function on_click() { +function on_click(): void { if (store.is_admin) { store.logout(); } else { @@ -33,7 +33,7 @@ function on_click() { } } -function on_submit(creds: Credentials) { +async function on_submit(creds: Credentials): Promise { modal_visible.value = false; store @@ -42,7 +42,7 @@ function on_submit(creds: Credentials) { .finally(() => (is_busy.value = false)); } -function on_cancel() { +function on_cancel(): void { modal_visible.value = false; is_busy.value = false; } diff --git a/ui/src/components/Calendar.vue b/ui/src/components/Calendar.vue index 5750df4..18bc7cb 100644 --- a/ui/src/components/Calendar.vue +++ b/ui/src/components/Calendar.vue @@ -71,11 +71,11 @@ let modal: HMultiModal | undefined; let toast: HBulmaToast | undefined; let toast_timeout: number | undefined; -function on_modal_handle(handle: HMultiModal) { +function on_modal_handle(handle: HMultiModal): void { modal = handle; } -function on_toast_handle(handle: HBulmaToast) { +function on_toast_handle(handle: HBulmaToast): void { toast = handle; if (store.is_touch_device) return; @@ -90,7 +90,7 @@ function on_toast_handle(handle: HBulmaToast) { }); } -async function door_click(day: number) { +async function door_click(day: number): Promise { window.clearTimeout(toast_timeout); toast?.hide(); diff --git a/ui/src/components/MultiModal.vue b/ui/src/components/MultiModal.vue index 3ab049f..904bf69 100644 --- a/ui/src/components/MultiModal.vue +++ b/ui/src/components/MultiModal.vue @@ -46,11 +46,11 @@ const emit = defineEmits<{ (event: "handle", handle: HMultiModal): void; }>(); -function hide() { +function hide(): void { state.value = { show: "none" }; } -function dismiss() { +function dismiss(): void { if (state.value.show !== "loading") { hide(); } @@ -58,10 +58,10 @@ function dismiss() { onMounted(() => { emit("handle", { - show_image(src: string, caption: string = "") { + show_image(src: string, caption: string = ""): void { state.value = { show: "image", src: src, caption: caption }; }, - show_loading() { + show_loading(): void { state.value = { show: "loading" }; }, hide, diff --git a/ui/src/components/admin/CalendarAssistant.vue b/ui/src/components/admin/CalendarAssistant.vue index 3f058fd..18d440b 100644 --- a/ui/src/components/admin/CalendarAssistant.vue +++ b/ui/src/components/admin/CalendarAssistant.vue @@ -59,11 +59,11 @@ const day_data = ref>({}); let modal: HMultiModal | undefined; -function on_modal_handle(handle: HMultiModal) { +function on_modal_handle(handle: HMultiModal): void { modal = handle; } -async function on_open() { +async function on_open(): Promise { const [day_parts, day_image_names] = await Promise.all([ API.request("admin/day_parts"), API.request("admin/day_image_names"), @@ -86,7 +86,7 @@ async function on_open() { }); } -async function door_click(day: number) { +async function door_click(day: number): Promise { if (modal === undefined) return; modal.show_loading(); diff --git a/ui/src/components/admin/ConfigView.vue b/ui/src/components/admin/ConfigView.vue index d3163f6..f69b25e 100644 --- a/ui/src/components/admin/ConfigView.vue +++ b/ui/src/components/admin/ConfigView.vue @@ -247,7 +247,7 @@ function fmt_puzzle_date(name: keyof AdminConfigModel["puzzle"]): string { return DateTime.fromISO(iso_date).toLocaleString(DateTime.DATE_SHORT); } -async function on_open() { +async function on_open(): Promise { const [store_update, new_admin_config_model, new_doors] = await Promise.all([ store.update(), API.request("admin/config_model"), @@ -259,7 +259,7 @@ async function on_open() { doors.value = new_doors; } -async function load_dav_credentials() { +async function load_dav_credentials(): Promise { try { dav_credentials.value = await API.request( "admin/dav_credentials", @@ -267,7 +267,7 @@ async function load_dav_credentials() { } catch {} } -async function load_ui_credentials() { +async function load_ui_credentials(): Promise { try { ui_credentials.value = await API.request( "admin/ui_credentials", diff --git a/ui/src/components/admin/DoorMapEditor.vue b/ui/src/components/admin/DoorMapEditor.vue index 8229d0b..cce795b 100644 --- a/ui/src/components/admin/DoorMapEditor.vue +++ b/ui/src/components/admin/DoorMapEditor.vue @@ -5,7 +5,7 @@ :disabled="current_step === 0" class="level-item is-link" @click="current_step--" -:icon="['fas', 'fa-backward']" + :icon="['fas', 'fa-backward']" /> @@ -47,20 +47,20 @@ @@ -95,7 +95,7 @@ const current_step = ref(0); const loading_doors = ref(false); const saving_doors = ref(false); -async function load_doors() { +async function load_doors(): Promise { try { const data = await API.request("admin/doors"); @@ -109,7 +109,7 @@ async function load_doors() { } } -async function save_doors() { +async function save_doors(): Promise { try { const data: DoorSaved[] = []; @@ -128,7 +128,7 @@ async function save_doors() { } } -async function on_download() { +async function on_download(): Promise { if (confirm("Aktuelle Änderungen verwerfen und Status vom Server laden?")) { loading_doors.value = true; @@ -146,14 +146,14 @@ async function on_download() { } } -function on_discard() { +function on_discard(): void { if (confirm("Alle Türchen löschen? (nur lokal)")) { // empty `doors` array doors.value.length = 0; } } -async function on_upload() { +async function on_upload(): Promise { if (confirm("Aktuelle Änderungen an den Server schicken?")) { saving_doors.value = true; diff --git a/ui/src/components/bulma/Drawer.vue b/ui/src/components/bulma/Drawer.vue index b10d817..54e6239 100644 --- a/ui/src/components/bulma/Drawer.vue +++ b/ui/src/components/bulma/Drawer.vue @@ -56,7 +56,7 @@ const props = withDefaults( const state = ref<"closed" | "loading" | "ok" | "err">("closed"); const is_open = computed(() => state.value !== "closed"); -async function toggle() { +async function toggle(): Promise { if (is_open.value) { state.value = "closed"; } else { @@ -64,7 +64,7 @@ async function toggle() { } } -async function load() { +async function load(): Promise { state.value = "loading"; try { diff --git a/ui/src/components/bulma/Toast.vue b/ui/src/components/bulma/Toast.vue index 5fb3525..5586739 100644 --- a/ui/src/components/bulma/Toast.vue +++ b/ui/src/components/bulma/Toast.vue @@ -24,7 +24,7 @@ const message = useTemplateRef("message"); onMounted(() => emit("handle", { - show(options: ToastOptions = {}) { + show(options: ToastOptions = {}): void { if (message.value === null) return; toast({ @@ -33,7 +33,7 @@ onMounted(() => message: message.value, }); }, - hide() { + hide(): void { if (message.value === null) return; const toast_div = message.value.parentElement; diff --git a/ui/src/components/calendar/ThouCanvas.vue b/ui/src/components/calendar/ThouCanvas.vue index 89cc816..39cb98f 100644 --- a/ui/src/components/calendar/ThouCanvas.vue +++ b/ui/src/components/calendar/ThouCanvas.vue @@ -42,7 +42,7 @@ const emit = defineEmits<{ (event: TCEventType, e: MouseEvent, point: Vector2D): void; }>(); -function transform_mouse_event(event: MouseEvent) { +function transform_mouse_event(event: MouseEvent): void { if (!is_tceventtype(event.type)) return; emit(event.type, event, get_event_thous(event)); diff --git a/ui/src/components/editor/DoorCanvas.vue b/ui/src/components/editor/DoorCanvas.vue index 68ec78f..58ddc5f 100644 --- a/ui/src/components/editor/DoorCanvas.vue +++ b/ui/src/components/editor/DoorCanvas.vue @@ -57,7 +57,7 @@ function pop_door(point: Vector2D): VueLike | undefined { return model.value.splice(idx, 1)[0]; } -function draw_start(event: MouseEvent, point: Vector2D) { +function draw_start(event: MouseEvent, point: Vector2D): void { if (preview_visible.value) { return; } @@ -66,7 +66,7 @@ function draw_start(event: MouseEvent, point: Vector2D) { state.value = { kind: "drawing" }; } -function draw_finish() { +function draw_finish(): void { if (state.value.kind !== "drawing") { return; } @@ -78,7 +78,7 @@ function draw_finish() { state.value = { kind: "idle" }; } -function drag_start(event: MouseEvent, point: Vector2D) { +function drag_start(event: MouseEvent, point: Vector2D): void { if (preview_visible.value) { return; } @@ -94,7 +94,7 @@ function drag_start(event: MouseEvent, point: Vector2D) { state.value = { kind: "dragging", door: drag_door, origin: point }; } -function drag_finish() { +function drag_finish(): void { if (state.value.kind !== "dragging") { return; } @@ -104,7 +104,7 @@ function drag_finish() { state.value = { kind: "idle" }; } -function on_mousemove(event: MouseEvent, point: Vector2D) { +function on_mousemove(event: MouseEvent, point: Vector2D): void { if (state.value.kind === "drawing") { preview.value = preview.value.update(undefined, point); } else if (state.value.kind === "dragging") { @@ -113,7 +113,7 @@ function on_mousemove(event: MouseEvent, point: Vector2D) { } } -function remove_rect(event: MouseEvent, point: Vector2D) { +function remove_rect(event: MouseEvent, point: Vector2D): void { if (preview_visible.value) { return; } diff --git a/ui/src/components/editor/PreviewDoor.vue b/ui/src/components/editor/PreviewDoor.vue index a74f218..0c7ef61 100644 --- a/ui/src/components/editor/PreviewDoor.vue +++ b/ui/src/components/editor/PreviewDoor.vue @@ -35,12 +35,12 @@ const day_input = useTemplateRef("day_input"); const day_str = ref(""); const editing = ref(false); -function toggle_editing() { +function toggle_editing(): void { day_str.value = String(model.value.day); editing.value = !editing.value; } -function on_click(event: MouseEvent) { +function on_click(event: MouseEvent): void { if (!(event.target instanceof HTMLDivElement)) { return; } @@ -57,7 +57,7 @@ function on_click(event: MouseEvent) { toggle_editing(); } -function on_keydown(event: KeyboardEvent) { +function on_keydown(event: KeyboardEvent): void { if (!editing.value) { return; } diff --git a/ui/src/lib/api_error.ts b/ui/src/lib/api_error.ts index d9d7d4d..b3f1f78 100644 --- a/ui/src/lib/api_error.ts +++ b/ui/src/lib/api_error.ts @@ -62,14 +62,14 @@ export class APIError extends Error { return result(); } - public alert() { + public alert(): void { toast({ message: this.format(), type: "is-danger", }); } - public static alert(error: unknown) { + public static alert(error: unknown): void { new APIError(error, "").alert(); } } diff --git a/ui/src/lib/helpers.ts b/ui/src/lib/helpers.ts index 36bff86..093ff1b 100644 --- a/ui/src/lib/helpers.ts +++ b/ui/src/lib/helpers.ts @@ -26,7 +26,7 @@ export function unwrap_loading(o: Loading): T { return o; } -export function wait_for(condition: () => boolean, action: () => void) { +export function wait_for(condition: () => boolean, action: () => void): void { const enqueue_action = () => { if (!condition()) { nextTick(enqueue_action); @@ -38,7 +38,7 @@ export function wait_for(condition: () => boolean, action: () => void) { enqueue_action(); } -export function handle_error(error: unknown) { +export function handle_error(error: unknown): void { if (error instanceof APIError) { error.alert(); } else { diff --git a/ui/src/lib/store.ts b/ui/src/lib/store.ts index 2bd837f..be98bf7 100644 --- a/ui/src/lib/store.ts +++ b/ui/src/lib/store.ts @@ -110,12 +110,12 @@ export const advent22Store = defineStore({ return this.is_admin; }, - login(creds: Credentials): Promise { + async login(creds: Credentials): Promise { API.creds = { username: creds[0], password: creds[1] }; - return this.update_is_admin(); + return await this.update_is_admin(); }, - logout(): Promise { + logout() { return this.login(["", ""]); }, diff --git a/ui/tests/unit/rectangle.spec.ts b/ui/tests/unit/rectangle.spec.ts index c0a5aae..54e4154 100644 --- a/ui/tests/unit/rectangle.spec.ts +++ b/ui/tests/unit/rectangle.spec.ts @@ -16,7 +16,7 @@ describe("Rectangle Tests", () => { top: number, width: number, height: number, - ) { + ): void { expect(r.left).to.equal(left); expect(r.top).to.equal(top);