mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-17 16:44:29 +03:00
add zooming to event review timeline
This commit is contained in:
parent
772da2533d
commit
a6d695adac
@ -53,6 +53,7 @@ import { FilterList, LAST_24_HOURS_KEY } from "@/types/filter";
|
|||||||
import { GiSoundWaves } from "react-icons/gi";
|
import { GiSoundWaves } from "react-icons/gi";
|
||||||
import useKeyboardListener from "@/hooks/use-keyboard-listener";
|
import useKeyboardListener from "@/hooks/use-keyboard-listener";
|
||||||
import ReviewDetailDialog from "@/components/overlay/detail/ReviewDetailDialog";
|
import ReviewDetailDialog from "@/components/overlay/detail/ReviewDetailDialog";
|
||||||
|
import { useTimelineZoom } from "@/hooks/use-timeline-zoom";
|
||||||
|
|
||||||
type EventViewProps = {
|
type EventViewProps = {
|
||||||
reviewItems?: SegmentedReviewData;
|
reviewItems?: SegmentedReviewData;
|
||||||
@ -461,8 +462,6 @@ function DetectionReview({
|
|||||||
}: DetectionReviewProps) {
|
}: DetectionReviewProps) {
|
||||||
const reviewTimelineRef = useRef<HTMLDivElement>(null);
|
const reviewTimelineRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const segmentDuration = 60;
|
|
||||||
|
|
||||||
// detail
|
// detail
|
||||||
|
|
||||||
const [reviewDetail, setReviewDetail] = useState<ReviewSegment>();
|
const [reviewDetail, setReviewDetail] = useState<ReviewSegment>();
|
||||||
@ -487,6 +486,33 @@ function DetectionReview({
|
|||||||
|
|
||||||
// timeline interaction
|
// timeline interaction
|
||||||
|
|
||||||
|
const [zoomSettings, setZoomSettings] = useState({
|
||||||
|
segmentDuration: 60,
|
||||||
|
timestampSpread: 15,
|
||||||
|
});
|
||||||
|
|
||||||
|
const possibleZoomLevels = useMemo(
|
||||||
|
() => [
|
||||||
|
{ segmentDuration: 60, timestampSpread: 15 },
|
||||||
|
{ segmentDuration: 30, timestampSpread: 5 },
|
||||||
|
{ segmentDuration: 10, timestampSpread: 1 },
|
||||||
|
],
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleZoomChange = useCallback(
|
||||||
|
(newZoomLevel: number) => {
|
||||||
|
setZoomSettings(possibleZoomLevels[newZoomLevel]);
|
||||||
|
},
|
||||||
|
[possibleZoomLevels],
|
||||||
|
);
|
||||||
|
|
||||||
|
useTimelineZoom({
|
||||||
|
zoomSettings,
|
||||||
|
zoomLevels: possibleZoomLevels,
|
||||||
|
onZoomChange: handleZoomChange,
|
||||||
|
});
|
||||||
|
|
||||||
const timelineDuration = useMemo(
|
const timelineDuration = useMemo(
|
||||||
() => timeRange.before - timeRange.after,
|
() => timeRange.before - timeRange.after,
|
||||||
[timeRange],
|
[timeRange],
|
||||||
@ -494,7 +520,7 @@ function DetectionReview({
|
|||||||
|
|
||||||
const { alignStartDateToTimeline, getVisibleTimelineDuration } =
|
const { alignStartDateToTimeline, getVisibleTimelineDuration } =
|
||||||
useTimelineUtils({
|
useTimelineUtils({
|
||||||
segmentDuration,
|
segmentDuration: zoomSettings.segmentDuration,
|
||||||
timelineDuration,
|
timelineDuration,
|
||||||
timelineRef: reviewTimelineRef,
|
timelineRef: reviewTimelineRef,
|
||||||
});
|
});
|
||||||
@ -692,7 +718,7 @@ function DetectionReview({
|
|||||||
data-start={value.start_time}
|
data-start={value.start_time}
|
||||||
data-segment-start={
|
data-segment-start={
|
||||||
alignStartDateToTimeline(value.start_time) -
|
alignStartDateToTimeline(value.start_time) -
|
||||||
segmentDuration
|
zoomSettings.segmentDuration
|
||||||
}
|
}
|
||||||
className="review-item relative rounded-lg"
|
className="review-item relative rounded-lg"
|
||||||
>
|
>
|
||||||
@ -749,13 +775,13 @@ function DetectionReview({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex w-[65px] flex-row md:w-[110px]">
|
<div className="flex w-[65px] flex-row md:w-[110px]">
|
||||||
<div className="no-scrollbar w-[55px] overflow-y-auto md:w-[100px]">
|
<div className="no-scrollbar w-[55px] md:w-[100px]">
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<Skeleton className="size-full" />
|
<Skeleton className="size-full" />
|
||||||
) : (
|
) : (
|
||||||
<EventReviewTimeline
|
<EventReviewTimeline
|
||||||
segmentDuration={segmentDuration}
|
segmentDuration={zoomSettings.segmentDuration}
|
||||||
timestampSpread={15}
|
timestampSpread={zoomSettings.timestampSpread}
|
||||||
timelineStart={timeRange.before}
|
timelineStart={timeRange.before}
|
||||||
timelineEnd={timeRange.after}
|
timelineEnd={timeRange.after}
|
||||||
showMinimap={showMinimap && !previewTime}
|
showMinimap={showMinimap && !previewTime}
|
||||||
@ -780,7 +806,7 @@ function DetectionReview({
|
|||||||
reviewTimelineRef={reviewTimelineRef}
|
reviewTimelineRef={reviewTimelineRef}
|
||||||
timelineStart={timeRange.before}
|
timelineStart={timeRange.before}
|
||||||
timelineEnd={timeRange.after}
|
timelineEnd={timeRange.after}
|
||||||
segmentDuration={segmentDuration}
|
segmentDuration={zoomSettings.segmentDuration}
|
||||||
events={reviewItems?.all ?? []}
|
events={reviewItems?.all ?? []}
|
||||||
severityType={severity}
|
severityType={severity}
|
||||||
/>
|
/>
|
||||||
@ -1095,7 +1121,6 @@ function MotionReview({
|
|||||||
setHandlebarTime={setCurrentTime}
|
setHandlebarTime={setCurrentTime}
|
||||||
events={reviewItems?.all ?? []}
|
events={reviewItems?.all ?? []}
|
||||||
motion_events={motionData ?? []}
|
motion_events={motionData ?? []}
|
||||||
severityType="significant_motion"
|
|
||||||
contentRef={contentRef}
|
contentRef={contentRef}
|
||||||
onHandlebarDraggingChange={(scrubbing) => {
|
onHandlebarDraggingChange={(scrubbing) => {
|
||||||
if (playing && scrubbing) {
|
if (playing && scrubbing) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user