mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
fix(webui): users page filter, labels, panel fetches
This commit is contained in:
@@ -30,7 +30,7 @@ describe('EVENT_KIND_LABEL', () => {
|
||||
describe('EVENT_KINDS', () => {
|
||||
it('contains every known AdminEventKind, derived from EVENT_KIND_LABEL', () => {
|
||||
expect(EVENT_KINDS).toEqual(Object.keys(EVENT_KIND_LABEL))
|
||||
expect(EVENT_KINDS).toEqual(['rate_limit', 'budget', 'store_down', 'upstream', 'timeout', 'unpriced', 'capacity'])
|
||||
expect(EVENT_KINDS).toEqual(['rate_limit', 'budget', 'store_down', 'upstream', 'timeout', 'unpriced', 'capacity', 'paced'])
|
||||
})
|
||||
|
||||
it('every entry has a truthy label (no silently-empty display text)', () => {
|
||||
|
||||
@@ -9,6 +9,7 @@ export const EVENT_KIND_LABEL: Record<AdminEventKind, string> = {
|
||||
timeout: 'Timeout',
|
||||
unpriced: 'Unpriced model',
|
||||
capacity: 'Capacity',
|
||||
paced: 'Paced',
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -82,6 +82,11 @@ describe('effectiveLimitRows', () => {
|
||||
expect(rows.find((r) => r.label === 'Requests/day')).toMatchObject({ value: '3,000', source: 'user' })
|
||||
expect(rows.find((r) => r.label === 'Pacing')).toMatchObject({ value: 'from 80%, up to 10s delay' })
|
||||
})
|
||||
it('formats cost limits with the shared cost format and marks pacing as prose', () => {
|
||||
const rows = effectiveLimitRows({ costPerMonthUSD: 25, pacing: PACING }, undefined)
|
||||
expect(rows.find((r) => r.key === 'costPerMonthUSD')?.value).toBe('$25.00')
|
||||
expect(rows.find((r) => r.key === 'pacing')?.prose).toBe(true)
|
||||
})
|
||||
it('returns no rows without limits', () => {
|
||||
expect(effectiveLimitRows(undefined, undefined)).toEqual([])
|
||||
})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { formatCompactCount } from '@/lib/format'
|
||||
import { formatCompactCount, formatCostDisplay, usdToMicros } from '@/lib/format'
|
||||
import type { AdminUsageEntryView, LimitSources, LimitsConfig } from '@/types/api'
|
||||
|
||||
/** Pacing starts here when a scope sets no pacing block; matches the budget bars' amber tier. */
|
||||
@@ -75,6 +75,8 @@ export interface LimitRow {
|
||||
label: string
|
||||
value: string
|
||||
source: string
|
||||
/** Prose rather than a number: the value is not set in mono. */
|
||||
prose?: boolean
|
||||
}
|
||||
|
||||
const LIMIT_FIELDS: Array<{ key: Exclude<keyof LimitsConfig, 'pacing'>; label: string; usd?: boolean }> = [
|
||||
@@ -100,10 +102,10 @@ export function effectiveLimitRows(limits: LimitsConfig | undefined, sources: Li
|
||||
const rows: LimitRow[] = []
|
||||
for (const f of LIMIT_FIELDS) {
|
||||
const v = limits[f.key]
|
||||
if (has(v)) rows.push({ key: f.key, label: f.label, value: f.usd ? `$${v}` : formatCompactCount(v), source: sourceLabel(sources?.[f.key]) })
|
||||
if (has(v)) rows.push({ key: f.key, label: f.label, value: f.usd ? formatCostDisplay(usdToMicros(v)) : formatCompactCount(v), source: sourceLabel(sources?.[f.key]) })
|
||||
}
|
||||
if (limits.pacing) {
|
||||
rows.push({ key: 'pacing', label: 'Pacing', value: `from ${limits.pacing.startPct}%, up to ${limits.pacing.maxDelay} delay`, source: sourceLabel(sources?.pacing) })
|
||||
rows.push({ key: 'pacing', label: 'Pacing', value: `from ${limits.pacing.startPct}%, up to ${limits.pacing.maxDelay} delay`, source: sourceLabel(sources?.pacing), prose: true })
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user