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"; import { useTranslation } from "react-i18next"; type ExploreSettingsProps = { className?: string; columns: number; defaultView: string; filter?: SearchFilter; setColumns: (columns: number) => void; setDefaultView: (view: string) => void; onUpdateFilter: (filter: SearchFilter) => void; }; export default function ExploreSettings({ className, columns, setColumns, defaultView, filter, setDefaultView, onUpdateFilter, }: ExploreSettingsProps) { const { t } = useTranslation(["components/filter"]); const { data: config } = useSWR("config"); const [open, setOpen] = useState(false); const [searchSources, setSearchSources] = useState([ "thumbnail", ]); const trigger = ( ); const content = (
{t("explore.settings.defaultView.title")}
{t("explore.settings.defaultView.desc")}
{!isMobileOnly && ( <>
{t("explore.settings.gridColumns.title")}
{t("explore.settings.gridColumns.desc")}
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) { const { t } = useTranslation(["components/filter"]); return ( <>
{t("explore.settings.searchSource.label")}
{t("explore.settings.searchSource.desc")}
{ 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); } } }} />
); }