Compare commits

...
3 Commits
Author SHA1 Message Date
Denozordec 4be07fc242 Implement dynamic alias filtering across multiple routes
Publish telemt-api gateway Docker image / test (push) Successful in 28s
Publish telemt-api gateway Docker image / build-and-push (push) Successful in 2m16s
- Added a new function `applyAliasIfChanged` to handle alias updates based on user selection, improving responsiveness and consistency in alias filtering.
- Updated the effect handling to ensure the alias filter reflects changes in the URL parameters across various pages, enhancing user experience.
- Removed the "Apply" button for alias changes, streamlining the interaction process by applying changes automatically.
2026-03-30 23:03:01 +07:00
Denozordec aaacb80f9a Enhance alias filtering functionality in IP routes
- Added a new function to apply alias changes dynamically based on user selection, improving the responsiveness of the alias filter.
- Updated the alias selection logic to ensure consistency with URL parameters, enhancing user experience when navigating between different aliases.
- Refactored the alias filter component to include a class for better z-index management, ensuring proper display layering in the UI.
2026-03-30 23:01:40 +07:00
Denozordec 309750fd25 Refactor alias selection logic in AliasFilterSelect component
- Introduced internal state management for alias selection, improving responsiveness to changes in the selected value.
- Enhanced the effect handling to ensure the internal value remains consistent with available aliases, preventing invalid selections.
- Updated the binding in the Select component to use the internal state, streamlining the alias selection process.
2026-03-30 23:00:27 +07:00
6 changed files with 108 additions and 21 deletions

No files matched your search

