mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-17 08:35:21 +03:00
add type and params
This commit is contained in:
parent
d63b76fbe7
commit
4477de6436
@ -116,6 +116,7 @@ export default function Explore() {
|
||||
is_submitted: searchSearchParams["is_submitted"],
|
||||
has_clip: searchSearchParams["has_clip"],
|
||||
event_id: searchSearchParams["event_id"],
|
||||
sort: searchSearchParams["sort"],
|
||||
limit:
|
||||
Object.keys(searchSearchParams).length == 0 ? API_LIMIT : undefined,
|
||||
timezone,
|
||||
@ -148,6 +149,7 @@ export default function Explore() {
|
||||
is_submitted: searchSearchParams["is_submitted"],
|
||||
has_clip: searchSearchParams["has_clip"],
|
||||
event_id: searchSearchParams["event_id"],
|
||||
sort: searchSearchParams["sort"],
|
||||
timezone,
|
||||
include_thumbnails: 0,
|
||||
},
|
||||
@ -165,12 +167,17 @@ export default function Explore() {
|
||||
|
||||
const [url, params] = searchQuery;
|
||||
|
||||
// If it's not the first page, use the last item's start_time as the 'before' parameter
|
||||
const isAscending = params.sort?.includes("date_asc");
|
||||
|
||||
if (pageIndex > 0 && previousPageData) {
|
||||
const lastDate = previousPageData[previousPageData.length - 1].start_time;
|
||||
return [
|
||||
url,
|
||||
{ ...params, before: lastDate.toString(), limit: API_LIMIT },
|
||||
{
|
||||
...params,
|
||||
[isAscending ? "after" : "before"]: lastDate.toString(),
|
||||
limit: API_LIMIT,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ const SEARCH_FILTERS = [
|
||||
"zone",
|
||||
"sub",
|
||||
"source",
|
||||
"sort",
|
||||
] as const;
|
||||
export type SearchFilters = (typeof SEARCH_FILTERS)[number];
|
||||
export const DEFAULT_SEARCH_FILTERS: SearchFilters[] = [
|
||||
@ -16,10 +17,18 @@ export const DEFAULT_SEARCH_FILTERS: SearchFilters[] = [
|
||||
"zone",
|
||||
"sub",
|
||||
"source",
|
||||
"sort",
|
||||
];
|
||||
|
||||
export type SearchSource = "similarity" | "thumbnail" | "description";
|
||||
|
||||
export type SearchSortType =
|
||||
| "date_asc"
|
||||
| "date_desc"
|
||||
| "score_asc"
|
||||
| "score_desc"
|
||||
| "relevance";
|
||||
|
||||
export type SearchResult = {
|
||||
id: string;
|
||||
camera: string;
|
||||
@ -65,6 +74,7 @@ export type SearchFilter = {
|
||||
time_range?: string;
|
||||
search_type?: SearchSource[];
|
||||
event_id?: string;
|
||||
sort?: SearchSortType;
|
||||
};
|
||||
|
||||
export const DEFAULT_TIME_RANGE_AFTER = "00:00";
|
||||
@ -86,6 +96,7 @@ export type SearchQueryParams = {
|
||||
query?: string;
|
||||
page?: number;
|
||||
time_range?: string;
|
||||
sort?: SearchSortType;
|
||||
};
|
||||
|
||||
export type SearchQuery = [string, SearchQueryParams] | null;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user