mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
feat(admin-ui): alias labels, active-provider legends, denser tables and readable money
Label configured model aliases with an alias badge wherever a model id shows. List only providers with traffic in the window in provider chart legends. Page long tables, show a scroll shadow on wide ones and drop the duplicate model link. Show costs with thousands separators and magnitude-scaled decimals on cards and chart axes. Use whole-number ticks for count charts and replace all-zero charts with a message. Back off polling after failures. Keep the CSV status region from widening the page on phones. Regenerate admin_assets_gen.go.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Badge as="span" variant="outline" class="shrink-0 px-1.5 py-0 text-[10px] font-medium uppercase tracking-wide" title="Model alias defined in the gateway config">alias</Badge>
|
||||
</template>
|
||||
@@ -7,7 +7,7 @@ import TimeSeriesChart from '@/components/TimeSeriesChart.vue'
|
||||
import type { TimeSeriesDataset } from '@/components/TimeSeriesChart.vue'
|
||||
import { cumulative, runOutDate } from '@/lib/burndown'
|
||||
import { NOT_ENOUGH_DATA } from '@/lib/forecast'
|
||||
import { formatBucketLabel, formatCost, formatShortDate } from '@/lib/format'
|
||||
import { formatBucketLabel, formatCostAxis, formatCostDisplay, formatShortDate } from '@/lib/format'
|
||||
import { loadState } from '@/lib/load-state'
|
||||
|
||||
/**
|
||||
@@ -73,8 +73,8 @@ const willExceed = computed<boolean>(() => props.budgetMicros !== null && spentM
|
||||
>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="grid grid-cols-2 gap-4 text-sm sm:grid-cols-3">
|
||||
<StatItem label="Spent so far" :tone="willExceed ? 'destructive' : 'default'">{{ formatCost(spentMicros) }}</StatItem>
|
||||
<StatItem v-if="budgetMicros !== null" label="Budget">{{ formatCost(budgetMicros) }}</StatItem>
|
||||
<StatItem label="Spent so far" :tone="willExceed ? 'destructive' : 'default'">{{ formatCostDisplay(spentMicros) }}</StatItem>
|
||||
<StatItem v-if="budgetMicros !== null" label="Budget">{{ formatCostDisplay(budgetMicros) }}</StatItem>
|
||||
<StatItem
|
||||
v-if="budgetMicros !== null"
|
||||
label="Projected run-out"
|
||||
@@ -89,7 +89,8 @@ const willExceed = computed<boolean>(() => props.budgetMicros !== null && spentM
|
||||
:labels="labels"
|
||||
:datasets="datasets"
|
||||
:comparison-datasets="comparisonDatasets"
|
||||
:value-formatter="formatCost"
|
||||
:value-formatter="formatCostDisplay"
|
||||
:axis-formatter="formatCostAxis"
|
||||
ariaLabel="Cumulative spend this month against the configured budget"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -59,6 +59,7 @@ const props = withDefaults(
|
||||
comparisonDatasets?: TimeSeriesComparisonDataset[]
|
||||
stacked?: boolean
|
||||
valueFormatter?: (value: number) => string
|
||||
axisFormatter?: (value: number) => string
|
||||
/** Required whenever `state` can reach 'ready' with the default TimeSeriesChart body (TimeSeriesChart's own ariaLabel doc comment: no safe generic default) — optional here only so a skeleton-only ChartCard is not forced to pass a meaningless placeholder. */
|
||||
ariaLabel?: string
|
||||
}>(),
|
||||
@@ -92,6 +93,7 @@ const props = withDefaults(
|
||||
:comparison-datasets="comparisonDatasets"
|
||||
:stacked="stacked"
|
||||
:value-formatter="valueFormatter"
|
||||
:axis-formatter="axisFormatter"
|
||||
:ariaLabel="ariaLabel"
|
||||
/>
|
||||
</slot>
|
||||
@@ -113,6 +115,7 @@ const props = withDefaults(
|
||||
:comparison-datasets="comparisonDatasets"
|
||||
:stacked="stacked"
|
||||
:value-formatter="valueFormatter"
|
||||
:axis-formatter="axisFormatter"
|
||||
:ariaLabel="ariaLabel"
|
||||
/>
|
||||
</slot>
|
||||
|
||||
@@ -25,7 +25,7 @@ import UsageTable from '@/components/UsageTable.vue'
|
||||
import { useNow } from '@/composables/useNow'
|
||||
import { useSearchQuery } from '@/composables/useSearchQuery'
|
||||
import { monthCostProjection, NOT_ENOUGH_DATA, WILL_EXCEED_TITLE } from '@/lib/forecast'
|
||||
import { formatCost, formatLimits } from '@/lib/format'
|
||||
import { formatCostDisplay, formatLimits } from '@/lib/format'
|
||||
import { loadState } from '@/lib/load-state'
|
||||
import { type ExpandState, clearExpandOverrides, computeExpandedItems, toggleItemExpand } from '@/lib/search-expand'
|
||||
import { budgetRatios } from '@/lib/usage-bars'
|
||||
@@ -49,6 +49,9 @@ import type { AdminUsageEntryView } from '@/types/api'
|
||||
* Source column (inline/file, GET /admin/api/consumers) on the flat Users
|
||||
* table only.
|
||||
*/
|
||||
/** Rows per page in the flat Users table: keeps a 30+ user fleet scannable. */
|
||||
const USERS_PAGE_SIZE = 25
|
||||
|
||||
const dashboard = useDashboardStore()
|
||||
const consumers = useConsumersStore()
|
||||
const nav = useNavStore()
|
||||
@@ -232,7 +235,7 @@ function isGlobPattern(entry: string): boolean {
|
||||
/** groupCostProjection renders lib/forecast.ts's shared monthCostProjection (reuse-audit.md F7) for one group row as display text. */
|
||||
function groupCostProjection(entry: AdminUsageEntryView, now: Date): { text: string; willExceed: boolean } {
|
||||
const projection = monthCostProjection(entry, now)
|
||||
return { text: projection.micros === null ? NOT_ENOUGH_DATA : formatCost(projection.micros), willExceed: projection.willExceed }
|
||||
return { text: projection.micros === null ? NOT_ENOUGH_DATA : formatCostDisplay(projection.micros), willExceed: projection.willExceed }
|
||||
}
|
||||
/**
|
||||
* GROUP_DETAIL_FIELDS (reuse-audit.md F6) drives the group accordion's 4
|
||||
@@ -308,7 +311,7 @@ function groupsCsv(): string {
|
||||
</StatItem>
|
||||
<StatItem label="Tokens in/day"><CompactNumber :value="usage.total.tokensInPerDay" /></StatItem>
|
||||
<StatItem label="Tokens out/day"><CompactNumber :value="usage.total.tokensOutPerDay" /></StatItem>
|
||||
<StatItem label="Cost/day">{{ formatCost(usage.total.costPerDayMicroUsd) }}</StatItem>
|
||||
<StatItem label="Cost/day">{{ formatCostDisplay(usage.total.costPerDayMicroUsd) }}</StatItem>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@@ -328,7 +331,8 @@ function groupsCsv(): string {
|
||||
<SkeletonList v-if="dashboardLoadState === 'skeleton'" :rows="3" />
|
||||
<ErrorState v-else-if="dashboardLoadState === 'error'" :message="dashboard.error" :on-retry="dashboard.refresh" />
|
||||
<template v-else>
|
||||
<div v-if="sortedGroupRows.length" class="mb-3 flex flex-wrap gap-x-4 gap-y-1 text-xs font-medium text-muted-foreground">
|
||||
<div v-if="sortedGroupRows.length" class="mb-3 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs font-medium text-muted-foreground">
|
||||
<span>Sort groups by</span>
|
||||
<SortHeaderButton v-for="header in toolbarHeaders" :key="header.id" :header="header" />
|
||||
</div>
|
||||
|
||||
@@ -345,7 +349,7 @@ function groupsCsv(): string {
|
||||
<CompactNumber v-else :value="row.original.requestsPerDay" /> req/day
|
||||
</span>
|
||||
<span class="text-xs text-muted-foreground tabular-nums">
|
||||
{{ row.original.storeDown ? '?' : formatCost(row.original.costPerDayMicroUsd) }}/day
|
||||
{{ row.original.storeDown ? '?' : formatCostDisplay(row.original.costPerDayMicroUsd) }}/day
|
||||
</span>
|
||||
</span>
|
||||
</AccordionTrigger>
|
||||
@@ -425,7 +429,7 @@ function groupsCsv(): string {
|
||||
<template v-if="row.original.storeDown">?</template>
|
||||
<CompactNumber v-else :value="field.read(row.original)" />
|
||||
</DetailField>
|
||||
<DetailField label="cost/month" numeric>{{ row.original.storeDown ? '?' : formatCost(row.original.costPerMonthMicroUsd) }}</DetailField>
|
||||
<DetailField label="cost/month" numeric>{{ row.original.storeDown ? '?' : formatCostDisplay(row.original.costPerMonthMicroUsd) }}</DetailField>
|
||||
<DetailField
|
||||
label="cost/month (proj.)"
|
||||
numeric
|
||||
@@ -462,7 +466,7 @@ function groupsCsv(): string {
|
||||
<div class="flex items-start justify-between gap-2">
|
||||
<div>
|
||||
<CardTitle>Users</CardTitle>
|
||||
<CardDescription v-if="consumers.data?.usersFile">File-backed users load from {{ consumers.data.usersFile }}.</CardDescription>
|
||||
<CardDescription v-if="consumers.data?.usersFile" class="max-w-full truncate" :title="consumers.data.usersFile">File-backed users load from {{ consumers.data.usersFile }}.</CardDescription>
|
||||
</div>
|
||||
<CsvExportButton filename="consumers-users.csv" :build="usersCsv" />
|
||||
</div>
|
||||
@@ -470,6 +474,7 @@ function groupsCsv(): string {
|
||||
<CardContent>
|
||||
<LoadStateView :state="dashboardLoadState" :error="dashboard.error" :on-retry="dashboard.refresh" skeleton="table" :rows="5" :cols="5">
|
||||
<UsageTable
|
||||
:page-size="USERS_PAGE_SIZE"
|
||||
id-label="Name"
|
||||
secondary-column-label="Group"
|
||||
:entries="filteredUsers"
|
||||
|
||||
@@ -4,7 +4,7 @@ import { computed } from 'vue'
|
||||
import LabeledSelect from '@/components/LabeledSelect.vue'
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
|
||||
import { costAvoidedMicros, freeRows, pickReferenceModel } from '@/lib/cost-avoided'
|
||||
import { formatCost } from '@/lib/format'
|
||||
import { formatCostDisplay } from '@/lib/format'
|
||||
import type { AdminCatalogModel, AdminUsageModelEntry } from '@/types/api'
|
||||
|
||||
/**
|
||||
@@ -129,12 +129,12 @@ function onReferenceUpdate(value: unknown): void {
|
||||
<p v-if="avoidedMicros === null" class="text-sm text-muted-foreground">
|
||||
{{ priceableOptions.length === 0 ? 'No priced model served in range to compare against.' : 'Pick a reference model above.' }}
|
||||
</p>
|
||||
<p v-else class="text-lg font-semibold tabular-nums text-chart-requests">{{ formatCost(avoidedMicros) }}</p>
|
||||
<p v-else class="text-lg font-semibold tabular-nums text-chart-requests">{{ formatCostDisplay(avoidedMicros) }}</p>
|
||||
</div>
|
||||
<div v-if="cacheStatsEnabled">
|
||||
<p class="text-muted-foreground">Cache savings</p>
|
||||
<p v-if="!cacheSavingsAvailable" class="text-lg font-semibold tabular-nums text-muted-foreground">n/a</p>
|
||||
<p v-else class="text-lg font-semibold tabular-nums text-chart-requests">{{ formatCost(cacheSavedMicros) }}</p>
|
||||
<p v-else class="text-lg font-semibold tabular-nums text-chart-requests">{{ formatCostDisplay(cacheSavedMicros) }}</p>
|
||||
<p v-if="cacheSavingsNote" class="text-xs text-status-warn">{{ cacheSavingsNote }}</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { computed } from 'vue'
|
||||
import StatItem from '@/components/StatItem.vue'
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
|
||||
import { headroom, monthProgress, NOT_ENOUGH_DATA, projectMonthEnd, WILL_EXCEED_TITLE } from '@/lib/forecast'
|
||||
import { formatCost } from '@/lib/format'
|
||||
import { formatCostDisplay } from '@/lib/format'
|
||||
import type { LimitsConfig } from '@/types/api'
|
||||
|
||||
/**
|
||||
@@ -54,16 +54,16 @@ const forecast = computed(() => headroom(projectedMicros.value, props.limits?.co
|
||||
<CardDescription>Projected month-end spend, extrapolated from month-to-date usage (UTC calendar month).</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent class="grid grid-cols-2 gap-4 text-sm sm:grid-cols-3">
|
||||
<StatItem label="Month to date">{{ formatCost(mtdMicros) }}</StatItem>
|
||||
<StatItem label="Month to date">{{ formatCostDisplay(mtdMicros) }}</StatItem>
|
||||
<StatItem
|
||||
label="Projected month-end"
|
||||
:tone="forecast.willExceed ? 'destructive' : 'default'"
|
||||
:title="forecast.willExceed ? WILL_EXCEED_TITLE : undefined"
|
||||
:hint="projectedMicros === null ? NOT_ENOUGH_DATA : undefined"
|
||||
>
|
||||
{{ projectedMicros === null ? '' : formatCost(projectedMicros) }}
|
||||
{{ projectedMicros === null ? '' : formatCostDisplay(projectedMicros) }}
|
||||
</StatItem>
|
||||
<StatItem v-if="forecast.limitMicros !== null" label="Limit">{{ formatCost(forecast.limitMicros) }}</StatItem>
|
||||
<StatItem v-if="forecast.limitMicros !== null" label="Limit">{{ formatCostDisplay(forecast.limitMicros) }}</StatItem>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</template>
|
||||
|
||||
@@ -81,7 +81,7 @@ onBeforeUnmount(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Button type="button" variant="outline" size="sm" :disabled="exporting" @click="onClick">
|
||||
<Button type="button" variant="outline" size="sm" class="relative" :disabled="exporting" @click="onClick">
|
||||
<FontAwesomeIcon v-if="feedback === 'failed'" :icon="faCircleXmark" class="size-3.5 text-destructive" aria-hidden="true" />
|
||||
<FontAwesomeIcon
|
||||
v-else-if="feedback"
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<script setup lang="ts" generic="TData">
|
||||
import type { ColumnDef, SortingState } from '@tanstack/vue-table'
|
||||
import { FlexRender, getCoreRowModel, getSortedRowModel, useVueTable } from '@tanstack/vue-table'
|
||||
import { ref } from 'vue'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import SortHeaderButton from '@/components/SortHeaderButton.vue'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { pageWindow } from '@/lib/paging'
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
@@ -40,6 +42,8 @@ const props = defineProps<{
|
||||
emptyMessage?: string
|
||||
/** Accessible name for the table (aria-label). */
|
||||
label?: string
|
||||
/** Rows per page; omit to show every row. A pager appears only when the data exceeds one page. */
|
||||
pageSize?: number
|
||||
/**
|
||||
* Optional CONTROLLED sort state (P6, `v-model:sorting`). Omitted (the
|
||||
* default) keeps every existing call site's original UNCONTROLLED
|
||||
@@ -59,6 +63,8 @@ const emit = defineEmits<{ 'update:sorting': [value: SortingState] }>()
|
||||
/** internalSorting is read only when props.sorting is undefined (uncontrolled mode) — see the `sorting` prop's own doc comment above. */
|
||||
const internalSorting = ref<SortingState>([])
|
||||
|
||||
const pageIndex = ref(0)
|
||||
|
||||
const table = useVueTable({
|
||||
get data() {
|
||||
return props.data
|
||||
@@ -81,6 +87,11 @@ const table = useVueTable({
|
||||
},
|
||||
})
|
||||
|
||||
const allRows = computed(() => table.getRowModel().rows)
|
||||
const pg = computed(() => pageWindow(allRows.value.length, props.pageSize ?? Math.max(1, allRows.value.length), pageIndex.value))
|
||||
const paged = computed(() => props.pageSize !== undefined && allRows.value.length > props.pageSize)
|
||||
const visibleRows = computed(() => (paged.value ? allRows.value.slice(pg.value.from, pg.value.to) : allRows.value))
|
||||
|
||||
/** ariaSort maps a column's current sort direction to the `aria-sort` value native to a real <th> — set only on the sorted column, per spec. */
|
||||
function ariaSort(dir: false | 'asc' | 'desc'): 'ascending' | 'descending' | undefined {
|
||||
if (dir === 'asc') return 'ascending'
|
||||
@@ -90,6 +101,7 @@ function ariaSort(dir: false | 'asc' | 'desc'): 'ascending' | 'descending' | und
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<Table :aria-label="label">
|
||||
<TableHeader>
|
||||
<TableRow v-for="headerGroup in table.getHeaderGroups()" :key="headerGroup.id">
|
||||
@@ -108,7 +120,7 @@ function ariaSort(dir: false | 'asc' | 'desc'): 'ascending' | 'descending' | und
|
||||
<TableEmpty v-if="table.getRowModel().rows.length === 0" :colspan="columns.length" class="text-muted-foreground">
|
||||
{{ emptyMessage ?? 'No rows to show.' }}
|
||||
</TableEmpty>
|
||||
<TableRow v-for="row in table.getRowModel().rows" :key="row.id" :class="rowClass?.(row.original)">
|
||||
<TableRow v-for="row in visibleRows" :key="row.id" :class="rowClass?.(row.original)">
|
||||
<TableCell
|
||||
v-for="cell in row.getVisibleCells()"
|
||||
:key="cell.id"
|
||||
@@ -119,4 +131,13 @@ function ariaSort(dir: false | 'asc' | 'desc'): 'ascending' | 'descending' | und
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
<nav v-if="paged" class="flex items-center justify-between gap-2 pt-3 text-xs text-muted-foreground" aria-label="Table pages">
|
||||
<span aria-live="polite">Rows {{ pg.from + 1 }}–{{ pg.to }} of {{ allRows.length }}</span>
|
||||
<span class="flex items-center gap-2">
|
||||
<Button type="button" variant="outline" size="sm" :disabled="pg.index === 0" @click="pageIndex = pg.index - 1">Previous</Button>
|
||||
<span class="tabular-nums">Page {{ pg.index + 1 }} / {{ pg.count }}</span>
|
||||
<Button type="button" variant="outline" size="sm" :disabled="pg.index >= pg.count - 1" @click="pageIndex = pg.index + 1">Next</Button>
|
||||
</span>
|
||||
</nav>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { faArrowUpRightFromSquare } from '@fortawesome/free-solid-svg-icons'
|
||||
|
||||
import AliasBadge from '@/components/AliasBadge.vue'
|
||||
import { useAliasNames } from '@/composables/useAliasNames'
|
||||
import { useNavStore } from '@/stores/nav'
|
||||
|
||||
/**
|
||||
@@ -43,6 +45,7 @@ const props = defineProps<{
|
||||
}>()
|
||||
|
||||
const nav = useNavStore()
|
||||
const { isAlias } = useAliasNames()
|
||||
|
||||
const TARGET: Record<'user' | 'model', { page: 'consumers' | 'models'; paramKey: 'user' | 'model'; noun: string }> = {
|
||||
user: { page: 'consumers', paramKey: 'user', noun: 'Consumers' },
|
||||
@@ -65,6 +68,7 @@ function onClick(event: MouseEvent): void {
|
||||
@click="onClick"
|
||||
>
|
||||
<span class="min-w-0" :class="labelClass">{{ label }}</span>
|
||||
<AliasBadge v-if="kind === 'model' && isAlias(id)" />
|
||||
<FontAwesomeIcon :icon="faArrowUpRightFromSquare" class="size-3 shrink-0" aria-hidden="true" />
|
||||
</button>
|
||||
</template>
|
||||
|
||||
@@ -69,6 +69,9 @@ const columns = eventsColumns()
|
||||
* states-plan.md item 3 — so content is never wiped/replaced by a
|
||||
* skeleton or error here).
|
||||
*/
|
||||
/** Rows per page in the Events table. */
|
||||
const EVENTS_PAGE_SIZE = 50
|
||||
|
||||
const eventsLoadState = computed(() => loadState({ loading: events.refreshing, hasData: events.lastUpdated !== null, error: events.error }))
|
||||
const staleMessage = computed(() => staleNotice(events.lastUpdated !== null, events.error, events.lastUpdated))
|
||||
|
||||
@@ -160,7 +163,7 @@ onUnmounted(() => {
|
||||
title="No failures recorded."
|
||||
description="Rate-limit, budget, and upstream events will show up here as they happen."
|
||||
/>
|
||||
<DataTable v-else label="Events" :columns="columns" :data="filteredEvents" :empty-message="emptyMessage" />
|
||||
<DataTable v-else label="Events" :page-size="EVENTS_PAGE_SIZE" :columns="columns" :data="filteredEvents" :empty-message="emptyMessage" />
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
import { faCheck, faCopy, faTriangleExclamation } from '@fortawesome/free-solid-svg-icons'
|
||||
import { computed, useTemplateRef } from 'vue'
|
||||
|
||||
import AliasBadge from '@/components/AliasBadge.vue'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { useAliasNames } from '@/composables/useAliasNames'
|
||||
import { useCopyFeedback } from '@/composables/useCopyFeedback'
|
||||
import { copyText } from '@/lib/clipboard'
|
||||
import { formatContextWindow, formatModelCostHover } from '@/lib/format'
|
||||
@@ -50,6 +52,7 @@ const props = defineProps<{
|
||||
outputPerMTokUsd?: number
|
||||
}>()
|
||||
|
||||
const { isAlias } = useAliasNames()
|
||||
const labelRef = useTemplateRef<HTMLElement>('label')
|
||||
const { state, set: setCopyFeedback } = useCopyFeedback()
|
||||
const toasts = useToastsStore()
|
||||
@@ -125,6 +128,7 @@ const title = computed(() => {
|
||||
@click="onClick"
|
||||
>
|
||||
<span ref="label" class="min-w-0 truncate select-text">{{ id }}</span>
|
||||
<AliasBadge v-if="isAlias(id)" />
|
||||
<FontAwesomeIcon :icon="icon[state]" class="size-2.5 shrink-0" aria-hidden="true" />
|
||||
</Badge>
|
||||
</template>
|
||||
|
||||
@@ -58,6 +58,8 @@ const props = withDefaults(
|
||||
stacked?: boolean
|
||||
/** Formats a raw value for the tooltip and y-axis ticks — defaults to formatExactInt (lib/format.ts). Cost callers pass formatCost, a ratio series a percent formatter, and so on. */
|
||||
valueFormatter?: (value: number) => string
|
||||
/** Y-axis tick formatter when the tooltip formatter is too wordy for a tick (cost: "$1,600" not "$1,600.00"); defaults to valueFormatter. */
|
||||
axisFormatter?: (value: number) => string
|
||||
/**
|
||||
* ariaLabel is this chart's accessible name (P3 item 16) — a bare
|
||||
* `<canvas>` has no text alternative at all for a screen reader, so
|
||||
@@ -158,7 +160,12 @@ const chartOptions = computed<ChartOptions<'line'>>(() => ({
|
||||
stacked: props.stacked,
|
||||
beginAtZero: true,
|
||||
grid: { color: border.value },
|
||||
ticks: { color: mutedForeground.value, callback: (value) => props.valueFormatter(Number(value)) },
|
||||
// Counts are whole numbers: no 0.1-step ticks on a chart whose largest value is 1.
|
||||
ticks: {
|
||||
color: mutedForeground.value,
|
||||
precision: props.valueFormatter === formatExactInt ? 0 : undefined,
|
||||
callback: (value) => (props.axisFormatter ?? props.valueFormatter)(Number(value)),
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
|
||||
@@ -28,6 +28,8 @@ const props = defineProps<{
|
||||
sorting?: SortingState
|
||||
/** Optional per-row source lookup ('inline'/'file'/undefined), forwarded to usage-columns.ts's usageColumns — see that module's sourceColumn doc comment. Omitted everywhere except ConsumerDirectory.vue's flat Users table. */
|
||||
sourceValue?: (entry: AdminUsageEntryView) => string | undefined
|
||||
/** Forwarded to DataTable: rows per page for large user lists. */
|
||||
pageSize?: number
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{ 'update:sorting': [value: SortingState] }>()
|
||||
@@ -40,6 +42,7 @@ const columns = computed(() =>
|
||||
<template>
|
||||
<DataTable
|
||||
label="Usage"
|
||||
:page-size="pageSize"
|
||||
:columns="columns"
|
||||
:data="entries"
|
||||
:empty-message="emptyMessage"
|
||||
|
||||
@@ -19,7 +19,7 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/com
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'
|
||||
import { useNow } from '@/composables/useNow'
|
||||
import { runOutDate as computeRunOutDate } from '@/lib/burndown'
|
||||
import { formatBucketLabel, formatCost, formatLimits, formatShortDate, formatTimestamp } from '@/lib/format'
|
||||
import { formatBucketLabel, formatCostAxis, formatCostDisplay, formatLimits, formatShortDate, formatTimestamp } from '@/lib/format'
|
||||
import { loadState } from '@/lib/load-state'
|
||||
import { budgetRatios, usdToMicros } from '@/lib/usage-bars'
|
||||
import { useConsumersStore } from '@/stores/consumers'
|
||||
@@ -187,8 +187,8 @@ const runOutDate = computed(() => {
|
||||
</CardContent>
|
||||
<CardContent v-else class="grid grid-cols-2 gap-4 text-sm sm:grid-cols-4">
|
||||
<StatItem label="Requests/day"><CompactNumber :value="entry.requestsPerDay" /></StatItem>
|
||||
<StatItem label="Cost/day">{{ formatCost(entry.costPerDayMicroUsd) }}</StatItem>
|
||||
<StatItem label="Cost/month">{{ formatCost(entry.costPerMonthMicroUsd) }}</StatItem>
|
||||
<StatItem label="Cost/day">{{ formatCostDisplay(entry.costPerDayMicroUsd) }}</StatItem>
|
||||
<StatItem label="Cost/month">{{ formatCostDisplay(entry.costPerMonthMicroUsd) }}</StatItem>
|
||||
<div>
|
||||
<p class="text-muted-foreground">Limits</p>
|
||||
<p class="text-sm">{{ formatLimits(entry.limits) }}</p>
|
||||
@@ -223,7 +223,8 @@ const runOutDate = computed(() => {
|
||||
:on-retry="loadDetail"
|
||||
:labels="costLabels"
|
||||
:datasets="costDatasets"
|
||||
:value-formatter="formatCost"
|
||||
:value-formatter="formatCostDisplay"
|
||||
:axis-formatter="formatCostAxis"
|
||||
:aria-label="`Cost over time for ${userId}`"
|
||||
/>
|
||||
|
||||
@@ -256,7 +257,7 @@ const runOutDate = computed(() => {
|
||||
<TableRow v-for="row in modelRows" :key="row.id">
|
||||
<TableCell><ModelChip :id="row.id" /></TableCell>
|
||||
<TableCell class="text-right tabular-nums"><CompactNumber :value="row.values.req ?? 0" /></TableCell>
|
||||
<TableCell class="text-right tabular-nums">{{ formatCost(row.values.cost ?? 0) }}</TableCell>
|
||||
<TableCell class="text-right tabular-nums">{{ formatCostDisplay(row.values.cost ?? 0) }}</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
@@ -10,7 +10,7 @@ const props = defineProps<{
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div data-slot="table-container" class="relative w-full overflow-x-auto">
|
||||
<div data-slot="table-container" class="scroll-shadow-x relative w-full overflow-x-auto">
|
||||
<table data-slot="table" v-bind="$attrs" :class="cn('w-full caption-bottom text-sm', props.class)">
|
||||
<slot />
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user