2024-10-15 16:24:47 +03:00
|
|
|
import TimeAgo from "../dynamic/TimeAgo";
|
|
|
|
|
import useSWR from "swr";
|
|
|
|
|
import { FrigateConfig } from "@/types/frigateConfig";
|
|
|
|
|
import { useFormattedTimestamp } from "@/hooks/use-date-utils";
|
|
|
|
|
import { SearchResult } from "@/types/search";
|
2024-10-22 17:01:01 +03:00
|
|
|
import ActivityIndicator from "../indicators/activity-indicator";
|
|
|
|
|
import SearchResultActions from "../menu/SearchResultActions";
|
2024-10-17 14:30:52 +03:00
|
|
|
import { cn } from "@/lib/utils";
|
2025-03-16 18:36:20 +03:00
|
|
|
import { useTranslation } from "react-i18next";
|
2024-10-15 16:24:47 +03:00
|
|
|
|
|
|
|
|
type SearchThumbnailProps = {
|
|
|
|
|
searchResult: SearchResult;
|
2024-10-17 14:30:52 +03:00
|
|
|
columns: number;
|
2024-10-15 16:24:47 +03:00
|
|
|
findSimilar: () => void;
|
|
|
|
|
refreshResults: () => void;
|
|
|
|
|
showObjectLifecycle: () => void;
|
2024-11-12 15:37:25 +03:00
|
|
|
showSnapshot: () => void;
|
2024-10-15 16:24:47 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default function SearchThumbnailFooter({
|
|
|
|
|
searchResult,
|
2024-10-17 14:30:52 +03:00
|
|
|
columns,
|
2024-10-15 16:24:47 +03:00
|
|
|
findSimilar,
|
|
|
|
|
refreshResults,
|
|
|
|
|
showObjectLifecycle,
|
2024-11-12 15:37:25 +03:00
|
|
|
showSnapshot,
|
2024-10-15 16:24:47 +03:00
|
|
|
}: SearchThumbnailProps) {
|
2025-03-16 18:36:20 +03:00
|
|
|
const { t } = useTranslation(["views/search"]);
|
2024-10-15 16:24:47 +03:00
|
|
|
const { data: config } = useSWR<FrigateConfig>("config");
|
|
|
|
|
|
|
|
|
|
// date
|
|
|
|
|
const formattedDate = useFormattedTimestamp(
|
|
|
|
|
searchResult.start_time,
|
2025-03-16 18:36:20 +03:00
|
|
|
config?.ui.time_format == "24hour"
|
|
|
|
|
? t("time.formattedTimestampExcludeSeconds.24hour", { ns: "common" })
|
2025-03-17 15:26:01 +03:00
|
|
|
: t("time.formattedTimestampExcludeSeconds.12hour", { ns: "common" }),
|
2024-10-15 16:24:47 +03:00
|
|
|
config?.ui.timezone,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
2024-10-22 17:01:01 +03:00
|
|
|
<div
|
|
|
|
|
className={cn(
|
2024-10-29 16:06:19 +03:00
|
|
|
"flex w-full flex-row items-center justify-between gap-2",
|
|
|
|
|
columns > 4 && "items-start sm:flex-col lg:flex-row lg:items-center",
|
2024-10-22 17:01:01 +03:00
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
<div className="flex flex-col items-start text-xs text-primary-variant">
|
|
|
|
|
{searchResult.end_time ? (
|
|
|
|
|
<TimeAgo time={searchResult.start_time * 1000} dense />
|
|
|
|
|
) : (
|
|
|
|
|
<div>
|
|
|
|
|
<ActivityIndicator size={14} />
|
|
|
|
|
</div>
|
2024-10-15 16:24:47 +03:00
|
|
|
)}
|
2024-10-22 17:01:01 +03:00
|
|
|
{formattedDate}
|
|
|
|
|
</div>
|
2024-10-29 16:06:19 +03:00
|
|
|
<div className="flex flex-row items-center justify-end gap-5 md:gap-4">
|
2024-10-22 17:01:01 +03:00
|
|
|
<SearchResultActions
|
|
|
|
|
searchResult={searchResult}
|
|
|
|
|
findSimilar={findSimilar}
|
|
|
|
|
refreshResults={refreshResults}
|
|
|
|
|
showObjectLifecycle={showObjectLifecycle}
|
2024-11-12 15:37:25 +03:00
|
|
|
showSnapshot={showSnapshot}
|
2024-10-22 17:01:01 +03:00
|
|
|
/>
|
2024-10-15 16:24:47 +03:00
|
|
|
</div>
|
2024-10-22 17:01:01 +03:00
|
|
|
</div>
|
2024-10-15 16:24:47 +03:00
|
|
|
);
|
|
|
|
|
}
|