mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-09 04:35:25 +03:00
make event bars clickable
This commit is contained in:
parent
93bd9ded88
commit
cfe4dc59b7
@ -102,7 +102,7 @@ export function EventReviewTimeline({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<EventSegment
|
<EventSegment
|
||||||
key={segmentTime}
|
key={segmentTime + severityType}
|
||||||
events={events}
|
events={events}
|
||||||
segmentDuration={segmentDuration}
|
segmentDuration={segmentDuration}
|
||||||
segmentTime={segmentTime}
|
segmentTime={segmentTime}
|
||||||
@ -111,6 +111,7 @@ export function EventReviewTimeline({
|
|||||||
minimapStartTime={minimapStartTime}
|
minimapStartTime={minimapStartTime}
|
||||||
minimapEndTime={minimapEndTime}
|
minimapEndTime={minimapEndTime}
|
||||||
severityType={severityType}
|
severityType={severityType}
|
||||||
|
contentRef={contentRef}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -122,6 +123,7 @@ export function EventReviewTimeline({
|
|||||||
showMinimap,
|
showMinimap,
|
||||||
minimapStartTime,
|
minimapStartTime,
|
||||||
minimapEndTime,
|
minimapEndTime,
|
||||||
|
events,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const segments = useMemo(
|
const segments = useMemo(
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { useEventUtils } from "@/hooks/use-event-utils";
|
import { useEventUtils } from "@/hooks/use-event-utils";
|
||||||
import { useSegmentUtils } from "@/hooks/use-segment-utils";
|
import { useSegmentUtils } from "@/hooks/use-segment-utils";
|
||||||
import { ReviewSegment, ReviewSeverity } from "@/types/review";
|
import { ReviewSegment, ReviewSeverity } from "@/types/review";
|
||||||
import React, { useEffect, useMemo, useRef } from "react";
|
import React, { RefObject, useEffect, useMemo, useRef } from "react";
|
||||||
|
|
||||||
type EventSegmentProps = {
|
type EventSegmentProps = {
|
||||||
events: ReviewSegment[];
|
events: ReviewSegment[];
|
||||||
@ -12,6 +12,7 @@ type EventSegmentProps = {
|
|||||||
minimapStartTime?: number;
|
minimapStartTime?: number;
|
||||||
minimapEndTime?: number;
|
minimapEndTime?: number;
|
||||||
severityType: ReviewSeverity;
|
severityType: ReviewSeverity;
|
||||||
|
contentRef: RefObject<HTMLDivElement>;
|
||||||
};
|
};
|
||||||
|
|
||||||
type MinimapSegmentProps = {
|
type MinimapSegmentProps = {
|
||||||
@ -131,6 +132,7 @@ export function EventSegment({
|
|||||||
minimapStartTime,
|
minimapStartTime,
|
||||||
minimapEndTime,
|
minimapEndTime,
|
||||||
severityType,
|
severityType,
|
||||||
|
contentRef,
|
||||||
}: EventSegmentProps) {
|
}: EventSegmentProps) {
|
||||||
const {
|
const {
|
||||||
getSeverity,
|
getSeverity,
|
||||||
@ -269,6 +271,16 @@ export function EventSegment({
|
|||||||
${roundTop ? "rounded-tl-full rounded-tr-full" : ""}
|
${roundTop ? "rounded-tl-full rounded-tr-full" : ""}
|
||||||
${severityColors[severityValue]}
|
${severityColors[severityValue]}
|
||||||
`}
|
`}
|
||||||
|
onClick={() => {
|
||||||
|
if (contentRef.current) {
|
||||||
|
const element = contentRef.current.querySelector(
|
||||||
|
`[data-segment-start="${segmentTime}"]`
|
||||||
|
);
|
||||||
|
if (element instanceof HTMLElement) {
|
||||||
|
debounceScrollIntoView(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import EventReviewTimeline from "@/components/timeline/EventReviewTimeline";
|
|||||||
import ActivityIndicator from "@/components/ui/activity-indicator";
|
import ActivityIndicator from "@/components/ui/activity-indicator";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
|
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
|
||||||
|
import { useEventUtils } from "@/hooks/use-event-utils";
|
||||||
import { FrigateConfig } from "@/types/frigateConfig";
|
import { FrigateConfig } from "@/types/frigateConfig";
|
||||||
import { ReviewFilter, ReviewSegment, ReviewSeverity } from "@/types/review";
|
import { ReviewFilter, ReviewSegment, ReviewSeverity } from "@/types/review";
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
@ -41,6 +42,7 @@ export default function DesktopEventView({
|
|||||||
const { data: config } = useSWR<FrigateConfig>("config");
|
const { data: config } = useSWR<FrigateConfig>("config");
|
||||||
const [severity, setSeverity] = useState<ReviewSeverity>("alert");
|
const [severity, setSeverity] = useState<ReviewSeverity>("alert");
|
||||||
const contentRef = useRef<HTMLDivElement | null>(null);
|
const contentRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
const segmentDuration = 60;
|
||||||
|
|
||||||
// review paging
|
// review paging
|
||||||
|
|
||||||
@ -76,6 +78,11 @@ export default function DesktopEventView({
|
|||||||
};
|
};
|
||||||
}, [reviewPages]);
|
}, [reviewPages]);
|
||||||
|
|
||||||
|
const { alignDateToTimeline } = useEventUtils(
|
||||||
|
reviewItems.all,
|
||||||
|
segmentDuration
|
||||||
|
);
|
||||||
|
|
||||||
const currentItems = useMemo(() => {
|
const currentItems = useMemo(() => {
|
||||||
const current = reviewItems[severity];
|
const current = reviewItems[severity];
|
||||||
|
|
||||||
@ -91,8 +98,8 @@ export default function DesktopEventView({
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return contentRef.current.scrollHeight > contentRef.current.clientHeight
|
return contentRef.current.scrollHeight > contentRef.current.clientHeight;
|
||||||
}, [contentRef.current?.scrollHeight])
|
}, [contentRef.current?.scrollHeight]);
|
||||||
|
|
||||||
// review interaction
|
// review interaction
|
||||||
|
|
||||||
@ -244,10 +251,7 @@ export default function DesktopEventView({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex h-full overflow-hidden">
|
<div className="flex h-full overflow-hidden">
|
||||||
<div
|
<div className="flex flex-1 flex-wrap content-start gap-2 overflow-y-auto no-scrollbar">
|
||||||
ref={contentRef}
|
|
||||||
className="flex flex-1 flex-wrap content-start gap-2 overflow-y-auto no-scrollbar"
|
|
||||||
>
|
|
||||||
{hasUpdate && (
|
{hasUpdate && (
|
||||||
<div className="absolute w-full z-30">
|
<div className="absolute w-full z-30">
|
||||||
<div className="flex justify-center items-center mr-[100px]">
|
<div className="flex justify-center items-center mr-[100px]">
|
||||||
@ -276,7 +280,10 @@ export default function DesktopEventView({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="w-full mr-4 md:grid md:grid-cols-3 3xl:grid-cols-4 gap-4">
|
<div
|
||||||
|
className="w-full mr-4 md:grid md:grid-cols-3 3xl:grid-cols-4 gap-4"
|
||||||
|
ref={contentRef}
|
||||||
|
>
|
||||||
{currentItems ? (
|
{currentItems ? (
|
||||||
currentItems.map((value, segIdx) => {
|
currentItems.map((value, segIdx) => {
|
||||||
const lastRow = segIdx == reviewItems[severity].length - 1;
|
const lastRow = segIdx == reviewItems[severity].length - 1;
|
||||||
@ -294,6 +301,9 @@ export default function DesktopEventView({
|
|||||||
key={value.id}
|
key={value.id}
|
||||||
ref={lastRow ? lastReviewRef : minimapRef}
|
ref={lastRow ? lastReviewRef : minimapRef}
|
||||||
data-start={value.start_time}
|
data-start={value.start_time}
|
||||||
|
data-segment-start={
|
||||||
|
alignDateToTimeline(value.start_time) - segmentDuration
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<div className="aspect-video rounded-lg overflow-hidden">
|
<div className="aspect-video rounded-lg overflow-hidden">
|
||||||
<PreviewThumbnailPlayer
|
<PreviewThumbnailPlayer
|
||||||
@ -314,7 +324,7 @@ export default function DesktopEventView({
|
|||||||
</div>
|
</div>
|
||||||
<div className="md:w-[100px] overflow-y-auto no-scrollbar">
|
<div className="md:w-[100px] overflow-y-auto no-scrollbar">
|
||||||
<EventReviewTimeline
|
<EventReviewTimeline
|
||||||
segmentDuration={60}
|
segmentDuration={segmentDuration}
|
||||||
timestampSpread={15}
|
timestampSpread={15}
|
||||||
timelineStart={timeRange.before}
|
timelineStart={timeRange.before}
|
||||||
timelineEnd={timeRange.after}
|
timelineEnd={timeRange.after}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user