From 0647306d7814b8f3cdb934dde8fc0daa59e82dc0 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Wed, 1 Jan 2025 11:52:56 -0600 Subject: [PATCH] webapp: shorter "filters" to "f", to be consistent with "q" --- webapp/src/Alerts.tsx | 14 ++++++-------- webapp/src/Events.tsx | 13 ++++--------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/webapp/src/Alerts.tsx b/webapp/src/Alerts.tsx index d2cdb240..880aa0bc 100644 --- a/webapp/src/Alerts.tsx +++ b/webapp/src/Alerts.tsx @@ -95,7 +95,7 @@ export function Alerts() { sortBy?: string; sortOrder?: "asc" | "desc"; sensor?: undefined | string; - filters?: string[]; + f?: string[]; }>(); const [cursor, setCursor] = createSignal(0); const [isLoading, setIsLoading] = createSignal(false); @@ -104,9 +104,7 @@ export function Alerts() { const [timedOut, setTimedOut] = createSignal(false); // For display of the filters. Reactiveness comes from the searchParams. - const [filters, setFilters] = createSignal( - searchParams.filters || [] - ); + const [filters, setFilters] = createSignal(searchParams.f || []); let toggleSelectAllRef: HTMLInputElement | null = null; let bindings: any = null; @@ -338,7 +336,7 @@ export function Alerts() { q: searchParams.q, timeRange: TIME_RANGE(), sensor: searchParams.sensor, - filters: searchParams.filters, + filters: searchParams.f, }; if (prev === undefined) { logger.log("Initial check of sortBy and sortOrder, not refreshing"); @@ -664,14 +662,14 @@ export function Alerts() { newFilters.push(entry); setSearchParams({ - filters: newFilters, + f: newFilters, }); } // Getter for searchParams.filters to convert to an array if there // is only one "filters" parameter. const getFilters = createMemo(() => { - let filters = searchParams.filters || []; + let filters = searchParams.f || []; if (!Array.isArray(filters)) { return [filters]; @@ -688,7 +686,7 @@ export function Alerts() { // Effect to update the query parameters when the filters signal updates. createEffect(() => { setSearchParams({ - filters: filters().length == 0 ? undefined : filters(), + f: filters().length == 0 ? undefined : filters(), }); }); diff --git a/webapp/src/Events.tsx b/webapp/src/Events.tsx index d95ac612..aaeab082 100644 --- a/webapp/src/Events.tsx +++ b/webapp/src/Events.tsx @@ -88,7 +88,7 @@ export function Events() { event_type?: string; from?: string; to?: string; - filters?: string[]; + f?: string[]; }>(); const [cursor, setCursor] = createSignal(0); const [filters, setFilters] = createSignal([]); @@ -137,7 +137,7 @@ export function Events() { // Getter for searchParams.filters to convert to an array if there // is only one "filters" parameter. const getFilters = createMemo(() => { - let filters = searchParams.filters || []; + let filters = searchParams.f || []; if (!Array.isArray(filters)) { return [filters]; @@ -173,11 +173,6 @@ export function Events() { setEventType(params.event_type); } - /* if (searchParams.q) { - * params.query_string = searchParams.q; - * } */ - - //const filterQuery: string = getFilters()?.join(" "); const filterQuery: string = filters()?.join(" "); if (filterQuery && filterQuery.length > 0) { params.query_string += " " + filterQuery; @@ -302,14 +297,14 @@ export function Events() { newFilters.push(entry); setSearchParams({ - filters: newFilters, + f: newFilters, }); } // Effect to update the query parameters when the filters signal updates. createEffect(() => { setSearchParams({ - filters: filters().length == 0 ? undefined : filters(), + f: filters().length == 0 ? undefined : filters(), }); });