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<Mirror[]> {
--- /dev/null
+<script setup lang="ts">
+ import { onMounted } from 'vue'
+ import { useMirrorStore } from '@/stores/mirrors'
+ import { getCountryName } from "@/utils/i18n"
+
+ // Components
+ import Box from "@/components/Box.vue"
+ import Loader from "@/components/Loader.vue"
+ import Notification from "@/components/Notification.vue"
+ import Tags from "@/components/Tags.vue"
+ import Tag from "@/components/Tag.vue"
+
+ // Load the store
+ const mirrorStore = useMirrorStore()
+
+ // Load all mirrors
+ onMounted(() => {
+ mirrorStore.loadMirrors()
+ })
+</script>
+
+<template>
+ <Loader v-if="mirrorStore.loading" />
+
+ <Notification v-else-if="mirrorStore.error" is-danger>
+ {{ mirrorStore.error }}
+ </Notification>
+
+ <Box v-else v-for="mirror in mirrorStore.mirrors" :key="mirror.hostname"
+ :title="mirror.hostname" :subtitle="mirror.owner">
+ <div class="level">
+ <!-- Show the country -->
+ <div class="level-item">
+ {{ getCountryName(mirror.country_code) }}
+ </div>
+
+ <!-- Show tags of which protocols are supported -->
+ <div class="level-item">
+ <Tags>
+ <Tag v-if="mirror.supports_ipv6" :title="$t('Supports IPv6')" is-success>
+ {{ $t('IPv6') }}
+ </Tag>
+
+ <Tag v-if="mirror.supports_ipv4" :title="$t('Supports IPv4')" is-success>
+ {{ $t('IPv4') }}
+ </Tag>
+ </Tags>
+ </div>
+ </div>
+ </Box>
+</template>
--- /dev/null
+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
+ }
+ },
+ },
+})
+++ /dev/null
-/*
- 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;
-}
<script setup lang="ts">
- import { ref, onMounted } from "vue"
- import type { Mirror } from "@/types/Mirror"
- import { fetchMirrors } from "@/api/mirrors"
- import { getCountryName } from "@/utils/i18n"
-
- // Import UI components
- import Box from "@/components/Box.vue"
+ // Components
+ import MirrorList from "@/components/MirrorList.vue"
import Section from "@/components/Section.vue"
- import Tags from "@/components/Tags.vue"
- import Tag from "@/components/Tag.vue"
-
- // Mirrors
- const mirrors = ref<Mirror[]>([]);
-
- // Fetch all builders as soon as we are mounted
- onMounted(async () => {
- try {
- mirrors.value = await fetchMirrors();
- } catch (err) {
- console.error(err);
- }
- });
</script>
<template>
<Section :title="$t('Mirrors')">
- <Box v-for="mirror in mirrors" :key="mirror.hostname"
- :title="mirror.hostname" :subtitle="mirror.owner">
- <div class="level">
- <!-- Show the country -->
- <div class="level-item">
- {{ getCountryName(mirror.country_code) }}
- </div>
-
- <!-- Show tags of which protocols are supported -->
- <div class="level-item">
- <Tags>
- <Tag v-if="mirror.supports_ipv6" :title="$t('Supports IPv6')" is-success>
- {{ $t('IPv6') }}
- </Tag>
-
- <Tag v-if="mirror.supports_ipv4" :title="$t('Supports IPv4')" is-success>
- {{ $t('IPv4') }}
- </Tag>
- </Tags>
- </div>
- </div>
- </Box>
+ <MirrorList />
</Section>
</template>