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:
@@ -18,7 +18,13 @@
|
||||
import { highlightFromUrl } from '$lib/highlight';
|
||||
import type { ServiceProvider, TelegramBot } from '$lib/types';
|
||||
|
||||
let trackers = $state<any[]>([]);
|
||||
let allCmdTrackers = $state<any[]>([]);
|
||||
let filterText = $state('');
|
||||
let filterProviderId = $state(0);
|
||||
let trackers = $derived(allCmdTrackers.filter((t: any) =>
|
||||
(!filterText || t.name.toLowerCase().includes(filterText.toLowerCase())) &&
|
||||
(!filterProviderId || t.provider_id === filterProviderId)
|
||||
));
|
||||
let providers = $derived(providersCache.items);
|
||||
let commandConfigs = $derived(commandConfigsCache.items);
|
||||
let telegramBots = $derived(telegramBotsCache.items);
|
||||
@@ -60,7 +66,7 @@
|
||||
onMount(load);
|
||||
async function load() {
|
||||
try {
|
||||
[trackers] = await Promise.all([
|
||||
[allCmdTrackers] = await Promise.all([
|
||||
api('/command-trackers'),
|
||||
providersCache.fetch(), commandConfigsCache.fetch(),
|
||||
telegramBotsCache.fetch(),
|
||||
@@ -212,10 +218,28 @@
|
||||
</Card>
|
||||
{/if}
|
||||
|
||||
{#if trackers.length === 0 && !showForm}
|
||||
{#if !showForm && allCmdTrackers.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={filterProviderId}
|
||||
class="px-3 py-1.5 border border-[var(--color-border)] rounded-md text-sm bg-[var(--color-background)]">
|
||||
<option value={0}>{t('common.allProviders')}</option>
|
||||
{#each providers as p}
|
||||
<option value={p.id}>{p.name} ({p.type})</option>
|
||||
{/each}
|
||||
</select>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if allCmdTrackers.length === 0 && !showForm}
|
||||
<Card>
|
||||
<EmptyState icon="mdiConsoleLine" message={t('commandTracker.noTrackers')} />
|
||||
</Card>
|
||||
{:else if trackers.length === 0 && !showForm}
|
||||
<Card>
|
||||
<EmptyState icon="mdiFilterOff" message={t('common.noFilterResults')} />
|
||||
</Card>
|
||||
{:else}
|
||||
<div class="space-y-3 stagger-children">
|
||||
{#each trackers as trk}
|
||||
|
||||
Reference in New Issue
Block a user