import { Button } from "../ui/button"; import { useState } from "react"; import { isDesktop, isMobileOnly } from "react-device-detect"; import { cn } from "@/lib/utils"; import PlatformAwareDialog from "../overlay/dialog/PlatformAwareDialog"; import { FaCog } from "react-icons/fa"; import { Slider } from "../ui/slider"; import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, } from "@/components/ui/select"; import { DropdownMenuSeparator } from "../ui/dropdown-menu"; import FilterSwitch from "../filter/FilterSwitch"; import { SearchFilter, SearchSource } from "@/types/search"; import useSWR from "swr"; import { FrigateConfig } from "@/types/frigateConfig"; type SearchSettingsProps = { className?: string; columns: number; defaultView: string; filter?: SearchFilter; setColumns: (columns: number) => void; setDefaultView: (view: string) => void; onUpdateFilter: (filter: SearchFilter) => void; }; export default function SearchSettings({ className, columns, setColumns, defaultView, filter, setDefaultView, onUpdateFilter, }: SearchSettingsProps) { const { data: config } = useSWR("config"); const [open, setOpen] = useState(false); const [searchSources, setSearchSources] = useState([ "thumbnail", ]); const trigger = ( ); const content = (
Default View
When no filters are selected, display a summary of the most recent tracked objects per label, or display an unfiltered grid.
{!isMobileOnly && ( <>
Grid Columns
Select the number of columns in the grid view.
setColumns(value)} max={8} min={2} step={1} className="flex-grow" /> {columns}
)} {config?.semantic_search?.enabled && ( { setSearchSources(sources as SearchSource[]); onUpdateFilter({ ...filter, search_type: sources }); }} /> )}
); return ( { setOpen(open); }} /> ); } type SearchTypeContentProps = { searchSources: SearchSource[] | undefined; setSearchSources: (sources: SearchSource[] | undefined) => void; }; export function SearchTypeContent({ searchSources, setSearchSources, }: SearchTypeContentProps) { return ( <>
Search Source
Choose whether to search the thumbnails or descriptions of your tracked objects.
{ const updatedSources = searchSources ? [...searchSources] : []; if (isChecked) { updatedSources.push("thumbnail"); setSearchSources(updatedSources); } else { if (updatedSources.length > 1) { const index = updatedSources.indexOf("thumbnail"); if (index !== -1) updatedSources.splice(index, 1); setSearchSources(updatedSources); } } }} /> { const updatedSources = searchSources ? [...searchSources] : []; if (isChecked) { updatedSources.push("description"); setSearchSources(updatedSources); } else { if (updatedSources.length > 1) { const index = updatedSources.indexOf("description"); if (index !== -1) updatedSources.splice(index, 1); setSearchSources(updatedSources); } } }} />
); }