mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
fix(webui): show unavailable usage when the store is down
This commit is contained in:
@@ -3,6 +3,7 @@ import { StatBar } from '@perfect-design/ui'
|
||||
import { computed } from 'vue'
|
||||
|
||||
import { formatCompactCount } from '@/lib/format'
|
||||
import { STORE_DOWN_HINT } from '@/lib/usage-store'
|
||||
import type { Meter } from '@/lib/meters'
|
||||
|
||||
const props = defineProps<{ meter: Meter }>()
|
||||
@@ -13,13 +14,13 @@ function fmt(n: number): string {
|
||||
|
||||
const pacing = computed(() => props.meter.markers.find((m) => m.tone === 'warning'))
|
||||
const warnAt = computed(() => (pacing.value ? pacing.value.value / props.meter.max : 0.8))
|
||||
const valueText = computed(() => `${fmt(props.meter.value)} / ${fmt(props.meter.max)}`)
|
||||
const valueText = computed(() => `${props.meter.unavailable ? '—' : fmt(props.meter.value)} / ${fmt(props.meter.max)}`)
|
||||
const markers = computed(() => props.meter.markers.map((m) => ({ ...m, valueText: fmt(m.value) })))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-1" data-testid="meter">
|
||||
<StatBar :label="meter.label" :value="meter.value" :max="meter.max" :value-text="valueText" tone="auto" :warn-at="warnAt" :danger-at="1" size="md" :markers="markers" />
|
||||
<div class="flex flex-col gap-1" data-testid="meter" :title="meter.unavailable ? STORE_DOWN_HINT : undefined" :class="{ 'opacity-60': meter.unavailable }">
|
||||
<StatBar :label="meter.label" :value="meter.unavailable ? 0 : meter.value" :max="meter.max" :value-text="valueText" tone="auto" :warn-at="warnAt" :danger-at="1" size="md" :markers="markers" />
|
||||
<p class="text-muted-foreground m-0 flex flex-wrap gap-x-4 text-xs">
|
||||
<span v-for="m in markers" :key="m.label" data-testid="meter-marker">{{ m.label }} <span class="font-mono tabular-nums">{{ m.valueText }}</span></span>
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user