mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-20 20:43:01 +03:00
Add summary timeline to Motion Review and History (#25034)
CI / AMD64 Build (push) Waiting to run
CI / AMD64 Smoke Test (push) Blocked by required conditions
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
CI / AMD64 Build (push) Waiting to run
CI / AMD64 Smoke Test (push) Blocked by required conditions
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
* add motion summary timeline to motion review and history The summary strip draws motion as a canvas layer, with each pixel row's opacity set by the mean motion value over its time, so the full day is visible next to the 30s timeline. Dragging now converts strip pixels to timeline pixels directly instead of going through the drag box height, which no longer matches the box once it has borders. The strip is wider on mobile, and the drag box style is shared with the alerts and detections strips. * hide summary timeline when motion only switch is on * drag summary timeline from anywhere and keep a minimum box size The drag box shrank to a few pixels when the timeline was zoomed in, and tapping the summary timeline on mobile read touches[0] on touchend, where the list is always empty. The box now has a minimum height centered on the visible range, and input goes through pointer events: a tap outside the box jumps there, and a press outside the box that moves snaps the box under the pointer and drags it.
This commit is contained in:
@@ -28,7 +28,7 @@ export function SummarySegment({
|
|||||||
<div className="absolute inset-0 flex h-full cursor-pointer justify-end">
|
<div className="absolute inset-0 flex h-full cursor-pointer justify-end">
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"w-[10px]",
|
"w-full",
|
||||||
severityColors[severity],
|
severityColors[severity],
|
||||||
height < 0.5 && "min-h-[0.5px]",
|
height < 0.5 && "min-h-[0.5px]",
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -8,18 +8,26 @@ import React, {
|
|||||||
import { SummarySegment } from "./SummarySegment";
|
import { SummarySegment } from "./SummarySegment";
|
||||||
import {
|
import {
|
||||||
ConsolidatedSegmentData,
|
ConsolidatedSegmentData,
|
||||||
|
MotionData,
|
||||||
ReviewSegment,
|
ReviewSegment,
|
||||||
ReviewSeverity,
|
ReviewSeverity,
|
||||||
} from "@/types/review";
|
} from "@/types/review";
|
||||||
import { useTimelineUtils } from "@/hooks/use-timeline-utils";
|
import { useTimelineUtils } from "@/hooks/use-timeline-utils";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import { isMobile } from "react-device-detect";
|
||||||
|
|
||||||
|
const MIN_BOX_HEIGHT = isMobile ? 20 : 12;
|
||||||
|
const DRAG_THRESHOLD = 4;
|
||||||
|
|
||||||
export type SummaryTimelineProps = {
|
export type SummaryTimelineProps = {
|
||||||
reviewTimelineRef: React.RefObject<HTMLDivElement | null>;
|
reviewTimelineRef: React.RefObject<HTMLDivElement | null>;
|
||||||
timelineStart: number;
|
timelineStart: number;
|
||||||
timelineEnd: number;
|
timelineEnd: number;
|
||||||
segmentDuration: number;
|
segmentDuration: number;
|
||||||
events: ReviewSegment[];
|
events?: ReviewSegment[];
|
||||||
severityType: ReviewSeverity;
|
severityType?: ReviewSeverity;
|
||||||
|
motionData?: MotionData[];
|
||||||
|
motionScale?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function SummaryTimeline({
|
export function SummaryTimeline({
|
||||||
@@ -27,16 +35,22 @@ export function SummaryTimeline({
|
|||||||
timelineStart,
|
timelineStart,
|
||||||
timelineEnd,
|
timelineEnd,
|
||||||
segmentDuration,
|
segmentDuration,
|
||||||
events,
|
events = [],
|
||||||
severityType,
|
severityType,
|
||||||
|
motionData,
|
||||||
|
motionScale,
|
||||||
}: SummaryTimelineProps) {
|
}: SummaryTimelineProps) {
|
||||||
const summaryTimelineRef = useRef<HTMLDivElement>(null);
|
const summaryTimelineRef = useRef<HTMLDivElement>(null);
|
||||||
const visibleSectionRef = useRef<HTMLDivElement>(null);
|
const visibleSectionRef = useRef<HTMLDivElement>(null);
|
||||||
|
const motionCanvasRef = useRef<HTMLCanvasElement>(null);
|
||||||
|
|
||||||
const [isDragging, setIsDragging] = useState(false);
|
const [isDragging, setIsDragging] = useState(false);
|
||||||
const [scrollStartPosition, setScrollStartPosition] = useState<number>(0);
|
const dragRef = useRef<{
|
||||||
const [initialReviewTimelineScrollTop, setInitialReviewTimelineScrollTop] =
|
startY: number;
|
||||||
useState<number>(0);
|
startScrollTop: number;
|
||||||
|
insideBox: boolean;
|
||||||
|
moved: boolean;
|
||||||
|
} | null>(null);
|
||||||
|
|
||||||
const observer = useRef<ResizeObserver | null>(null);
|
const observer = useRef<ResizeObserver | null>(null);
|
||||||
|
|
||||||
@@ -129,6 +143,79 @@ export function SummaryTimeline({
|
|||||||
segmentDuration,
|
segmentDuration,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Each motion sample covers motionScale seconds with a 0-100 value, and
|
||||||
|
// bins without motion are absent. Opacity is the bucket's mean value.
|
||||||
|
|
||||||
|
const drawMotion = useCallback(() => {
|
||||||
|
const canvas = motionCanvasRef.current;
|
||||||
|
const ctx = canvas?.getContext("2d");
|
||||||
|
|
||||||
|
if (!canvas || !ctx || !motionData || !motionScale) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { clientWidth: width, clientHeight: height } = canvas;
|
||||||
|
const dpr = window.devicePixelRatio || 1;
|
||||||
|
canvas.width = width * dpr;
|
||||||
|
canvas.height = height * dpr;
|
||||||
|
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||||||
|
ctx.clearRect(0, 0, width, height);
|
||||||
|
|
||||||
|
const duration = timelineStart - timelineEnd;
|
||||||
|
|
||||||
|
if (duration <= 0 || height <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const rows = Math.max(
|
||||||
|
1,
|
||||||
|
Math.min(Math.floor(height), Math.ceil(duration / motionScale)),
|
||||||
|
);
|
||||||
|
const rowHeight = height / rows;
|
||||||
|
const rowSeconds = duration / rows;
|
||||||
|
const sums = new Array<number>(rows).fill(0);
|
||||||
|
|
||||||
|
motionData.forEach((item) => {
|
||||||
|
const row = Math.floor(
|
||||||
|
((timelineStart - item.start_time) / duration) * rows,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (row >= 0 && row < rows) {
|
||||||
|
sums[row] += item.motion ?? 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const color = getComputedStyle(document.documentElement)
|
||||||
|
.getPropertyValue("--severity_significant_motion")
|
||||||
|
.trim();
|
||||||
|
|
||||||
|
const samplesPerRow = rowSeconds / motionScale;
|
||||||
|
|
||||||
|
sums.forEach((sum, row) => {
|
||||||
|
if (sum == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const intensity = Math.min(1, sum / (100 * samplesPerRow));
|
||||||
|
ctx.fillStyle = `hsl(${color} / ${intensity})`;
|
||||||
|
ctx.fillRect(0, row * rowHeight, width, Math.ceil(rowHeight));
|
||||||
|
});
|
||||||
|
}, [motionData, motionScale, timelineStart, timelineEnd]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const canvas = motionCanvasRef.current;
|
||||||
|
|
||||||
|
if (!canvas) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
drawMotion();
|
||||||
|
const resizeObserver = new ResizeObserver(drawMotion);
|
||||||
|
resizeObserver.observe(canvas);
|
||||||
|
|
||||||
|
return () => resizeObserver.disconnect();
|
||||||
|
}, [drawMotion]);
|
||||||
|
|
||||||
const setVisibleSectionStyles = useCallback(() => {
|
const setVisibleSectionStyles = useCallback(() => {
|
||||||
if (
|
if (
|
||||||
reviewTimelineRef.current &&
|
reviewTimelineRef.current &&
|
||||||
@@ -144,13 +231,22 @@ export function SummaryTimeline({
|
|||||||
} = content;
|
} = content;
|
||||||
const { clientHeight: summaryTimelineVisibleHeight } = summary;
|
const { clientHeight: summaryTimelineVisibleHeight } = summary;
|
||||||
|
|
||||||
visibleSectionRef.current.style.top = `${
|
// The box keeps a minimum height so it stays visible when zoomed in,
|
||||||
summaryTimelineVisibleHeight * (scrolled / reviewTimelineFullHeight)
|
// centered on the true visible range.
|
||||||
}px`;
|
|
||||||
visibleSectionRef.current.style.height = `${
|
const trueHeight =
|
||||||
reviewTimelineVisibleHeight *
|
summaryTimelineVisibleHeight *
|
||||||
(reviewTimelineVisibleHeight / reviewTimelineFullHeight)
|
(reviewTimelineVisibleHeight / reviewTimelineFullHeight);
|
||||||
}px`;
|
const trueTop =
|
||||||
|
summaryTimelineVisibleHeight * (scrolled / reviewTimelineFullHeight);
|
||||||
|
const height = Math.max(trueHeight, MIN_BOX_HEIGHT);
|
||||||
|
const top = Math.min(
|
||||||
|
Math.max(trueTop - (height - trueHeight) / 2, 0),
|
||||||
|
summaryTimelineVisibleHeight - height,
|
||||||
|
);
|
||||||
|
|
||||||
|
visibleSectionRef.current.style.top = `${top}px`;
|
||||||
|
visibleSectionRef.current.style.height = `${height}px`;
|
||||||
}
|
}
|
||||||
}, [reviewTimelineRef, summaryTimelineRef, visibleSectionRef]);
|
}, [reviewTimelineRef, summaryTimelineRef, visibleSectionRef]);
|
||||||
|
|
||||||
@@ -184,178 +280,137 @@ export function SummaryTimeline({
|
|||||||
segmentDuration,
|
segmentDuration,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const timelineClick = useCallback(
|
const scrollTopForPosition = useCallback(
|
||||||
(
|
(clientY: number) => {
|
||||||
e: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,
|
const timeline = reviewTimelineRef.current;
|
||||||
) => {
|
const summary = summaryTimelineRef.current;
|
||||||
// prevent default only for mouse events
|
|
||||||
// to avoid chrome/android issues
|
if (!timeline || !summary) {
|
||||||
if (e.nativeEvent instanceof MouseEvent) {
|
return 0;
|
||||||
e.preventDefault();
|
|
||||||
}
|
}
|
||||||
e.stopPropagation();
|
|
||||||
|
|
||||||
let clientY;
|
const rect = summary.getBoundingClientRect();
|
||||||
if ("TouchEvent" in window && e.nativeEvent instanceof TouchEvent) {
|
const ratio = (clientY - rect.top) / rect.height;
|
||||||
clientY = e.nativeEvent.touches[0].clientY;
|
return ratio * timeline.scrollHeight - timeline.clientHeight / 2;
|
||||||
} else if (e.nativeEvent instanceof MouseEvent) {
|
},
|
||||||
clientY = e.nativeEvent.clientY;
|
[reviewTimelineRef],
|
||||||
}
|
);
|
||||||
if (
|
|
||||||
clientY &&
|
|
||||||
reviewTimelineRef.current &&
|
|
||||||
summaryTimelineRef.current &&
|
|
||||||
visibleSectionRef.current
|
|
||||||
) {
|
|
||||||
const { clientHeight: summaryTimelineVisibleHeight } =
|
|
||||||
summaryTimelineRef.current;
|
|
||||||
|
|
||||||
const rect = summaryTimelineRef.current.getBoundingClientRect();
|
const scrollTimelineTo = useCallback(
|
||||||
const summaryTimelineTop = rect.top;
|
(top: number, behavior: ScrollBehavior = "auto") => {
|
||||||
|
const timeline = reviewTimelineRef.current;
|
||||||
|
|
||||||
const { scrollHeight: reviewTimelineHeight } =
|
if (timeline) {
|
||||||
reviewTimelineRef.current;
|
const maxScrollTop = timeline.scrollHeight - timeline.clientHeight;
|
||||||
|
timeline.scrollTo({
|
||||||
const { clientHeight: visibleSectionHeight } =
|
top: Math.min(Math.max(top, 0), maxScrollTop),
|
||||||
visibleSectionRef.current;
|
behavior,
|
||||||
|
|
||||||
const visibleSectionOffset = -(visibleSectionHeight / 2);
|
|
||||||
|
|
||||||
const clickPercentage =
|
|
||||||
(clientY - summaryTimelineTop + visibleSectionOffset) /
|
|
||||||
summaryTimelineVisibleHeight;
|
|
||||||
|
|
||||||
reviewTimelineRef.current.scrollTo({
|
|
||||||
top: Math.floor(reviewTimelineHeight * clickPercentage),
|
|
||||||
behavior: "smooth",
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[reviewTimelineRef, summaryTimelineRef, visibleSectionRef],
|
[reviewTimelineRef],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleMouseDown = useCallback(
|
// A press outside the box jumps there on release, or snaps the box under
|
||||||
(
|
// the pointer once it moves and then drags it.
|
||||||
e: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,
|
|
||||||
) => {
|
const handlePointerDown = useCallback(
|
||||||
// prevent default only for mouse events
|
(e: React.PointerEvent<HTMLDivElement>) => {
|
||||||
// to avoid chrome/android issues
|
if (
|
||||||
if (e.nativeEvent instanceof MouseEvent) {
|
e.button != 0 ||
|
||||||
e.preventDefault();
|
!reviewTimelineRef.current ||
|
||||||
|
!visibleSectionRef.current
|
||||||
|
) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
e.currentTarget.setPointerCapture(e.pointerId);
|
||||||
|
|
||||||
|
const box = visibleSectionRef.current.getBoundingClientRect();
|
||||||
|
dragRef.current = {
|
||||||
|
startY: e.clientY,
|
||||||
|
startScrollTop: reviewTimelineRef.current.scrollTop,
|
||||||
|
insideBox: e.clientY >= box.top && e.clientY <= box.bottom,
|
||||||
|
moved: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
[reviewTimelineRef],
|
||||||
|
);
|
||||||
|
|
||||||
|
const handlePointerMove = useCallback(
|
||||||
|
(e: React.PointerEvent<HTMLDivElement>) => {
|
||||||
|
const drag = dragRef.current;
|
||||||
|
const timeline = reviewTimelineRef.current;
|
||||||
|
const summary = summaryTimelineRef.current;
|
||||||
|
|
||||||
|
if (!drag || !timeline || !summary) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const deltaY = e.clientY - drag.startY;
|
||||||
|
|
||||||
|
if (!drag.moved) {
|
||||||
|
if (Math.abs(deltaY) < DRAG_THRESHOLD) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
drag.moved = true;
|
||||||
setIsDragging(true);
|
setIsDragging(true);
|
||||||
|
|
||||||
let clientY;
|
if (!drag.insideBox) {
|
||||||
if ("TouchEvent" in window && e.nativeEvent instanceof TouchEvent) {
|
drag.startScrollTop = scrollTopForPosition(drag.startY);
|
||||||
clientY = e.nativeEvent.touches[0].clientY;
|
|
||||||
} else if (e.nativeEvent instanceof MouseEvent) {
|
|
||||||
clientY = e.nativeEvent.clientY;
|
|
||||||
}
|
}
|
||||||
if (clientY && summaryTimelineRef.current && reviewTimelineRef.current) {
|
|
||||||
setScrollStartPosition(clientY);
|
|
||||||
setInitialReviewTimelineScrollTop(reviewTimelineRef.current.scrollTop);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scrollTimelineTo(
|
||||||
|
drag.startScrollTop +
|
||||||
|
deltaY * (timeline.scrollHeight / summary.clientHeight),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
[setIsDragging, summaryTimelineRef, reviewTimelineRef],
|
[reviewTimelineRef, scrollTopForPosition, scrollTimelineTo],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleMouseUp = useCallback(
|
const handlePointerUp = useCallback(
|
||||||
(e: MouseEvent | TouchEvent) => {
|
(e: React.PointerEvent<HTMLDivElement>) => {
|
||||||
e.preventDefault();
|
const drag = dragRef.current;
|
||||||
e.stopPropagation();
|
dragRef.current = null;
|
||||||
if (isDragging) {
|
|
||||||
setIsDragging(false);
|
setIsDragging(false);
|
||||||
|
|
||||||
|
if (drag && !drag.moved && !drag.insideBox) {
|
||||||
|
scrollTimelineTo(scrollTopForPosition(e.clientY), "smooth");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[isDragging, setIsDragging],
|
[scrollTopForPosition, scrollTimelineTo],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleMouseMove = useCallback(
|
const handlePointerCancel = useCallback(() => {
|
||||||
(e: MouseEvent | TouchEvent) => {
|
dragRef.current = null;
|
||||||
if (
|
setIsDragging(false);
|
||||||
summaryTimelineRef.current &&
|
}, []);
|
||||||
reviewTimelineRef.current &&
|
|
||||||
visibleSectionRef.current
|
|
||||||
) {
|
|
||||||
// prevent default only for mouse events
|
|
||||||
// to avoid chrome/android issues
|
|
||||||
if (e instanceof MouseEvent) {
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
e.stopPropagation();
|
|
||||||
let clientY;
|
|
||||||
if ("TouchEvent" in window && e instanceof TouchEvent) {
|
|
||||||
clientY = e.touches[0].clientY;
|
|
||||||
} else if (e instanceof MouseEvent) {
|
|
||||||
clientY = e.clientY;
|
|
||||||
}
|
|
||||||
if (isDragging && clientY) {
|
|
||||||
const { clientHeight: summaryTimelineVisibleHeight } =
|
|
||||||
summaryTimelineRef.current;
|
|
||||||
|
|
||||||
const {
|
|
||||||
scrollHeight: reviewTimelineHeight,
|
|
||||||
clientHeight: reviewTimelineVisibleHeight,
|
|
||||||
} = reviewTimelineRef.current;
|
|
||||||
|
|
||||||
const { clientHeight: visibleSectionHeight } =
|
|
||||||
visibleSectionRef.current;
|
|
||||||
|
|
||||||
const deltaY =
|
|
||||||
(clientY - scrollStartPosition) *
|
|
||||||
(summaryTimelineVisibleHeight / visibleSectionHeight);
|
|
||||||
|
|
||||||
const newScrollTop = Math.min(
|
|
||||||
initialReviewTimelineScrollTop + deltaY,
|
|
||||||
reviewTimelineHeight - reviewTimelineVisibleHeight,
|
|
||||||
);
|
|
||||||
|
|
||||||
reviewTimelineRef.current.scrollTop = newScrollTop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[
|
|
||||||
initialReviewTimelineScrollTop,
|
|
||||||
isDragging,
|
|
||||||
reviewTimelineRef,
|
|
||||||
scrollStartPosition,
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
const documentRef = useRef<Document | null>(document);
|
|
||||||
useEffect(() => {
|
|
||||||
const documentInstance = documentRef.current;
|
|
||||||
|
|
||||||
if (isDragging) {
|
|
||||||
documentInstance?.addEventListener("mousemove", handleMouseMove);
|
|
||||||
documentInstance?.addEventListener("touchmove", handleMouseMove);
|
|
||||||
documentInstance?.addEventListener("mouseup", handleMouseUp);
|
|
||||||
documentInstance?.addEventListener("touchend", handleMouseUp);
|
|
||||||
} else {
|
|
||||||
documentInstance?.removeEventListener("mousemove", handleMouseMove);
|
|
||||||
documentInstance?.removeEventListener("touchmove", handleMouseMove);
|
|
||||||
documentInstance?.removeEventListener("mouseup", handleMouseUp);
|
|
||||||
documentInstance?.removeEventListener("touchend", handleMouseUp);
|
|
||||||
}
|
|
||||||
return () => {
|
|
||||||
documentInstance?.removeEventListener("mousemove", handleMouseMove);
|
|
||||||
documentInstance?.removeEventListener("touchmove", handleMouseMove);
|
|
||||||
documentInstance?.removeEventListener("mouseup", handleMouseUp);
|
|
||||||
documentInstance?.removeEventListener("touchend", handleMouseUp);
|
|
||||||
};
|
|
||||||
}, [handleMouseMove, handleMouseUp, isDragging]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`no-scrollbar relative h-full select-none overflow-hidden border-l-[1px] border-neutral-700 bg-secondary`}
|
className={cn(
|
||||||
|
"no-scrollbar relative h-full touch-none select-none overflow-hidden border-l-[1px] border-neutral-700 bg-secondary",
|
||||||
|
isDragging ? "cursor-grabbing" : "cursor-pointer",
|
||||||
|
)}
|
||||||
role="scrollbar"
|
role="scrollbar"
|
||||||
|
onPointerDown={handlePointerDown}
|
||||||
|
onPointerMove={handlePointerMove}
|
||||||
|
onPointerUp={handlePointerUp}
|
||||||
|
onPointerCancel={handlePointerCancel}
|
||||||
>
|
>
|
||||||
|
{motionData && (
|
||||||
|
<canvas
|
||||||
|
ref={motionCanvasRef}
|
||||||
|
className="pointer-events-none absolute inset-0 size-full"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<div
|
<div
|
||||||
ref={summaryTimelineRef}
|
ref={summaryTimelineRef}
|
||||||
className="relative z-10 flex h-full flex-col-reverse"
|
className="relative z-10 flex h-full flex-col-reverse"
|
||||||
onClick={timelineClick}
|
|
||||||
onTouchEnd={timelineClick}
|
|
||||||
>
|
>
|
||||||
{consolidatedSegments.map((segment, index) => (
|
{consolidatedSegments.map((segment, index) => (
|
||||||
<SummarySegment
|
<SummarySegment
|
||||||
@@ -367,11 +422,10 @@ export function SummaryTimeline({
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
ref={visibleSectionRef}
|
ref={visibleSectionRef}
|
||||||
onMouseDown={handleMouseDown}
|
className={cn(
|
||||||
onTouchStart={handleMouseDown}
|
"absolute z-20 w-full border-y border-primary/60 bg-primary/30 shadow-[0_0_0_1px_hsl(var(--background))]",
|
||||||
className={`absolute z-20 w-full touch-none bg-primary/30 ${
|
!isDragging && "cursor-grab",
|
||||||
isDragging ? "cursor-grabbing" : "cursor-grab"
|
)}
|
||||||
}`}
|
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -923,7 +923,7 @@ function DetectionReview({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex w-[65px] flex-row md:w-[110px]">
|
<div className="flex w-[73px] flex-row md:w-[110px]">
|
||||||
<div className="no-scrollbar relative w-[55px] md:w-[100px]">
|
<div className="no-scrollbar relative w-[55px] md:w-[100px]">
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<Skeleton className="size-full" />
|
<Skeleton className="size-full" />
|
||||||
@@ -951,7 +951,7 @@ function DetectionReview({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="w-[10px]">
|
<div className="w-[18px] md:w-[10px]">
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<Skeleton className="w-full" />
|
<Skeleton className="w-full" />
|
||||||
) : (
|
) : (
|
||||||
@@ -1013,6 +1013,7 @@ function MotionReview({
|
|||||||
const segmentDuration = 30;
|
const segmentDuration = 30;
|
||||||
const { data: config } = useSWR<FrigateConfig>("config");
|
const { data: config } = useSWR<FrigateConfig>("config");
|
||||||
const allowedCameras = useAllowedCameras();
|
const allowedCameras = useAllowedCameras();
|
||||||
|
const motionTimelineRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const reviewCameras = useMemo(() => {
|
const reviewCameras = useMemo(() => {
|
||||||
if (!config) {
|
if (!config) {
|
||||||
@@ -1700,9 +1701,16 @@ function MotionReview({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{!selectedMotionPreviewCamera && (
|
{!selectedMotionPreviewCamera && (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"flex flex-row",
|
||||||
|
motionOnly ? "w-[55px] md:w-[100px]" : "w-[73px] md:w-[110px]",
|
||||||
|
)}
|
||||||
|
>
|
||||||
<div className="no-scrollbar w-[55px] overflow-y-auto md:w-[100px]">
|
<div className="no-scrollbar w-[55px] overflow-y-auto md:w-[100px]">
|
||||||
{motionData ? (
|
{motionData ? (
|
||||||
<MotionReviewTimeline
|
<MotionReviewTimeline
|
||||||
|
timelineRef={motionTimelineRef}
|
||||||
segmentDuration={segmentDuration}
|
segmentDuration={segmentDuration}
|
||||||
timestampSpread={15}
|
timestampSpread={15}
|
||||||
timelineStart={timeRangeSegments.end}
|
timelineStart={timeRangeSegments.end}
|
||||||
@@ -1730,6 +1738,23 @@ function MotionReview({
|
|||||||
<Skeleton className="size-full" />
|
<Skeleton className="size-full" />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
{!motionOnly && (
|
||||||
|
<div className="w-[18px] md:w-[10px]">
|
||||||
|
{motionData ? (
|
||||||
|
<SummaryTimeline
|
||||||
|
reviewTimelineRef={motionTimelineRef}
|
||||||
|
timelineStart={timeRangeSegments.end}
|
||||||
|
timelineEnd={timeRangeSegments.start}
|
||||||
|
segmentDuration={segmentDuration}
|
||||||
|
motionData={motionData}
|
||||||
|
motionScale={segmentDuration / 2}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Skeleton className="w-full" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!selectedMotionPreviewCamera && (
|
{!selectedMotionPreviewCamera && (
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ import { cn } from "@/lib/utils";
|
|||||||
import { useFullscreen } from "@/hooks/use-fullscreen";
|
import { useFullscreen } from "@/hooks/use-fullscreen";
|
||||||
import { useTimezone } from "@/hooks/use-date-utils";
|
import { useTimezone } from "@/hooks/use-date-utils";
|
||||||
import { useTimelineZoom } from "@/hooks/use-timeline-zoom";
|
import { useTimelineZoom } from "@/hooks/use-timeline-zoom";
|
||||||
|
import SummaryTimeline from "@/components/timeline/SummaryTimeline";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useTimelineUtils } from "@/hooks/use-timeline-utils";
|
import { useTimelineUtils } from "@/hooks/use-timeline-utils";
|
||||||
import {
|
import {
|
||||||
@@ -1317,14 +1318,14 @@ function Timeline({
|
|||||||
isDesktop
|
isDesktop
|
||||||
? cn(
|
? cn(
|
||||||
timelineType == "timeline"
|
timelineType == "timeline"
|
||||||
? "w-[100px] flex-shrink-0"
|
? "w-[110px] flex-shrink-0"
|
||||||
: timelineType == "detail"
|
: timelineType == "detail"
|
||||||
? "min-w-[20rem] max-w-[30%] flex-shrink-0 flex-grow-0 basis-[30rem] md:min-w-[20rem] md:max-w-[25%] lg:min-w-[30rem] lg:max-w-[33%]"
|
? "min-w-[20rem] max-w-[30%] flex-shrink-0 flex-grow-0 basis-[30rem] md:min-w-[20rem] md:max-w-[25%] lg:min-w-[30rem] lg:max-w-[33%]"
|
||||||
: "w-80 flex-shrink-0",
|
: "w-80 flex-shrink-0",
|
||||||
)
|
)
|
||||||
: cn(
|
: cn(
|
||||||
timelineType == "timeline"
|
timelineType == "timeline"
|
||||||
? "portrait:flex-grow landscape:w-[100px] landscape:flex-shrink-0"
|
? "portrait:flex-grow landscape:w-[128px] landscape:flex-shrink-0"
|
||||||
: timelineType == "detail"
|
: timelineType == "detail"
|
||||||
? "portrait:flex-grow landscape:w-[19rem] landscape:flex-shrink-0"
|
? "portrait:flex-grow landscape:w-[19rem] landscape:flex-shrink-0"
|
||||||
: "portrait:flex-grow landscape:w-[19rem] landscape:flex-shrink-0",
|
: "portrait:flex-grow landscape:w-[19rem] landscape:flex-shrink-0",
|
||||||
@@ -1345,6 +1346,8 @@ function Timeline({
|
|||||||
)}
|
)}
|
||||||
{timelineType == "timeline" ? (
|
{timelineType == "timeline" ? (
|
||||||
!isLoading ? (
|
!isLoading ? (
|
||||||
|
<div className="flex size-full flex-row">
|
||||||
|
<div className="relative h-full min-w-0 flex-1">
|
||||||
<MotionReviewTimeline
|
<MotionReviewTimeline
|
||||||
timelineRef={selectedTimelineRef}
|
timelineRef={selectedTimelineRef}
|
||||||
segmentDuration={zoomSettings.segmentDuration}
|
segmentDuration={zoomSettings.segmentDuration}
|
||||||
@@ -1371,6 +1374,23 @@ function Timeline({
|
|||||||
possibleZoomLevels={possibleZoomLevels}
|
possibleZoomLevels={possibleZoomLevels}
|
||||||
currentZoomLevel={currentZoomLevel}
|
currentZoomLevel={currentZoomLevel}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"flex-shrink-0",
|
||||||
|
isDesktop ? "w-[10px]" : "w-[28px]",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<SummaryTimeline
|
||||||
|
reviewTimelineRef={selectedTimelineRef}
|
||||||
|
timelineStart={timeRange.before}
|
||||||
|
timelineEnd={timeRange.after}
|
||||||
|
segmentDuration={zoomSettings.segmentDuration}
|
||||||
|
motionData={motionData}
|
||||||
|
motionScale={Math.round(zoomSettings.segmentDuration / 2)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<Skeleton className="size-full" />
|
<Skeleton className="size-full" />
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user