Skip to content

Commit

Permalink
webapp: shorter "filters" to "f", to be consistent with "q"
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonish committed Jan 1, 2025
1 parent ae23cd9 commit 0647306
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
14 changes: 6 additions & 8 deletions webapp/src/Alerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<string[]>(
searchParams.filters || []
);
const [filters, setFilters] = createSignal<string[]>(searchParams.f || []);

let toggleSelectAllRef: HTMLInputElement | null = null;
let bindings: any = null;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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];
Expand All @@ -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(),
});
});

Expand Down
13 changes: 4 additions & 9 deletions webapp/src/Events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string[]>([]);
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
});
});

Expand Down

0 comments on commit 0647306

Please sign in to comment.