mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
feat(webui): make the dashboard responsive and add loading and empty states
Every tab row scrolls sideways instead of being clipped by its card. On phones this hid tabs, such as the Config change helper's last forms at 360-390px. The login button has a larger touch target, and long names are truncated with a tooltip. Loading and empty states: - Skeletons show only while a selection has no data yet, never over data already on screen during a refresh. - Empty states name the next step to take. - Error states offer a Retry button that shows progress, and each card keeps its own error. - Toasts confirm copies and key generation, and report background failures once per streak through polite and assertive live regions. Other changes: - The access matrix switches between Models, MCP servers and Agents, and says "none configured" only once its data has loaded. - Home ranks the top 5 users by cost, requests or tokens. It requests only the needed metrics and warns before a range exceeds the server's key cap. - MCP and agent deep links accept a bare target name. admin_assets_gen.go is regenerated. Claude-Session: https://claude.ai/code/session_01V5jYJNxpDFdJkyyExpADrv
This commit is contained in:
@@ -2,12 +2,18 @@
|
||||
import { computed } from 'vue'
|
||||
|
||||
import DataTable from '@/components/DataTable.vue'
|
||||
import EmptyState from '@/components/EmptyState.vue'
|
||||
import ErrorState from '@/components/ErrorState.vue'
|
||||
import SearchInput from '@/components/SearchInput.vue'
|
||||
import { Alert, AlertDescription } from '@/components/ui/alert'
|
||||
import SkeletonTable from '@/components/SkeletonTable.vue'
|
||||
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
|
||||
import { filterModelRows } from '@/lib/model-filter'
|
||||
import { loadState } from '@/lib/load-state'
|
||||
import { modelCatalogColumns } from '@/lib/model-table-columns'
|
||||
import type { ModelCatalogRow } from '@/lib/model-table-columns'
|
||||
import { useNavStore } from '@/stores/nav'
|
||||
|
||||
/**
|
||||
* ModelCatalogTable (redesign-plan.md section 3.4, Models & providers
|
||||
@@ -27,17 +33,35 @@ const props = defineProps<{
|
||||
/** GET /admin/api/performance's own latencyEnabled (AdminPerfResponse) — false means admin.stats.latency is off, so p50/p95 read "—" for every row, not "no traffic yet". */
|
||||
latencyEnabled: boolean
|
||||
loading: boolean
|
||||
/** models.error (verify-ui-states.md #3 fix) — ModelsPage.vue's own current-fetch error, '' when there is none. Previously this component always passed error: '' into loadState below, so a fetch that failed with no rows yet rendered "No models configured." (a false fleet fact) instead of ErrorState. */
|
||||
error?: string
|
||||
/** Renders ErrorState's own "Retry" button — ModelsPage.vue's own models.fetch. */
|
||||
onRetry?: () => void | Promise<void>
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{ 'update:query': [value: string] }>()
|
||||
|
||||
const nav = useNavStore()
|
||||
|
||||
const filtered = computed<ModelCatalogRow[]>(() => filterModelRows(props.rows, props.query))
|
||||
|
||||
const columns = modelCatalogColumns()
|
||||
|
||||
/**
|
||||
* catalogLoadState (lib/load-state.ts, verify-ui-states.md #3 fix) now
|
||||
* reads the REAL `error` prop, not a hardcoded ''. A not-yet-loaded (or
|
||||
* failed) catalog used to render "No models configured." — a false fleet
|
||||
* fact — for BOTH "still fetching" and "the fetch failed with zero rows"
|
||||
* cases alike, since `error: ''` meant loadState could only ever resolve
|
||||
* to 'skeleton' or 'empty', never 'error'. ModelsPage.vue's own top-level
|
||||
* `models.error` paragraph stays alongside this (it also covers a
|
||||
* background refresh failure while rows are already on screen, which
|
||||
* never reaches this component's own ErrorState — loadState's 'ready'
|
||||
* precedence keeps existing rows on screen through that case).
|
||||
*/
|
||||
const catalogLoadState = computed(() => loadState({ loading: props.loading, hasData: props.rows.length > 0, error: props.error ?? '' }))
|
||||
|
||||
const emptyMessage = computed<string>(() => {
|
||||
if (props.loading) return 'loading…'
|
||||
if (props.rows.length === 0) return 'no models configured'
|
||||
if (props.query.trim()) return `no models match "${props.query}"`
|
||||
return 'none'
|
||||
})
|
||||
@@ -59,11 +83,16 @@ const emptyMessage = computed<string>(() => {
|
||||
</CardHeader>
|
||||
<CardContent class="flex flex-col gap-3">
|
||||
<Alert v-if="!latencyEnabled" variant="warn">
|
||||
<AlertDescription>
|
||||
Latency percentiles (p50/p95) are off for this deployment. Enable <code>admin.stats.latency</code> to see them.
|
||||
<AlertTitle>Latency statistics are off</AlertTitle>
|
||||
<AlertDescription class="flex flex-wrap items-center gap-2">
|
||||
<span>Enable <code>admin.stats.latency</code> in the middleware config to see fleet p50/p95.</span>
|
||||
<Button type="button" variant="outline" size="sm" @click="nav.goTo('config')">Open Config</Button>
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
<DataTable :columns="columns" :data="filtered" :empty-message="emptyMessage" />
|
||||
<SkeletonTable v-if="catalogLoadState === 'skeleton'" :rows="5" :cols="columns.length" />
|
||||
<ErrorState v-else-if="catalogLoadState === 'error'" :message="error ?? ''" :on-retry="onRetry" />
|
||||
<EmptyState v-else-if="catalogLoadState === 'empty'" title="No models configured." />
|
||||
<DataTable v-else :columns="columns" :data="filtered" :empty-message="emptyMessage" />
|
||||
</CardContent>
|
||||
</Card>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user