mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-09 04:35:25 +03:00
Don't show gif until event is over and fix aspect
This commit is contained in:
parent
f54cb21bd0
commit
ae7df14da4
@ -2,18 +2,50 @@ import { baseUrl } from "@/api/baseUrl";
|
||||
import { Event as FrigateEvent } from "@/types/event";
|
||||
import TimeAgo from "../dynamic/TimeAgo";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip";
|
||||
import { useMemo } from "react";
|
||||
import { useApiHost } from "@/api";
|
||||
import useSWR from "swr";
|
||||
import { FrigateConfig } from "@/types/frigateConfig";
|
||||
|
||||
type AnimatedEventThumbnailProps = {
|
||||
event: FrigateEvent;
|
||||
};
|
||||
export function AnimatedEventThumbnail({ event }: AnimatedEventThumbnailProps) {
|
||||
const apiHost = useApiHost();
|
||||
const { data: config } = useSWR<FrigateConfig>("config");
|
||||
|
||||
const imageUrl = useMemo(() => {
|
||||
if (!event.end_time) {
|
||||
return `${apiHost}api/preview/${event.camera}/${event.start_time}/thumbnail.jpg`;
|
||||
}
|
||||
|
||||
return `${baseUrl}api/events/${event.id}/preview.gif`;
|
||||
}, [event]);
|
||||
|
||||
const aspect = useMemo(() => {
|
||||
if (!config) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const detect = config.cameras[event.camera].detect;
|
||||
const aspect = detect.width / detect.height;
|
||||
|
||||
if (aspect > 2) {
|
||||
return "aspect-wide";
|
||||
} else if (aspect < 1) {
|
||||
return "aspect-tall";
|
||||
} else {
|
||||
return "aspect-video";
|
||||
}
|
||||
}, [config, event]);
|
||||
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div
|
||||
className="relative rounded bg-cover aspect-video h-24 bg-no-repeat bg-center mr-4"
|
||||
className={`relative rounded bg-cover h-24 bg-no-repeat bg-center mr-4 ${aspect}`}
|
||||
style={{
|
||||
backgroundImage: `url(${baseUrl}api/events/${event.id}/preview.gif)`,
|
||||
backgroundImage: `url(${imageUrl})`,
|
||||
}}
|
||||
>
|
||||
<div className="absolute bottom-0 w-full h-6 bg-gradient-to-t from-slate-900/50 to-transparent rounded">
|
||||
|
||||
@ -62,7 +62,7 @@ function Live() {
|
||||
if (aspectRatio > 2) {
|
||||
grow = "md:col-span-2 aspect-wide";
|
||||
} else if (aspectRatio < 1) {
|
||||
grow = `md:row-span-2 aspect-[8/9] md:h-full`;
|
||||
grow = `md:row-span-2 aspect-tall md:h-full`;
|
||||
} else {
|
||||
grow = "aspect-video";
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ module.exports = {
|
||||
},
|
||||
aspectRatio: {
|
||||
wide: "32 / 9",
|
||||
tall: "9 / 16",
|
||||
tall: "8 / 9",
|
||||
},
|
||||
colors: {
|
||||
border: "hsl(var(--border))",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user