mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
refactor(webui): extract repeated dashboard elements into shared components
Markup and helpers that were copied between pages now live in one place: - ChartCard, StatDisabledAlert, StatItem, DetailField, BudgetRatioBars, LabeledSelect, TargetPicker and LoadStateView components - lib/scope.ts, lib/columns.ts and lib/chart-palette.ts - messageOf, isAuthRejection, and the USD to micro-USD conversion helpers - one monthly cost projection, one date formatter, and the useCopyFeedback composable Behaviour is unchanged. Before and after screenshots of every page match at 390 and 1440 px. Empty-state text now comes from the shared EmptyState component, and the user run-out date uses the short date format. admin_assets_gen.go is regenerated. Claude-Session: https://claude.ai/code/session_01V5jYJNxpDFdJkyyExpADrv
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { faCheck, faCopy, faTriangleExclamation } from '@fortawesome/free-solid-svg-icons'
|
||||
import { computed, onUnmounted, ref, useTemplateRef } from 'vue'
|
||||
import { computed, useTemplateRef } from 'vue'
|
||||
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { useCopyFeedback } from '@/composables/useCopyFeedback'
|
||||
import { copyText } from '@/lib/clipboard'
|
||||
import { formatContextWindow, formatModelCostHover } from '@/lib/format'
|
||||
import { useToastsStore } from '@/stores/toasts'
|
||||
@@ -50,17 +51,9 @@ const props = defineProps<{
|
||||
}>()
|
||||
|
||||
const labelRef = useTemplateRef<HTMLElement>('label')
|
||||
const state = ref<'idle' | 'copied' | 'selected' | 'failed'>('idle')
|
||||
let resetTimer: ReturnType<typeof setTimeout> | undefined
|
||||
const { state, set: setCopyFeedback } = useCopyFeedback()
|
||||
const toasts = useToastsStore()
|
||||
|
||||
function scheduleReset(): void {
|
||||
clearTimeout(resetTimer)
|
||||
resetTimer = setTimeout(() => {
|
||||
state.value = 'idle'
|
||||
}, 1500)
|
||||
}
|
||||
|
||||
async function onClick(): Promise<void> {
|
||||
const result = await copyText(props.id, labelRef.value ?? undefined)
|
||||
// 'failed' (neither the Clipboard API nor the selection fallback
|
||||
@@ -71,9 +64,8 @@ async function onClick(): Promise<void> {
|
||||
// feedback right at the click target (the icon swap plus this same
|
||||
// title/aria-label text), so a success toast on top would double-notify
|
||||
// for something the reader is already looking straight at.
|
||||
state.value = result
|
||||
setCopyFeedback(result)
|
||||
if (result === 'failed') toasts.push({ kind: 'error', message: `Could not copy ${props.id}.` })
|
||||
scheduleReset()
|
||||
}
|
||||
|
||||
const icon = {
|
||||
@@ -119,10 +111,6 @@ const title = computed(() => {
|
||||
const base = baseTitle.value[state.value]
|
||||
return metaDetail.value ? `${base} · ${metaDetail.value}` : base
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
clearTimeout(resetTimer)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user