From 8df92a470e38990ed294aa9f44d569301cca4b5c Mon Sep 17 00:00:00 2001 From: Robin Dittmar Date: Tue, 1 Sep 2026 17:03:23 +0200 Subject: [PATCH] feat: use new version endpoint to display api information --- src/api/version.ts | 10 +++++++++ src/types/version.ts | 5 +++++ src/views/AccountView.vue | 46 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 src/api/version.ts create mode 100644 src/types/version.ts diff --git a/src/api/version.ts b/src/api/version.ts new file mode 100644 index 0000000..af779f0 --- /dev/null +++ b/src/api/version.ts @@ -0,0 +1,10 @@ +import { API_BASE_URL, extractErrorMessage } from '@/api/http' +import type { VersionInfo } from '@/types/version' + +export async function getVersionApi(): Promise { + const response = await fetch(`${API_BASE_URL}/version`) + if (!response.ok) { + throw new Error(await extractErrorMessage(response, 'Failed to load API version')) + } + return response.json() +} diff --git a/src/types/version.ts b/src/types/version.ts new file mode 100644 index 0000000..b7cbe2b --- /dev/null +++ b/src/types/version.ts @@ -0,0 +1,5 @@ +export interface VersionInfo { + version: string + commit: string + buildTime: string +} diff --git a/src/views/AccountView.vue b/src/views/AccountView.vue index 53df3d2..a10494e 100644 --- a/src/views/AccountView.vue +++ b/src/views/AccountView.vue @@ -2,6 +2,8 @@ import { onMounted, ref } from 'vue' import { useListsStore } from '@/stores/lists' import { useAuthStore } from '@/stores/auth' +import { getVersionApi } from '@/api/version' +import type { VersionInfo } from '@/types/version' import ChangePasswordModal from '@/components/ChangePasswordModal.vue' import InvitesPanel from '@/components/InvitesPanel.vue' @@ -9,10 +11,27 @@ const listsStore = useListsStore() const authStore = useAuthStore() const showChangePassword = ref(false) +const versionInfo = ref(null) +const versionError = ref('') +const isLoadingVersion = ref(false) onMounted(() => { listsStore.loadLists() + loadVersion() }) + +async function loadVersion() { + isLoadingVersion.value = true + versionError.value = '' + try { + versionInfo.value = await getVersionApi() + } catch (err) { + versionError.value = err instanceof Error ? err.message : 'Failed to load API information' + } finally { + isLoadingVersion.value = false + } +} + @@ -107,4 +147,10 @@ onMounted(() => { margin-top: 0.6rem; padding: 0.5rem 1rem; } + +.loading-text { + font-size: 0.85rem; + color: var(--c-text-soft); + margin: 0; +}