mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-17 16:44:29 +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"],
|
is_submitted: searchSearchParams["is_submitted"],
|
||||||
has_clip: searchSearchParams["has_clip"],
|
has_clip: searchSearchParams["has_clip"],
|
||||||
event_id: searchSearchParams["event_id"],
|
event_id: searchSearchParams["event_id"],
|
||||||
|
sort: searchSearchParams["sort"],
|
||||||
limit:
|
limit:
|
||||||
Object.keys(searchSearchParams).length == 0 ? API_LIMIT : undefined,
|
Object.keys(searchSearchParams).length == 0 ? API_LIMIT : undefined,
|
||||||
timezone,
|
timezone,
|
||||||
@ -148,6 +149,7 @@ export default function Explore() {
|
|||||||
is_submitted: searchSearchParams["is_submitted"],
|
is_submitted: searchSearchParams["is_submitted"],
|
||||||
has_clip: searchSearchParams["has_clip"],
|
has_clip: searchSearchParams["has_clip"],
|
||||||
event_id: searchSearchParams["event_id"],
|
event_id: searchSearchParams["event_id"],
|
||||||
|
sort: searchSearchParams["sort"],
|
||||||
timezone,
|
timezone,
|
||||||
include_thumbnails: 0,
|
include_thumbnails: 0,
|
||||||
},
|
},
|
||||||
@ -165,12 +167,17 @@ export default function Explore() {
|
|||||||
|
|
||||||
const [url, params] = searchQuery;
|
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) {
|
if (pageIndex > 0 && previousPageData) {
|
||||||
const lastDate = previousPageData[previousPageData.length - 1].start_time;
|
const lastDate = previousPageData[previousPageData.length - 1].start_time;
|
||||||
return [
|
return [
|
||||||
url,
|
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",
|
"zone",
|
||||||
"sub",
|
"sub",
|
||||||
"source",
|
"source",
|
||||||
|
"sort",
|
||||||
] as const;
|
] as const;
|
||||||
export type SearchFilters = (typeof SEARCH_FILTERS)[number];
|
export type SearchFilters = (typeof SEARCH_FILTERS)[number];
|
||||||
export const DEFAULT_SEARCH_FILTERS: SearchFilters[] = [
|
export const DEFAULT_SEARCH_FILTERS: SearchFilters[] = [
|
||||||
@ -16,10 +17,18 @@ export const DEFAULT_SEARCH_FILTERS: SearchFilters[] = [
|
|||||||
"zone",
|
"zone",
|
||||||
"sub",
|
"sub",
|
||||||
"source",
|
"source",
|
||||||
|
"sort",
|
||||||
];
|
];
|
||||||
|
|
||||||
export type SearchSource = "similarity" | "thumbnail" | "description";
|
export type SearchSource = "similarity" | "thumbnail" | "description";
|
||||||
|
|
||||||
|
export type SearchSortType =
|
||||||
|
| "date_asc"
|
||||||
|
| "date_desc"
|
||||||
|
| "score_asc"
|
||||||
|
| "score_desc"
|
||||||
|
| "relevance";
|
||||||
|
|
||||||
export type SearchResult = {
|
export type SearchResult = {
|
||||||
id: string;
|
id: string;
|
||||||
camera: string;
|
camera: string;
|
||||||
@ -65,6 +74,7 @@ export type SearchFilter = {
|
|||||||
time_range?: string;
|
time_range?: string;
|
||||||
search_type?: SearchSource[];
|
search_type?: SearchSource[];
|
||||||
event_id?: string;
|
event_id?: string;
|
||||||
|
sort?: SearchSortType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DEFAULT_TIME_RANGE_AFTER = "00:00";
|
export const DEFAULT_TIME_RANGE_AFTER = "00:00";
|
||||||
@ -86,6 +96,7 @@ export type SearchQueryParams = {
|
|||||||
query?: string;
|
query?: string;
|
||||||
page?: number;
|
page?: number;
|
||||||
time_range?: string;
|
time_range?: string;
|
||||||
|
sort?: SearchSortType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type SearchQuery = [string, SearchQueryParams] | null;
|
export type SearchQuery = [string, SearchQueryParams] | null;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user