feat: add filtering to all entity list pages

- Tracking configs: filter by name + provider type
- Template configs: filter by name + provider type
- Command configs: filter by name + provider type
- Notification trackers: filter by name + provider
- Command trackers: filter by name + provider
- Targets: filter by name (type filtering already existed)
- Nav badge counts include system-owned entities (user_id=0)
- Shows "no items match filter" vs "no items yet" empty states
This commit is contained in:
2026-03-22 20:22:53 +03:00
parent 63437c1841
commit 7cbba9d3fd
9 changed files with 165 additions and 17 deletions
@@ -19,7 +19,13 @@
import { highlightFromUrl } from '$lib/highlight';
import type { TrackingConfig } from '$lib/types';
let configs = $derived(trackingConfigsCache.items);
let allConfigs = $derived(trackingConfigsCache.items);
let filterText = $state('');
let filterType = $state('');
let configs = $derived(allConfigs.filter(c =>
(!filterText || c.name.toLowerCase().includes(filterText.toLowerCase())) &&
(!filterType || c.provider_type === filterType)
));
let loaded = $state(false);
let showForm = $state(false);
let editing = $state<number | null>(null);
@@ -228,10 +234,28 @@
</div>
{/if}
{#if configs.length === 0 && !showForm}
{#if !showForm && allConfigs.length > 0}
<div class="flex items-center gap-2 mb-3">
<input type="text" bind:value={filterText} placeholder={t('common.filterByName')}
class="flex-1 px-3 py-1.5 border border-[var(--color-border)] rounded-md text-sm bg-[var(--color-background)]" />
<select bind:value={filterType}
class="px-3 py-1.5 border border-[var(--color-border)] rounded-md text-sm bg-[var(--color-background)]">
<option value="">{t('common.allTypes')}</option>
<option value="immich">Immich</option>
<option value="gitea">Gitea</option>
<option value="scheduler">Scheduler</option>
</select>
</div>
{/if}
{#if allConfigs.length === 0 && !showForm}
<Card>
<EmptyState icon="mdiCog" message={t('trackingConfig.noConfigs')} />
</Card>
{:else if configs.length === 0 && !showForm}
<Card>
<EmptyState icon="mdiFilterOff" message={t('common.noFilterResults')} />
</Card>
{:else}
<div class="space-y-3 stagger-children">
{#each configs as config}