@@ -13,16 +13,30 @@
allLabel?: string;
} = $props();
let selectedLabel = $derived(value === "all" ? allLabel : value);
let internalValue = $state(value ?? "all");
$effect(() => {
const next = value ?? "all";
if (internalValue !== next) internalValue = next;
});
$effect(() => {
if (internalValue !== "all" && !availableAliases.includes(internalValue)) {
internalValue = "all";
}
if (value !== internalValue) value = internalValue;
});
let selectedLabel = $derived(internalValue === "all" ? allLabel : internalValue);
</script>
<label class="text-xs text-muted-foreground">
{label}
<Select.Root type="single" bind:value>
<Select.Root type="single" bind:value={internalValue}>
<Select.Trigger class="mt-1 w-[220px]">
{selectedLabel}
</Select.Trigger>
<Select.Content>
<Select.Content class="z-[1200]">
<Select.Item value="all">{allLabel}</Select.Item>
{#each availableAliases as alias (alias)}
<Select.Item value={alias}>{alias}</Select.Item>
+20 -3
View File
@@ -196,6 +196,20 @@
});
}
async function applyAliasIfChanged(nextAlias: string) {
const currentAlias = parseAliasFilter(page.url.searchParams.get('aliases'));
if (nextAlias === currentAlias) return;
const q = new URLSearchParams(page.url.searchParams);
if (nextAlias === 'all') q.delete('aliases');
else q.set('aliases', nextAlias);
const qs = q.toString();
await goto(`${page.url.pathname}${qs ? `?${qs}` : ''}`, {
replaceState: true,
noScroll: true,
keepFocus: true
});
}
let queryKey = $derived(page.url.searchParams.toString());
$effect(() => {
queryKey;
@@ -207,6 +221,11 @@
void load();
});
$effect(() => {
if (typeof window === 'undefined') return;
void applyAliasIfChanged(aliasFilter);
});
let staleSeconds = $derived.by(() =>
lastSuccessAtMs == null ? null : Math.max(0, Math.floor((nowMs - lastSuccessAtMs) / 1000))
);
@@ -397,11 +416,9 @@
max="300"
class="mt-1 h-9 w-28 rounded-md border bg-background px-2 text-sm"
bind:value={refreshInput}
onchange={() => void applyControls()}
/>
</label>
<Button variant="outline" size="sm" onclick={() => void applyControls()} disabled={loading}>
Apply
</Button>
</div>
{#if partial}
+20 -3
View File
@@ -148,6 +148,20 @@
});
}
async function applyAliasIfChanged(nextAlias: string) {
const currentAlias = parseAliasFilter(page.url.searchParams.get('aliases'));
if (nextAlias === currentAlias) return;
const q = new URLSearchParams(page.url.searchParams);
if (nextAlias === 'all') q.delete('aliases');
else q.set('aliases', nextAlias);
const qs = q.toString();
await goto(`${page.url.pathname}${qs ? `?${qs}` : ''}`, {
replaceState: true,
noScroll: true,
keepFocus: true
});
}
let queryKey = $derived(page.url.searchParams.toString());
$effect(() => {
queryKey;
@@ -160,6 +174,11 @@
void load(nextAlias);
});
$effect(() => {
if (typeof window === 'undefined') return;
void applyAliasIfChanged(aliasFilter);
});
let staleSeconds = $derived.by(() =>
lastSuccessAtMs == null ? null : Math.max(0, Math.floor((nowMs - lastSuccessAtMs) / 1000))
);
@@ -221,11 +240,9 @@
max="300"
class="mt-1 h-9 w-28 rounded-md border bg-background px-2 text-sm"
bind:value={refreshInput}
onchange={() => void applyControls()}
/>
</label>
<Button variant="outline" size="sm" onclick={() => void applyControls()} disabled={loading}>
Apply
</Button>
</div>
{#if partial}
+21 -3
View File
@@ -349,6 +349,20 @@
});
}
async function applyAliasIfChanged(nextAlias: string) {
const currentAlias = parseAliasFilter(page.url.searchParams.get('aliases'));
if (nextAlias === currentAlias) return;
const q = new URLSearchParams(page.url.searchParams);
if (nextAlias === 'all') q.delete('aliases');
else q.set('aliases', nextAlias);
const qs = q.toString();
await goto(`${page.url.pathname}${qs ? `?${qs}` : ''}`, {
replaceState: true,
noScroll: true,
keepFocus: true
});
}
let queryKey = $derived(page.url.searchParams.toString());
$effect(() => {
queryKey;
@@ -361,6 +375,12 @@
void load();
});
$effect(() => {
if (typeof window === 'undefined') return;
const nextAlias = aliasFilter;
void applyAliasIfChanged(nextAlias);
});
let staleSeconds = $derived.by(() =>
lastSuccessAtMs == null ? null : Math.max(0, Math.floor((nowMs - lastSuccessAtMs) / 1000))
);
@@ -427,11 +447,9 @@
max="300"
class="mt-1 h-9 w-28 rounded-md border bg-background px-2 text-sm"
bind:value={refreshInput}
onchange={() => void applyControls()}
/>
</label>
<Button variant="outline" size="sm" onclick={() => void applyControls()} disabled={loading}>
Apply
</Button>
</div>
{#if partial}
+10 -6
View File
@@ -199,10 +199,12 @@
es = next;
}
async function applyControls() {
async function applyAliasIfChanged(nextAlias: string) {
const currentAlias = parseAliasFilter(page.url.searchParams.get('aliases'));
if (nextAlias === currentAlias) return;
const q = new URLSearchParams(page.url.searchParams);
if (aliasFilter === 'all') q.delete('aliases');
else q.set('aliases', aliasFilter);
if (nextAlias === 'all') q.delete('aliases');
else q.set('aliases', nextAlias);
const qs = q.toString();
await goto(`${page.url.pathname}${qs ? `?${qs}` : ''}`, {
replaceState: true,
@@ -220,6 +222,11 @@
connectStream(nextAlias);
});
$effect(() => {
if (typeof window === 'undefined') return;
void applyAliasIfChanged(aliasFilter);
});
let staleSeconds = $derived.by(() =>
lastEventAtMs == null ? null : Math.max(0, Math.floor((nowMs - lastEventAtMs) / 1000))
);
@@ -271,9 +278,6 @@
<div class="mb-4 flex flex-wrap items-end gap-2">
<AliasFilterSelect availableAliases={availableAliases} bind:value={aliasFilter} />
<Button variant="outline" size="sm" onclick={() => void applyControls()}>
Apply
</Button>
</div>
{#if err}
+20 -3
View File
@@ -92,6 +92,20 @@
});
}
async function applyAliasIfChanged(nextAlias: string) {
const currentAlias = parseAliasFilter(page.url.searchParams.get('aliases'));
if (nextAlias === currentAlias) return;
const q = new URLSearchParams(page.url.searchParams);
if (nextAlias === 'all') q.delete('aliases');
else q.set('aliases', nextAlias);
const qs = q.toString();
await goto(`${page.url.pathname}${qs ? `?${qs}` : ''}`, {
replaceState: true,
noScroll: true,
keepFocus: true
});
}
let queryKey = $derived(page.url.searchParams.toString());
$effect(() => {
queryKey;
@@ -104,6 +118,11 @@
void load();
});
$effect(() => {
if (typeof window === 'undefined') return;
void applyAliasIfChanged(aliasFilter);
});
let staleSeconds = $derived.by(() =>
lastSuccessAtMs == null ? null : Math.max(0, Math.floor((nowMs - lastSuccessAtMs) / 1000))
);
@@ -206,11 +225,9 @@
max="300"
class="mt-1 h-9 w-28 rounded-md border bg-background px-2 text-sm"
bind:value={refreshInput}
onchange={() => void applyControls()}
/>
</label>
<Button variant="outline" size="sm" onclick={() => void applyControls()} disabled={loading}>
Apply
</Button>
</div>
{#if partial}