mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-07 11:45:24 +03:00
Don't have horizontal scrolling
This commit is contained in:
parent
38fbe84159
commit
08e9120db5
@ -35,11 +35,12 @@ export default function HistoryCard({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="my-2 mr-2 bg-secondary w-[284px]">
|
<Card className="my-2 xs:mr-2 bg-secondary w-full xs:w-[48%] sm:w-[284px]">
|
||||||
<PreviewThumbnailPlayer
|
<PreviewThumbnailPlayer
|
||||||
camera={timeline.camera}
|
camera={timeline.camera}
|
||||||
relevantPreview={relevantPreview}
|
relevantPreview={relevantPreview}
|
||||||
startTs={Object.values(timeline.entries)[0].timestamp}
|
startTs={Object.values(timeline.entries)[0].timestamp}
|
||||||
|
eventId={Object.values(timeline.entries)[0].source_id}
|
||||||
/>
|
/>
|
||||||
<div className="p-2">
|
<div className="p-2">
|
||||||
<div className="text-sm flex">
|
<div className="text-sm flex">
|
||||||
|
|||||||
@ -10,6 +10,7 @@ type PreviewPlayerProps = {
|
|||||||
camera: string;
|
camera: string;
|
||||||
relevantPreview?: Preview;
|
relevantPreview?: Preview;
|
||||||
startTs: number;
|
startTs: number;
|
||||||
|
eventId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type Preview = {
|
type Preview = {
|
||||||
@ -24,6 +25,7 @@ export default function PreviewThumbnailPlayer({
|
|||||||
camera,
|
camera,
|
||||||
relevantPreview,
|
relevantPreview,
|
||||||
startTs,
|
startTs,
|
||||||
|
eventId,
|
||||||
}: PreviewPlayerProps) {
|
}: PreviewPlayerProps) {
|
||||||
const { data: config } = useSWR("config");
|
const { data: config } = useSWR("config");
|
||||||
const playerRef = useRef<Player | null>(null);
|
const playerRef = useRef<Player | null>(null);
|
||||||
@ -46,12 +48,29 @@ export default function PreviewThumbnailPlayer({
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (!relevantPreview) {
|
if (!relevantPreview) {
|
||||||
|
if (isCurrentHour(startTs)) {
|
||||||
|
return (
|
||||||
|
<AspectRatio
|
||||||
|
ratio={16 / 9}
|
||||||
|
className="bg-black flex justify-center items-center"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
className={`${getPreviewWidth(camera, config)}`}
|
||||||
|
src={`${apiHost}api/preview/${camera}/${startTs}/thumbnail.jpg`}
|
||||||
|
/>
|
||||||
|
</AspectRatio>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AspectRatio
|
<AspectRatio
|
||||||
ratio={16 / 9}
|
ratio={16 / 9}
|
||||||
className="bg-black flex justify-center items-center"
|
className="bg-black flex justify-center items-center"
|
||||||
>
|
>
|
||||||
<img src={`${apiHost}api/preview/${camera}/${startTs}/thumbnail.jpg`} />
|
<img
|
||||||
|
className="w-[160px]"
|
||||||
|
src={`${apiHost}api/events/${eventId}/thumbnail.jpg`}
|
||||||
|
/>
|
||||||
</AspectRatio>
|
</AspectRatio>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -63,7 +82,7 @@ export default function PreviewThumbnailPlayer({
|
|||||||
onMouseEnter={() => onHover(true)}
|
onMouseEnter={() => onHover(true)}
|
||||||
onMouseLeave={() => onHover(false)}
|
onMouseLeave={() => onHover(false)}
|
||||||
>
|
>
|
||||||
<div className={`${getThumbWidth(camera, config)}`}>
|
<div className={`${getPreviewWidth(camera, config)}`}>
|
||||||
<VideoPlayer
|
<VideoPlayer
|
||||||
options={{
|
options={{
|
||||||
preload: "auto",
|
preload: "auto",
|
||||||
@ -93,11 +112,17 @@ export default function PreviewThumbnailPlayer({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getThumbWidth(camera: string, config: FrigateConfig) {
|
function isCurrentHour(timestamp: number) {
|
||||||
|
const now = new Date();
|
||||||
|
now.setMinutes(0, 0, 0);
|
||||||
|
return timestamp > now.getTime() / 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPreviewWidth(camera: string, config: FrigateConfig) {
|
||||||
const detect = config.cameras[camera].detect;
|
const detect = config.cameras[camera].detect;
|
||||||
|
|
||||||
if (detect.width / detect.height < 1.4) {
|
if (detect.width / detect.height < 1.4) {
|
||||||
return "w-[200px]";
|
return "w-[208px]";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "w-full";
|
return "w-full";
|
||||||
|
|||||||
@ -197,32 +197,29 @@ function History() {
|
|||||||
strftime_fmt: "%I:00",
|
strftime_fmt: "%I:00",
|
||||||
})}
|
})}
|
||||||
</Heading>
|
</Heading>
|
||||||
<ScrollArea>
|
|
||||||
<div className="flex">
|
<div className="flex flex-wrap">
|
||||||
{Object.entries(timelineHour).map(
|
{Object.entries(timelineHour).map(
|
||||||
([key, timeline]) => {
|
([key, timeline]) => {
|
||||||
const startTs = Object.values(
|
const startTs = Object.values(timeline.entries)[0]
|
||||||
timeline.entries
|
.timestamp;
|
||||||
)[0].timestamp;
|
return (
|
||||||
return (
|
<HistoryCard
|
||||||
<HistoryCard
|
key={key}
|
||||||
key={key}
|
timeline={timeline}
|
||||||
timeline={timeline}
|
relevantPreview={Object.values(
|
||||||
relevantPreview={Object.values(
|
allPreviews || []
|
||||||
allPreviews || []
|
).find(
|
||||||
).find(
|
(preview) =>
|
||||||
(preview) =>
|
preview.camera == timeline.camera &&
|
||||||
preview.camera == timeline.camera &&
|
preview.start < startTs &&
|
||||||
preview.start < startTs &&
|
preview.end > startTs
|
||||||
preview.end > startTs
|
)}
|
||||||
)}
|
/>
|
||||||
/>
|
);
|
||||||
);
|
}
|
||||||
}
|
)}
|
||||||
)}
|
</div>
|
||||||
</div>
|
|
||||||
<ScrollBar className="m-2" orientation="horizontal" />
|
|
||||||
</ScrollArea>
|
|
||||||
{lastRow && <ActivityIndicator />}
|
{lastRow && <ActivityIndicator />}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -70,6 +70,10 @@ module.exports = {
|
|||||||
"accordion-down": "accordion-down 0.2s ease-out",
|
"accordion-down": "accordion-down 0.2s ease-out",
|
||||||
"accordion-up": "accordion-up 0.2s ease-out",
|
"accordion-up": "accordion-up 0.2s ease-out",
|
||||||
},
|
},
|
||||||
|
screens: {
|
||||||
|
"xs": "480px",
|
||||||
|
"2xl": "1400px",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins: [require("tailwindcss-animate")],
|
plugins: [require("tailwindcss-animate")],
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user