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,6 +1,6 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
import { AdminApiError, adminFetch } from '@/lib/api'
|
||||
import { adminFetch, isAuthRejection, messageOf } from '@/lib/api'
|
||||
import { seriesUrl } from '@/lib/range'
|
||||
import { ratioSeries } from '@/lib/series'
|
||||
import { useDashboardStore } from '@/stores/dashboard'
|
||||
@@ -53,21 +53,6 @@ export function errorRateSeries(attempts: AdminSeriesResponse, fails: AdminSerie
|
||||
}))
|
||||
}
|
||||
|
||||
/**
|
||||
* RELIABILITY_SERIES_COLORS cycles through main.css's four existing
|
||||
* --chart-* tokens (assets/main.css is owned by WP-E — this store does not
|
||||
* add a fifth) to color the per-provider error-rate/timeout/failover
|
||||
* overlay charts: with more than four configured providers, colors repeat
|
||||
* — a known, documented limitation rather than a silent one, since adding
|
||||
* a genuinely distinct fifth hue is out of this work package's file scope.
|
||||
*/
|
||||
export const RELIABILITY_SERIES_COLORS = ['--chart-requests', '--chart-tokens-in', '--chart-tokens-out', '--chart-cost'] as const
|
||||
|
||||
/** seriesColor picks one of RELIABILITY_SERIES_COLORS by index, cycling. */
|
||||
export function seriesColor(index: number): string {
|
||||
return RELIABILITY_SERIES_COLORS[index % RELIABILITY_SERIES_COLORS.length]
|
||||
}
|
||||
|
||||
/** One plain (non-ratio) metric series, e.g. failovers/timeouts per provider, or the fleet-wide rej/r402 total. */
|
||||
export interface CountSeries {
|
||||
scope: string
|
||||
@@ -179,8 +164,8 @@ export const useReliabilityStore = defineStore('reliability', {
|
||||
this.error = ''
|
||||
} catch (err) {
|
||||
if (requestId !== this.reqId) return
|
||||
if (err instanceof AdminApiError && (err.status === 401 || err.status === 403)) return
|
||||
this.error = err instanceof Error ? err.message : String(err)
|
||||
if (isAuthRejection(err)) return
|
||||
this.error = messageOf(err)
|
||||
} finally {
|
||||
if (requestId === this.reqId) this.loading = false
|
||||
}
|
||||
@@ -232,8 +217,8 @@ export const useReliabilityStore = defineStore('reliability', {
|
||||
this.providerPerfError = ''
|
||||
} catch (err) {
|
||||
if (requestId !== this.providerPerfReqId) return
|
||||
if (err instanceof AdminApiError && (err.status === 401 || err.status === 403)) return
|
||||
this.providerPerfError = err instanceof Error ? err.message : String(err)
|
||||
if (isAuthRejection(err)) return
|
||||
this.providerPerfError = messageOf(err)
|
||||
} finally {
|
||||
if (requestId === this.providerPerfReqId) this.providerPerfLoading = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user