Files
traefik-llmgateway/webui/src/App.vue
T
lukaszraczylo 0da9479e08 fix(admin): attach model aliases to the model their target resolves to
The catalog grouped aliases by the raw target string and looked them up by
canonical provider/model id. A bare target never matched, so no model card
listed its aliases. Each alias now keys on the canonical id that the
registry resolves its target to. The alias view gains an additive
resolvedTarget field.

Model-id cells in the overview, usage and panels now show an alias badge
with the target, using the catalog alias list.
2026-11-28 01:55:09 +00:00

95 lines
3.8 KiB
Vue

<script setup lang="ts">
import type { Component } from 'vue'
import { computed, defineAsyncComponent, onMounted, watch } from 'vue'
import AuthGate from '@/components/AuthGate.vue'
import ConfigWarningsBanner from '@/components/ConfigWarningsBanner.vue'
import PageLoadError from '@/components/PageLoadError.vue'
import ToastViewport from '@/components/ToastViewport.vue'
import { useHashState } from '@/composables/useHashState'
import AppLayout from '@/layout/AppLayout.vue'
import type { PageId } from '@/lib/pages'
import { useAuthStore } from '@/stores/auth'
import { useCatalogStore } from '@/stores/catalog'
import { useConfigStore } from '@/stores/config'
import { useDashboardStore } from '@/stores/dashboard'
import { useNavStore } from '@/stores/nav'
import { resetSessionData } from '@/stores/session'
const auth = useAuthStore()
const catalog = useCatalogStore()
const config = useConfigStore()
const dashboard = useDashboardStore()
const nav = useNavStore()
// The old flat-tab shell (activeTab/useTabHash) is superseded by the
// sidebar-page redesign (redesign-plan.md section 3.1): nav.page/params
// now drive routing, and useHashState() keeps them — plus the global
// filters (stores/filters.ts) — synced with a single
// "#<page>?range=...&cmp=...&scope=...&<page params>" URL hash. MUST be
// created here, before the `v-if="!auth.isAuthenticated"` branch below
// (load-with-hash-then-authenticate) — every store write it makes is
// safe to run before a key is stored, so the hash's selection is already
// restored by the time the reader authenticates.
useHashState()
/**
* PAGES maps each PageId (lib/pages.ts) to its own top-level page
* component, lazily loaded — an admin session only ever looks at one
* page at a time, so only that page's own code (and, for the pages
* other work packages are filling in with chart.js-backed views) ships
* on first load, generalizing the same reasoning the old shell already
* applied to its one chart-heavy tab.
*/
function lazyPage(loader: () => Promise<Component>): Component {
return defineAsyncComponent({ loader, errorComponent: PageLoadError, timeout: 30_000 })
}
const PAGES: Record<PageId, Component> = {
overview: lazyPage(() => import('@/pages/OverviewPage.vue')),
usage: lazyPage(() => import('@/pages/UsagePage.vue')),
reliability: lazyPage(() => import('@/pages/ReliabilityPage.vue')),
users: lazyPage(() => import('@/pages/UsersPage.vue')),
models: lazyPage(() => import('@/pages/ModelsPage.vue')),
routers: lazyPage(() => import('@/pages/RoutersPage.vue')),
targets: lazyPage(() => import('@/pages/TargetsPage.vue')),
events: lazyPage(() => import('@/pages/EventsPage.vue')),
config: lazyPage(() => import('@/pages/ConfigPage.vue')),
}
const currentPage = computed<Component>(() => PAGES[nav.page])
// A different key may carry different privileges, so never keep the previous key's data on screen.
watch(
() => auth.apiKey,
(next, prev) => {
if (next !== prev) resetSessionData()
},
)
// Every model-id cell marks an alias from the catalog's alias list, so load it once per key.
watch(
() => auth.apiKey,
() => {
if (auth.isAuthenticated) void catalog.ensureLoaded()
},
{ immediate: true },
)
onMounted(() => {
dashboard.startPolling()
})
</script>
<template>
<div v-if="!auth.isAuthenticated" class="px-4 py-6 sm:px-6 lg:px-8">
<AuthGate />
</div>
<AppLayout v-else>
<!-- GET /admin/api/overview's config warnings — renders nothing itself once `warnings` is empty, so this is always safe to mount. -->
<ConfigWarningsBanner v-if="nav.page !== 'config' || (config.error !== '' && !config.data)" :warnings="dashboard.overview?.warnings ?? []" :warnings-dropped="dashboard.overview?.warningsDropped" />
<component :is="currentPage" />
</AppLayout>
<ToastViewport />
</template>