Files
traefik-llmgateway/webui/vite.config.ts
T
lukaszraczylo d6b9879813 feat(webui): user and group search filter on usage and charts views
Add a "Filter users or groups" search input to UsageView, mirroring
OverviewView's model search (same Input component, icon, and
clear-button styling). Case-insensitive, trimmed substring match:

- A user matches when its own name contains the query.
- A group matches when its own name contains the query OR it has at
  least one matching member.

Groups accordion shows only matching groups, sorted through the
existing Groups toolbar unchanged. A group that matches only via a
member auto-expands (using the same tested override semantics as
Overview's provider search); a group matched by its own name is not
force-expanded, since the match is already visible on its collapsed
trigger row. The nested members table inside an expanded group shows
every member when the group matched by name, and only the matching
members when it matched via a member.

The flat Users table filters to matching users, plus every member of
a name-matched group. The Total card and ChartsView's chart rendering
are untouched by the filter.

ChartsView's scope picker (Select) gets the identical search input,
filtering the user/group option list it offers. "Total" always stays
in the list, and the currently selected scope is always kept in the
list even if a new query would otherwise hide it, so an active chart
is never torn down or re-labeled by narrowing the picker.

Generalize lib/provider-expand.ts into lib/search-expand.ts: the same
two-set (manuallyExpanded/manuallyCollapsed) auto-expand/override state
machine now drives both Overview's providers and Usage's groups, keyed
on generic string ids instead of provider names specifically.
OverviewView.vue is updated to the renamed
computeExpandedItems/toggleItemExpand exports; its own behavior is
unchanged. The moved spec (search-expand.spec.ts) keeps all 9 original
cases plus 2 new ones pinning the same semantics against non-provider
(group-shaped) ids.

Add lib/usage-search.ts with the shared user/group matching helpers
(userMatches, groupNameMatches, membersOfGroup,
matchingMembersOfGroup, groupMatches) so UsageView and ChartsView
share one matching implementation, with its own vitest spec.

UsageTable.vue gains an optional emptyMessage prop (threaded to
DataTable) so UsageView can show a "no users match ..."/"no groups
match ..." message under an active filter, matching Overview's own
alias-search empty-state pattern.

No backend/Go logic changes; filtering is client-side over the
already-polled GET /admin/api/usage response.
2026-08-21 12:16:57 +01:00

46 lines
2.0 KiB
TypeScript

import { fileURLToPath, URL } from 'node:url'
import tailwindcss from '@tailwindcss/vite'
import vue from '@vitejs/plugin-vue'
// vitest/config's defineConfig is vite's own, augmented with the `test`
// field's types — importing from here (not 'vite') is what lets the
// `test` block below type-check under vue-tsc -b without a separate
// vitest.config.ts or a triple-slash type reference.
import { defineConfig } from 'vitest/config'
// https://vite.dev/config/
export default defineConfig({
// admin.go serves this build's index.html at GET /admin and every hashed
// asset at GET /admin/assets/{hashedname} — the base must match so the
// emitted index.html's own <script>/<link> references resolve correctly
// regardless of what path the browser first loaded the page from.
base: '/admin/',
plugins: [vue(), tailwindcss()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
build: {
// No inline bootstrap script in the emitted index.html (admin.go's CSP
// ships script-src 'self' with no 'unsafe-inline' — see the Go-side
// asset-serving comment for the full rationale): Vite's module-preload
// polyfill is otherwise inlined as a <script> tag, which that CSP would
// block. Disabling it leaves only <link rel="modulepreload"> hints,
// which need no script-src allowance at all. The admin panel only ever
// targets current evergreen browsers (native ES module support), so the
// polyfill has nothing to do here anyway.
modulePreload: { polyfill: false },
},
test: {
// Deliberately narrow: only lib/'s pure modules (search-expand.ts,
// usage-search.ts) are under vitest right now (webui's test infra
// starts here, on purpose — no snapshot/DOM/component testing this
// round). 'node' is enough since neither module touches browser
// globals; jsdom is not pulled in as a dependency for modules that
// don't need it.
environment: 'node',
include: ['src/**/*.spec.ts'],
},
})