mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-27 10:16:34 +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:
@@ -118,13 +118,16 @@ export function providerErrorRate(attempts: number, failures: number): number |
|
||||
* formatRatePercent above (a SUCCESS rate must never overstate itself as
|
||||
* 100%; an ERROR rate must never round down to a misleadingly clean 0%).
|
||||
* `null` (no traffic to compute a rate from — providerErrorRate's own
|
||||
* "nothing to report" case) renders as "no data", never "0%". Not clamped
|
||||
* to 100%: a rate above 1 should not occur with real counters, but this
|
||||
* "nothing to report" case) renders as `nullLabel` (default "no data"),
|
||||
* never "0%" — reuse-audit.md F13: the `nullLabel` param lets HomePage.vue's
|
||||
* fleet-wide reading pass "no traffic" instead of hand-rolling an identical
|
||||
* copy of this function with a different null wording. Not clamped to
|
||||
* 100%: a rate above 1 should not occur with real counters, but this
|
||||
* function reports whatever the caller computed rather than silently
|
||||
* capping it (lib/series.ts's own ratioSeries makes the identical choice).
|
||||
*/
|
||||
export function formatErrorRatePercent(rate: number | null): string {
|
||||
if (rate === null) return 'no data'
|
||||
export function formatErrorRatePercent(rate: number | null, nullLabel = 'no data'): string {
|
||||
if (rate === null) return nullLabel
|
||||
if (rate <= 0) return '0%'
|
||||
return `${Math.ceil(rate * 100)}%`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user