feat(ui): page, search and filter packages on the server

The package list loaded every package, then grouped and paged in the
browser. The dashboard did the same to show ten recent rows.

- PackageList asks the server for one page of 25 groups. The registry
  filter and a debounced search box (300 ms) change the request. A newer
  request replaces the answer of an older one.
- Dashboard loads a page of 10 groups sorted by cached_at, newest first,
  and runs its stats, recent list and chart requests in parallel.
- Stats already used /api/stats only and does not change.
- The store keeps the loading flag on until the last overlapping request
  settles. Deleting a package no longer reloads the full list, and the
  list reloads its own page instead.
- VulnerablePackages keeps the unpaginated call because it filters on
  scan results in the browser.
This commit is contained in:
2026-11-23 13:26:50 +00:00
parent db5ca2539f
commit ac4f39322c
7 changed files with 423 additions and 158 deletions
+4 -14
View File
@@ -75,7 +75,7 @@
</CardHeader>
<CardContent>
<EmptyState
v-if="packages.length === 0"
v-if="recentPackages.length === 0"
size="sm"
:icon="faBoxOpen"
title="No packages cached yet"
@@ -140,7 +140,7 @@ import {
} from '@/lib/icons'
const store = usePackageStore()
const { packages, stats, loading, error } = storeToRefs(store)
const { recentPackages, stats, loading, error } = storeToRefs(store)
const rt = useRealtimeStore()
const { lastStats, events: rtEvents } = storeToRefs(rt)
@@ -259,7 +259,7 @@ const packageColumns: DataTableColumn<Package>[] = [
function refresh() {
void store.fetchStats()
void store.fetchPackages()
void store.fetchRecentPackages()
}
function getChartLabel(index: number): string {
@@ -291,14 +291,6 @@ function getChartLabel(index: number): string {
return labels[selectedPeriod.value]?.(index) || `${index}`
}
// API returns clean, deduplicated data - just sort and limit
const recentPackages = computed(() => {
return packages.value
.slice()
.sort((a, b) => new Date(b.cached_at).getTime() - new Date(a.cached_at).getTime())
.slice(0, 10)
})
// Watch for period changes and fetch new data
watch(selectedPeriod, () => {
fetchTimeSeriesData()
@@ -309,9 +301,7 @@ onMounted(async () => {
// initial polling resolves. Singleton survives navigation, so we
// intentionally do not disconnect on unmount.
rt.connect()
await store.fetchStats()
await store.fetchPackages()
await fetchTimeSeriesData()
await Promise.all([store.fetchStats(), store.fetchRecentPackages(), fetchTimeSeriesData()])
})
</script>