feat : new ui et message discord
This commit is contained in:
@@ -1,87 +1,99 @@
|
||||
<template>
|
||||
<div class="bg-m-secondary w-[250px] h-[259px] rounded-md mx-4 shadow-md/50 shadow-black">
|
||||
<p class="font-bold text-3xl text-m-tertiary my-1 mx-3">
|
||||
Backup
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
class="bg-m-tertiary w-[200px] h-[32px] rounded-md shadow-md/50 shadow-m-black mx-3 mb-[10px] flex items-center justify-between cursor-pointer"
|
||||
@click="select('bitwarden')"
|
||||
>
|
||||
<p class="font-bold uppercase text-xl ml-[24px]">
|
||||
bitwarden
|
||||
</p>
|
||||
<IconifyIcon
|
||||
icon="mdi:eye"
|
||||
class="text-black text-2xl mr-[24px]"
|
||||
/>
|
||||
</button>
|
||||
<div class="backup-card card-glow">
|
||||
<div class="card-header">
|
||||
<h2 class="card-title">Backup</h2>
|
||||
<span class="font-mono text-[10px] text-m-muted tracking-widest uppercase">Dossiers</span>
|
||||
</div>
|
||||
|
||||
<button
|
||||
<div class="backup-list">
|
||||
<button
|
||||
v-for="item in folders"
|
||||
:key="item.name"
|
||||
type="button"
|
||||
class="bg-m-tertiary w-[200px] h-[32px] rounded-md shadow-md/50 shadow-m-black mx-3 mb-[10px] flex items-center justify-between cursor-pointer"
|
||||
@click="select('inventory')"
|
||||
>
|
||||
<p class="font-bold uppercase text-xl ml-[24px]">
|
||||
inventory
|
||||
</p>
|
||||
<IconifyIcon
|
||||
icon="mdi:eye"
|
||||
class="text-black text-2xl mr-[24px]"
|
||||
/>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="bg-m-tertiary w-[200px] h-[32px] rounded-md shadow-md/50 shadow-m-black mx-3 mb-[10px] flex items-center justify-between cursor-pointer"
|
||||
@click="select('sirh')"
|
||||
>
|
||||
<p class="font-bold uppercase text-xl ml-[24px]">
|
||||
sirh
|
||||
</p>
|
||||
<IconifyIcon
|
||||
icon="mdi:eye"
|
||||
class="text-black text-2xl mr-[24px]"
|
||||
/>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="bg-m-tertiary w-[200px] h-[32px] rounded-md shadow-md/50 shadow-m-black mx-3 mb-[10px] flex items-center justify-between cursor-pointer"
|
||||
@click="select('ferme')"
|
||||
>
|
||||
<p class="font-bold uppercase text-xl ml-[24px]">
|
||||
ferme
|
||||
</p>
|
||||
<IconifyIcon
|
||||
icon="mdi:eye"
|
||||
class="text-black text-2xl mr-[24px]"
|
||||
/>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="bg-m-tertiary w-[200px] h-[32px] rounded-md shadow-md/50 shadow-m-black mx-3 mb-[10px] flex items-center justify-between cursor-pointer"
|
||||
@click="select('user')"
|
||||
>
|
||||
<p class="font-bold uppercase text-xl ml-[24px]">
|
||||
user
|
||||
</p>
|
||||
<IconifyIcon
|
||||
icon="mdi:eye"
|
||||
class="text-black text-2xl mr-[24px]"
|
||||
/>
|
||||
</button>
|
||||
class="backup-btn"
|
||||
:class="{ 'backup-btn-active': active === item.name }"
|
||||
@click="select(item.name)"
|
||||
>
|
||||
<div class="flex items-center gap-2.5">
|
||||
<IconifyIcon :icon="item.icon" class="text-base text-m-accent" />
|
||||
<span class="font-display text-sm font-semibold uppercase tracking-wide">
|
||||
{{ item.name }}
|
||||
</span>
|
||||
</div>
|
||||
<IconifyIcon
|
||||
icon="mdi:chevron-right"
|
||||
class="text-lg text-m-muted transition-transform duration-200"
|
||||
:class="{ 'translate-x-0.5 !text-m-accent': active === item.name }"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue"
|
||||
import { Icon as IconifyIcon } from "@iconify/vue"
|
||||
import backupOptions from "~/server/config/backup-options.json"
|
||||
|
||||
const emit = defineEmits(["select"])
|
||||
const active = ref<string | null>(null)
|
||||
const folders = backupOptions as Array<{ name: string; icon: string }>
|
||||
|
||||
const select = (name: string) => {
|
||||
active.value = name
|
||||
emit("select", name)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.backup-card {
|
||||
background: rgb(var(--m-secondary));
|
||||
border-radius: 12px;
|
||||
padding: 1.25rem;
|
||||
transition: background-color 0.4s ease;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-family: var(--font-display);
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: rgb(var(--m-text));
|
||||
}
|
||||
|
||||
.backup-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.375rem;
|
||||
}
|
||||
|
||||
.backup-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.625rem 0.875rem;
|
||||
border-radius: 8px;
|
||||
background: rgb(var(--m-tertiary));
|
||||
border: 1px solid transparent;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
color: rgb(var(--m-text));
|
||||
}
|
||||
|
||||
.backup-btn:hover {
|
||||
border-color: rgb(var(--m-accent) / 0.15);
|
||||
background: rgb(var(--m-accent) / 0.06);
|
||||
}
|
||||
|
||||
.backup-btn-active {
|
||||
border-color: rgb(var(--m-accent) / 0.25);
|
||||
background: rgb(var(--m-accent) / 0.08);
|
||||
box-shadow: 0 0 12px -4px rgb(var(--m-accent) / 0.15);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,44 +1,58 @@
|
||||
<template>
|
||||
<div class="bg-m-secondary w-[507px] h-[367px] rounded-md mx-4 shadow-md/50 shadow-black">
|
||||
<p class="font-bold text-3xl text-m-tertiary my-1 mx-3">
|
||||
{{ title }}
|
||||
</p>
|
||||
<div class="backup-list-card card-glow">
|
||||
<div class="card-header">
|
||||
<h2 class="card-title">{{ title }}</h2>
|
||||
</div>
|
||||
|
||||
<div v-if="loading">
|
||||
<div v-if="!folder" class="empty-state">
|
||||
<IconifyIcon icon="mdi:folder-open-outline" class="text-3xl text-m-muted/40" />
|
||||
<p class="mt-2 font-mono text-xs text-m-muted/50">
|
||||
Selectionnez un dossier
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div v-else-if="loading" class="file-list">
|
||||
<div
|
||||
v-for="n in 6"
|
||||
:key="`backup-skeleton-${n}`"
|
||||
class="relative w-[483px] h-[39px] mx-3 mb-[10px]"
|
||||
class="file-row animate-shimmer"
|
||||
>
|
||||
<ButtonSkeleton custom-class="h-full w-full" />
|
||||
<div class="absolute inset-0 flex items-center justify-between px-3">
|
||||
<TextSkeleton custom-class="h-5 w-[260px]" />
|
||||
<CircleSkeleton custom-class="h-6 w-6 rounded-md" />
|
||||
</div>
|
||||
<TextSkeleton custom-class="h-4 w-48" />
|
||||
<CircleSkeleton custom-class="h-5 w-5 rounded" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
v-else
|
||||
<div v-else-if="backups.length === 0" class="empty-state">
|
||||
<IconifyIcon icon="mdi:file-hidden" class="text-3xl text-m-muted/40" />
|
||||
<p class="mt-2 font-mono text-xs text-m-muted/50">
|
||||
Aucun backup trouve
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div v-else class="file-list">
|
||||
<button
|
||||
v-for="file in backups"
|
||||
:key="file"
|
||||
class="bg-m-tertiary w-[483px] h-[39px] rounded-md shadow-md/50 shadow-m-black mx-3 mb-[10px] flex items-center justify-between cursor-pointer"
|
||||
class="file-row"
|
||||
@click="downloadBackup(file)"
|
||||
>
|
||||
<p class="text-xl ml-3 truncate max-w-[400px]">
|
||||
{{ file }}
|
||||
</p>
|
||||
|
||||
<IconifyIcon
|
||||
>
|
||||
<div class="flex min-w-0 items-center gap-2.5">
|
||||
<IconifyIcon icon="mdi:file-document-outline" class="text-base text-m-accent flex-shrink-0" />
|
||||
<span class="truncate font-mono text-xs text-m-text">
|
||||
{{ file }}
|
||||
</span>
|
||||
</div>
|
||||
<IconifyIcon
|
||||
icon="mdi:download"
|
||||
class="text-black text-2xl mr-3"
|
||||
/>
|
||||
</button>
|
||||
class="text-base text-m-muted flex-shrink-0 transition-colors duration-200"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {Icon as IconifyIcon} from "@iconify/vue"
|
||||
import ButtonSkeleton from "~/components/skeleton/ButtonSkeleton.vue"
|
||||
import CircleSkeleton from "~/components/skeleton/CircleSkeleton.vue"
|
||||
import TextSkeleton from "~/components/skeleton/TextSkeleton.vue"
|
||||
|
||||
@@ -49,8 +63,8 @@ const props = defineProps<{
|
||||
const backups = ref<string[]>([])
|
||||
const loading = ref(false)
|
||||
const title = computed(() => {
|
||||
if (!props.folder) return "Backup"
|
||||
return `Liste des backup de ${props.folder.toUpperCase()}`
|
||||
if (!props.folder) return "Fichiers"
|
||||
return `Backup — ${props.folder.toUpperCase()}`
|
||||
})
|
||||
|
||||
const downloadBackup = (file: string) => {
|
||||
@@ -78,3 +92,59 @@ watch(() => props.folder, async (folder) => {
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.backup-list-card {
|
||||
background: rgb(var(--m-secondary));
|
||||
border-radius: 12px;
|
||||
padding: 1.25rem;
|
||||
transition: background-color 0.4s ease;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-family: var(--font-display);
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: rgb(var(--m-text));
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 2.5rem 1rem;
|
||||
}
|
||||
|
||||
.file-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.375rem;
|
||||
}
|
||||
|
||||
.file-row {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.625rem 0.875rem;
|
||||
border-radius: 8px;
|
||||
background: rgb(var(--m-tertiary));
|
||||
border: 1px solid transparent;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.file-row:hover {
|
||||
border-color: rgb(var(--m-accent) / 0.15);
|
||||
background: rgb(var(--m-accent) / 0.06);
|
||||
}
|
||||
|
||||
.file-row:hover .text-m-muted {
|
||||
color: rgb(var(--m-accent));
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,35 +1,48 @@
|
||||
<template>
|
||||
<section class="flex flex-col items-center p-4">
|
||||
<template v-if="loading">
|
||||
<TextSkeleton custom-class="h-7 w-40" />
|
||||
<CircleSkeleton custom-class="mt-2 h-[140px] w-[140px]" />
|
||||
<BlockSkeleton custom-class="mt-2 h-5 w-36" />
|
||||
<section class="storage-card">
|
||||
<template v-if="item.loading">
|
||||
<TextSkeleton custom-class="h-5 w-28" />
|
||||
<CircleSkeleton custom-class="mt-3 h-[120px] w-[120px]" />
|
||||
<BlockSkeleton custom-class="mt-3 h-4 w-32" />
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<p class="text-center text-xl font-semibold uppercase">{{ hostName }}</p>
|
||||
<div class="relative h-[140px] w-[140px]" :class="statusColorClass">
|
||||
<svg class="h-full w-full -rotate-90" viewBox="0 0 120 120" aria-label="Pourcentage restant">
|
||||
<p class="font-mono text-[11px] font-medium uppercase tracking-[0.2em] text-white/60">
|
||||
{{ item.hostName }}
|
||||
</p>
|
||||
|
||||
<div class="chart-wrapper" :class="item.statusColorClass">
|
||||
<svg class="chart-svg" viewBox="0 0 120 120" aria-label="Pourcentage restant">
|
||||
<circle
|
||||
class="fill-none stroke-[rgba(255,255,255,0.22)] [stroke-width:10]"
|
||||
cx="60"
|
||||
cy="60"
|
||||
:r="chartRadius"
|
||||
class="track"
|
||||
cx="60" cy="60"
|
||||
:r="item.chartRadius"
|
||||
/>
|
||||
<circle
|
||||
class="fill-none stroke-[currentColor] [stroke-linecap:round] [stroke-width:10] transition-[stroke-dashoffset] duration-300"
|
||||
cx="60"
|
||||
cy="60"
|
||||
:r="chartRadius"
|
||||
:style="{ strokeDasharray: `${chartCircumference}`, strokeDashoffset: `${chartOffset}` }"
|
||||
class="progress"
|
||||
cx="60" cy="60"
|
||||
:r="item.chartRadius"
|
||||
:style="{
|
||||
strokeDasharray: `${item.chartCircumference}`,
|
||||
strokeDashoffset: `${item.chartOffset}`
|
||||
}"
|
||||
/>
|
||||
</svg>
|
||||
<div class="absolute inset-0 flex flex-col items-center justify-center">
|
||||
<strong class="text-2xl leading-none">{{ remainingPercentText }}</strong>
|
||||
<div class="chart-label">
|
||||
<strong class="font-mono text-2xl font-bold leading-none">
|
||||
{{ item.remainingPercentText }}
|
||||
</strong>
|
||||
<span class="mt-1 font-mono text-[9px] uppercase tracking-widest text-m-muted">
|
||||
libre
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="mt-1 text-center text-sm font-semibold">{{ usedText }} / {{ totalText }}</p>
|
||||
<p class="font-mono text-xs font-medium text-m-muted/80">
|
||||
{{ item.usedText }}
|
||||
<span class="mx-0.5 text-m-muted/40">/</span>
|
||||
{{ item.totalText }}
|
||||
</p>
|
||||
</template>
|
||||
</section>
|
||||
</template>
|
||||
@@ -40,24 +53,69 @@ import BlockSkeleton from "~/components/skeleton/BlockSkeleton.vue"
|
||||
import TextSkeleton from "~/components/skeleton/TextSkeleton.vue"
|
||||
|
||||
defineProps<{
|
||||
loading: boolean
|
||||
hostName: string
|
||||
statusColorClass: string
|
||||
chartRadius: number
|
||||
chartCircumference: number
|
||||
chartOffset: number
|
||||
remainingPercentText: string
|
||||
usedText: string
|
||||
totalText: string
|
||||
item: {
|
||||
loading: boolean
|
||||
hostName: string
|
||||
statusColorClass: string
|
||||
chartRadius: number
|
||||
chartCircumference: number
|
||||
chartOffset: number
|
||||
remainingPercentText: string
|
||||
usedText: string
|
||||
totalText: string
|
||||
}
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.m-success {
|
||||
.storage-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 1.25rem 1rem;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.chart-wrapper {
|
||||
position: relative;
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
}
|
||||
|
||||
.chart-svg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
|
||||
.track {
|
||||
fill: none;
|
||||
stroke: rgba(255, 255, 255, 0.06);
|
||||
stroke-width: 8;
|
||||
}
|
||||
|
||||
.progress {
|
||||
fill: none;
|
||||
stroke: currentColor;
|
||||
stroke-width: 8;
|
||||
stroke-linecap: round;
|
||||
transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.chart-label {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.status-success {
|
||||
color: rgb(var(--m-success));
|
||||
}
|
||||
|
||||
.m-error {
|
||||
.status-error {
|
||||
color: rgb(var(--m-error));
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,19 +1,108 @@
|
||||
<script setup>
|
||||
import {Icon as IconifyIcon} from "@iconify/vue"
|
||||
const { data: messages } = await useFetch('/api/discord/messages')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="bg-m-secondary w-auto h-auto mx-4 rounded-md shadow-md/50 shadow-black p-2">
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<p class="font-bold text-3xl text-m-tertiary">
|
||||
Speedtest
|
||||
<div class="discord-card card-glow">
|
||||
<div class="card-header">
|
||||
<div class="flex items-center gap-2.5">
|
||||
<IconifyIcon icon="mdi:message-text" class="text-lg text-m-accent" />
|
||||
<h2 class="card-title">Discord</h2>
|
||||
</div>
|
||||
<span class="font-mono text-[10px] text-m-muted tracking-widest uppercase">Messages</span>
|
||||
</div>
|
||||
|
||||
<div v-if="!messages || messages.length === 0" class="empty-state">
|
||||
<IconifyIcon icon="mdi:chat-outline" class="text-3xl text-m-muted/40" />
|
||||
<p class="mt-2 font-mono text-xs text-m-muted/50">
|
||||
Aucun message
|
||||
</p>
|
||||
<div v-if="messages">
|
||||
<div v-for="m in messages" :key="m.id">
|
||||
<strong>{{ m.author.username }}</strong>
|
||||
<p>{{ m.content }}</p>
|
||||
</div>
|
||||
|
||||
<div v-else class="message-list">
|
||||
<div
|
||||
v-for="m in messages"
|
||||
:key="m.id"
|
||||
class="message-row"
|
||||
>
|
||||
<div class="message-avatar">
|
||||
{{ m.author.username.charAt(0).toUpperCase() }}
|
||||
</div>
|
||||
<div class="min-w-0 flex-1">
|
||||
<span class="font-display text-xs font-semibold text-m-accent">
|
||||
{{ m.author.username }}
|
||||
</span>
|
||||
<p class="mt-0.5 break-words font-display text-sm leading-relaxed text-m-text/80">
|
||||
{{ m.content }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.discord-card {
|
||||
background: rgb(var(--m-secondary));
|
||||
border-radius: 12px;
|
||||
padding: 1.25rem;
|
||||
max-height: calc(100vh - 7rem);
|
||||
overflow: hidden;
|
||||
transition: background-color 0.4s ease;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-family: var(--font-display);
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: rgb(var(--m-text));
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 2rem 1rem;
|
||||
}
|
||||
|
||||
.message-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
max-height: calc(100vh - 12rem);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.message-row {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
padding: 0.75rem;
|
||||
border-radius: 8px;
|
||||
background: rgb(var(--m-tertiary));
|
||||
border: 1px solid rgb(var(--m-accent) / 0.04);
|
||||
}
|
||||
|
||||
.message-avatar {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 8px;
|
||||
background: linear-gradient(135deg, rgb(var(--m-accent) / 0.2), rgb(var(--m-success) / 0.15));
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
color: rgb(var(--m-accent));
|
||||
flex-shrink: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,103 +1,64 @@
|
||||
<template>
|
||||
<div class="bg-m-secondary w-[507px] h-[184px] mx-4 rounded-md shadow-md/50 shadow-black p-2">
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<p class="font-bold text-3xl text-m-tertiary">
|
||||
Speedtest
|
||||
</p>
|
||||
<IconifyIcon
|
||||
<div class="speedtest-card card-glow">
|
||||
<div class="card-header">
|
||||
<h2 class="card-title">Speedtest</h2>
|
||||
<button
|
||||
class="reload-btn"
|
||||
@click="runTests"
|
||||
:disabled="isTesting"
|
||||
>
|
||||
<IconifyIcon
|
||||
icon="mdi:reload"
|
||||
class="bg-m-tertiary text-2xl text-black rounded-md shadow-md/50 mr-1 cursor-pointer"
|
||||
@click="runTests"
|
||||
/>
|
||||
class="text-lg"
|
||||
:class="{ 'animate-spin': isTesting }"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
<div class="grid grid-cols-3 gap-3">
|
||||
<div class="bg-m-tertiary w-[153px] h-[120px] rounded-md shadow-md/50 shadow-m-black">
|
||||
<div class="flex items-center justify-center">
|
||||
<IconifyIcon
|
||||
icon="mdi:download"
|
||||
class="text-m-primary text-2xl mt-2 ml-1"
|
||||
/>
|
||||
<p class="font-bold uppercase text-xl text-m-text mt-2 mr-1">
|
||||
download
|
||||
</p>
|
||||
</div>
|
||||
<div class="mx-2 flex flex-col items-center justify-center">
|
||||
<template v-if="isTesting">
|
||||
<TextSkeleton custom-class="h-10 w-16 mb-1" />
|
||||
</template>
|
||||
<span v-else class="text-4xl">
|
||||
{{ download !== null ? `${download}` : "--" }}
|
||||
|
||||
<div class="metrics-grid">
|
||||
<div v-for="metric in metrics" :key="metric.label" class="metric-card">
|
||||
<div class="metric-header">
|
||||
<IconifyIcon :icon="metric.icon" class="text-lg text-m-accent" />
|
||||
<span class="font-mono text-[10px] font-medium uppercase tracking-[0.15em] text-m-muted">
|
||||
{{ metric.label }}
|
||||
</span>
|
||||
<p class="font-bold text-xl leading-tight">
|
||||
Mbps
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-m-tertiary w-[153px] h-[120px] rounded-md shadow-md/50 shadow-m-black">
|
||||
<div class="flex items-center justify-center">
|
||||
<IconifyIcon
|
||||
icon="mdi:upload"
|
||||
class="text-m-primary text-2xl mt-2 ml-1"
|
||||
/>
|
||||
<p class="font-bold uppercase text-xl text-m-text mt-2 mr-1">
|
||||
upload
|
||||
</p>
|
||||
</div>
|
||||
<div class="mx-2 flex flex-col items-center justify-center">
|
||||
<div class="metric-value-area">
|
||||
<template v-if="isTesting">
|
||||
<TextSkeleton custom-class="h-10 w-16 mb-1" />
|
||||
<div class="h-10 w-16 animate-shimmer rounded" />
|
||||
</template>
|
||||
<span v-else class="text-4xl">
|
||||
{{ upload !== null ? `${upload}` : "--" }}
|
||||
</span>
|
||||
<p class="font-bold text-xl leading-tight">
|
||||
Mbps
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-m-tertiary w-[153px] h-[120px] rounded-md shadow-md/50 shadow-m-black">
|
||||
<div class="flex items-center justify-center">
|
||||
<IconifyIcon
|
||||
icon="mdi:wifi"
|
||||
class="text-m-primary text-2xl mt-2 ml-1"
|
||||
/>
|
||||
<p class="font-bold uppercase text-xl text-m-text mt-2 mr-1">
|
||||
ping
|
||||
</p>
|
||||
</div>
|
||||
<div class="mx-2 flex flex-col items-center justify-center">
|
||||
<template v-if="isTesting">
|
||||
<TextSkeleton custom-class="h-10 w-16 mb-1" />
|
||||
<template v-else>
|
||||
<span class="metric-value font-mono">
|
||||
{{ metric.value !== null ? metric.value : "--" }}
|
||||
</span>
|
||||
</template>
|
||||
<span v-else class="text-4xl">
|
||||
{{ ping !== null ? `${ping}` : "--" }}
|
||||
</span>
|
||||
<p class="font-bold text-xl leading-tight">
|
||||
Ms
|
||||
</p>
|
||||
<span class="metric-unit font-mono">{{ metric.unit }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {ref} from "vue";
|
||||
import {computed, ref} from "vue"
|
||||
import {Icon as IconifyIcon} from "@iconify/vue"
|
||||
import TextSkeleton from "~/components/skeleton/TextSkeleton.vue"
|
||||
|
||||
const ping = ref<number | null>(null)
|
||||
const download = ref<number | null>(null)
|
||||
const upload = ref<number | null>(null)
|
||||
const isTesting = ref(false)
|
||||
|
||||
const metrics = computed(() => [
|
||||
{ label: "Download", icon: "mdi:arrow-down-bold", value: download.value, unit: "Mbps" },
|
||||
{ label: "Upload", icon: "mdi:arrow-up-bold", value: upload.value, unit: "Mbps" },
|
||||
{ label: "Ping", icon: "mdi:signal", value: ping.value, unit: "ms" },
|
||||
])
|
||||
|
||||
async function testDownload() {
|
||||
const start = performance.now()
|
||||
|
||||
const res = await fetch('/api/download')
|
||||
const blob = await res.blob()
|
||||
|
||||
const end = performance.now()
|
||||
|
||||
const size = blob.size
|
||||
const seconds = (end - start) / 1000
|
||||
download.value = Math.round((size * 8) / seconds / 1000000)
|
||||
@@ -106,28 +67,17 @@ async function testDownload() {
|
||||
async function testUpload() {
|
||||
const size = 5 * 1024 * 1024
|
||||
const data = new Uint8Array(size)
|
||||
|
||||
const start = performance.now()
|
||||
|
||||
await fetch('/api/upload', {
|
||||
method: 'POST',
|
||||
body: data
|
||||
})
|
||||
|
||||
await fetch('/api/upload', { method: 'POST', body: data })
|
||||
const end = performance.now()
|
||||
|
||||
const seconds = (end - start) / 1000
|
||||
upload.value = Math.round((size * 8) / seconds / 1000000)
|
||||
}
|
||||
|
||||
|
||||
async function testPing() {
|
||||
const start = performance.now()
|
||||
|
||||
await fetch('/api/ping')
|
||||
|
||||
const end = performance.now()
|
||||
|
||||
ping.value = Math.round(end - start)
|
||||
}
|
||||
|
||||
@@ -146,3 +96,97 @@ async function runTests() {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.speedtest-card {
|
||||
background: rgb(var(--m-secondary));
|
||||
border-radius: 12px;
|
||||
padding: 1.25rem;
|
||||
transition: background-color 0.4s ease;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-family: var(--font-display);
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: rgb(var(--m-text));
|
||||
}
|
||||
|
||||
.reload-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 8px;
|
||||
background: rgb(var(--m-tertiary));
|
||||
color: rgb(var(--m-accent));
|
||||
border: 1px solid rgb(var(--m-accent) / 0.12);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.reload-btn:hover:not(:disabled) {
|
||||
background: rgb(var(--m-accent) / 0.12);
|
||||
border-color: rgb(var(--m-accent) / 0.25);
|
||||
}
|
||||
|
||||
.reload-btn:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.metrics-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.metric-card {
|
||||
background: rgb(var(--m-tertiary));
|
||||
border-radius: 10px;
|
||||
padding: 1rem;
|
||||
border: 1px solid rgb(var(--m-accent) / 0.06);
|
||||
transition: border-color 0.2s ease;
|
||||
}
|
||||
|
||||
.metric-card:hover {
|
||||
border-color: rgb(var(--m-accent) / 0.15);
|
||||
}
|
||||
|
||||
.metric-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.metric-value-area {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.125rem;
|
||||
}
|
||||
|
||||
.metric-value {
|
||||
font-size: 2rem;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
color: rgb(var(--m-text));
|
||||
}
|
||||
|
||||
.metric-unit {
|
||||
font-size: 0.65rem;
|
||||
font-weight: 500;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.1em;
|
||||
color: rgb(var(--m-muted));
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,49 +1,45 @@
|
||||
<template>
|
||||
<div class="bg-m-secondary w-[250px] h-[292px] rounded-md mx-4 shadow-md/50 shadow-black">
|
||||
<p class="font-bold text-3xl text-m-tertiary my-1 mx-3">
|
||||
Status
|
||||
</p>
|
||||
<div class="status-card card-glow">
|
||||
<div class="card-header">
|
||||
<h2 class="card-title">Status</h2>
|
||||
<span class="font-mono text-[10px] text-m-muted tracking-widest uppercase">Services</span>
|
||||
</div>
|
||||
|
||||
<template v-if="loading">
|
||||
<div
|
||||
v-for="n in 3"
|
||||
:key="`skeleton-${n}`"
|
||||
class="relative w-[200px] h-[68px] rounded-md mx-[25px] mb-3"
|
||||
class="status-row animate-shimmer"
|
||||
>
|
||||
<ButtonSkeleton custom-class="h-full w-full" />
|
||||
<div class="absolute inset-0 p-2">
|
||||
<TextSkeleton custom-class="h-5 w-24 mb-2" />
|
||||
<div class="flex items-center gap-2">
|
||||
<CircleSkeleton custom-class="h-6 w-6" />
|
||||
<TextSkeleton custom-class="h-5 w-20" />
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<CircleSkeleton custom-class="h-3 w-3" />
|
||||
<TextSkeleton custom-class="h-4 w-20" />
|
||||
</div>
|
||||
<TextSkeleton custom-class="h-4 w-16" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div
|
||||
v-else
|
||||
class="bg-m-tertiary w-[200px] h-[68px] rounded-md shadow-md/50 shadow-m-black mx-[25px] mb-3"
|
||||
v-for="row in rows"
|
||||
:key="`${row.label}-${row.url}`"
|
||||
class="status-row"
|
||||
:class="row.status === 200 ? 'row-ok' : 'row-error'"
|
||||
>
|
||||
<p class="font-bold text-xl text-m-text mt-2 mx-2 mb-1">
|
||||
{{ row.label }}
|
||||
</p>
|
||||
<div class="mx-2 flex items-center">
|
||||
<span
|
||||
class="inline-block h-[24px] w-[24px] rounded-full mr-2"
|
||||
:class="statusClass(row.status)"
|
||||
/>
|
||||
<span class="font-semibold text-lg">
|
||||
{{ statusLabel(row.status) }}
|
||||
<div class="flex items-center gap-3">
|
||||
<span class="status-dot" :class="row.status === 200 ? 'dot-ok' : 'dot-error'" />
|
||||
<span class="font-display text-sm font-semibold text-m-text">
|
||||
{{ row.label }}
|
||||
</span>
|
||||
</div>
|
||||
<span class="font-mono text-xs" :class="row.status === 200 ? 'text-m-success' : 'text-m-error'">
|
||||
{{ statusLabel(row.status) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import ButtonSkeleton from "~/components/skeleton/ButtonSkeleton.vue"
|
||||
import CircleSkeleton from "~/components/skeleton/CircleSkeleton.vue"
|
||||
import TextSkeleton from "~/components/skeleton/TextSkeleton.vue"
|
||||
import {onBeforeUnmount, onMounted, ref} from "vue"
|
||||
@@ -77,16 +73,10 @@ const loading = ref(true)
|
||||
const initialized = ref(false)
|
||||
let timer: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
const statusClass = (status: number) => {
|
||||
if (status === 200) return "bg-m-success"
|
||||
if (status === 0) return "bg-m-error"
|
||||
return "bg-m-error"
|
||||
}
|
||||
|
||||
const statusLabel = (status: number) => {
|
||||
if (status === 200) return "HTTP 200"
|
||||
if (status === 0) return "Injoignable"
|
||||
return `KO (HTTP ${status})`
|
||||
return `KO (${status})`
|
||||
}
|
||||
|
||||
const checkStatus = async () => {
|
||||
@@ -125,3 +115,67 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.status-card {
|
||||
background: rgb(var(--m-secondary));
|
||||
border-radius: 12px;
|
||||
padding: 1.25rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.625rem;
|
||||
transition: background-color 0.4s ease;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-family: var(--font-display);
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: rgb(var(--m-text));
|
||||
}
|
||||
|
||||
.status-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.75rem 1rem;
|
||||
border-radius: 8px;
|
||||
background: rgb(var(--m-tertiary));
|
||||
border: 1px solid transparent;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.row-ok {
|
||||
border-color: rgb(var(--m-success) / 0.08);
|
||||
}
|
||||
|
||||
.row-error {
|
||||
border-color: rgb(var(--m-error) / 0.1);
|
||||
background: rgb(var(--m-error) / 0.04);
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.dot-ok {
|
||||
background: rgb(var(--m-success));
|
||||
box-shadow: 0 0 6px rgb(var(--m-success) / 0.5);
|
||||
}
|
||||
|
||||
.dot-error {
|
||||
background: rgb(var(--m-error));
|
||||
box-shadow: 0 0 6px rgb(var(--m-error) / 0.5);
|
||||
animation: pulse-glow 2s ease-in-out infinite;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user