From: Michael Tremer Date: Fri, 4 Jul 2025 13:53:37 +0000 (+0000) Subject: frontend: Create a store and listing component for mirrors X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1dfb847316b868770beec8bfb90cf64afff01b1;p=pbs.git frontend: Create a store and listing component for mirrors Signed-off-by: Michael Tremer --- diff --git a/frontend/src/api/mirrors.ts b/frontend/src/api/mirrors.ts index a082f335..b0c5301b 100644 --- a/frontend/src/api/mirrors.ts +++ b/frontend/src/api/mirrors.ts @@ -1,5 +1,45 @@ import api from "@/api" -import type { Mirror } from "@/types/Mirror"; + +export interface Mirror { + // Hostanme + hostname: string; + + // Path + path: string; + + // Owner + owner: string; + + // Contact + contact: string; + + // Notes + notes: string; + + // Country Code + country_code: string; + + // ASN + asn: number; + + // AS Name + as_name: string | null; + + // Supports IPv6? + supports_ipv6: boolean; + + // Supports IPv4? + supports_ipv4: boolean; + + // Last Check Was Successful? + last_check_success: boolean; + + // Last Check At + last_check_at: Date; + + // Last Sync At + last_sync_at: Date; +} // Fetch all mirrors export async function fetchMirrors(): Promise { diff --git a/frontend/src/components/MirrorList.vue b/frontend/src/components/MirrorList.vue new file mode 100644 index 00000000..a907bd2f --- /dev/null +++ b/frontend/src/components/MirrorList.vue @@ -0,0 +1,51 @@ + + + diff --git a/frontend/src/stores/mirrors.ts b/frontend/src/stores/mirrors.ts new file mode 100644 index 00000000..f76ef9b6 --- /dev/null +++ b/frontend/src/stores/mirrors.ts @@ -0,0 +1,27 @@ +import { defineStore } from "pinia" + +// Fetch the mirror API +import type { Mirror } from "@/api/mirrors" +import { fetchMirrors } from "@/api/mirrors" + +export const useMirrorStore = defineStore("mirrors", { + state: () => ({ + mirrors: [] as Mirror[], + loading: false, + error: null as string | null, + }), + + actions: { + async loadMirrors() { + this.loading = true + this.error = null + try { + this.mirrors = await fetchMirrors() + } catch (err) { + this.error = "Failed to load mirrors" + } finally { + this.loading = false + } + }, + }, +}) diff --git a/frontend/src/types/Mirror.ts b/frontend/src/types/Mirror.ts deleted file mode 100644 index 7bbb6905..00000000 --- a/frontend/src/types/Mirror.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - Defines a Mirror -*/ -export interface Mirror { - // Hostanme - hostname: string; - - // Path - path: string; - - // Owner - owner: string; - - // Contact - contact: string; - - // Notes - notes: string; - - // Country Code - country_code: string; - - // ASN - asn: number; - - // AS Name - as_name: string | null; - - // Supports IPv6? - supports_ipv6: boolean; - - // Supports IPv4? - supports_ipv4: boolean; - - // Last Check Was Successful? - last_check_success: boolean; - - // Last Check At - last_check_at: Date; - - // Last Sync At - last_sync_at: Date; -} diff --git a/frontend/src/views/MirrorsView.vue b/frontend/src/views/MirrorsView.vue index 1323ccfb..bae033a3 100644 --- a/frontend/src/views/MirrorsView.vue +++ b/frontend/src/views/MirrorsView.vue @@ -1,51 +1,11 @@