mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-07 11:45:24 +03:00
Only show timeline for selected hour
This commit is contained in:
parent
0f38eb69bd
commit
6ee7cacaa2
@ -9,8 +9,6 @@ import { Event } from "@/types/event";
|
|||||||
import ActivityIndicator from "@/components/ui/activity-indicator";
|
import ActivityIndicator from "@/components/ui/activity-indicator";
|
||||||
import { useApiHost } from "@/api";
|
import { useApiHost } from "@/api";
|
||||||
import TimelineScrubber from "@/components/playground/TimelineScrubber";
|
import TimelineScrubber from "@/components/playground/TimelineScrubber";
|
||||||
import TimelineGraph from "@/components/graph/TimelineGraph";
|
|
||||||
import { GraphDataPoint } from "@/types/graph";
|
|
||||||
|
|
||||||
// Color data
|
// Color data
|
||||||
const colors = [
|
const colors = [
|
||||||
@ -76,36 +74,6 @@ function UIPlayground() {
|
|||||||
"events",
|
"events",
|
||||||
{ limit: 10, after: recentTimestamp },
|
{ limit: 10, after: recentTimestamp },
|
||||||
]);
|
]);
|
||||||
const { data: recordingSegments } = useSWR<RecordingSegment[]>([
|
|
||||||
"front_cam/recordings",
|
|
||||||
{ before: 1704211200, after: 1704207600 },
|
|
||||||
]);
|
|
||||||
|
|
||||||
const graphData = useMemo(() => {
|
|
||||||
if (!recordingSegments) {
|
|
||||||
return { motion: [], objects: [] };
|
|
||||||
}
|
|
||||||
|
|
||||||
const motion: GraphDataPoint[] = [];
|
|
||||||
const objects: GraphDataPoint[] = [];
|
|
||||||
|
|
||||||
recordingSegments
|
|
||||||
.forEach((seg) => {
|
|
||||||
if (seg.objects > 0) {
|
|
||||||
objects.push({
|
|
||||||
x: new Date((seg.start_time + 5) * 1000),
|
|
||||||
y: seg.motion,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
motion.push({
|
|
||||||
x: new Date((seg.start_time + 5) * 1000),
|
|
||||||
y: seg.motion,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return { motion, objects };
|
|
||||||
}, [recordingSegments]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -123,28 +91,12 @@ function UIPlayground() {
|
|||||||
{config && (
|
{config && (
|
||||||
<div>
|
<div>
|
||||||
{events && events.length > 0 && (
|
{events && events.length > 0 && (
|
||||||
<div className="relative">
|
<>
|
||||||
<ActivityScrubber
|
<ActivityScrubber
|
||||||
items={[]}
|
items={eventsToScrubberItems(events)}
|
||||||
options={{
|
|
||||||
start: new Date(1704207600000),
|
|
||||||
end: new Date(1704211200000),
|
|
||||||
}}
|
|
||||||
selectHandler={onSelect}
|
selectHandler={onSelect}
|
||||||
/>
|
/>
|
||||||
<div className="w-full absolute left-0 top-0 h-[84px]">
|
</>
|
||||||
<TimelineGraph
|
|
||||||
id="test"
|
|
||||||
data={[
|
|
||||||
{
|
|
||||||
name: "Motion",
|
|
||||||
data: graphData.motion,
|
|
||||||
},
|
|
||||||
{ name: "Active Objects", data: graphData.objects },
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -327,8 +327,7 @@ export default function DesktopTimelineView({
|
|||||||
key={timeline.range.start}
|
key={timeline.range.start}
|
||||||
className={`relative p-2 ${
|
className={`relative p-2 ${
|
||||||
isSelected ? "bg-secondary bg-opacity-30 rounded-md" : ""
|
isSelected ? "bg-secondary bg-opacity-30 rounded-md" : ""
|
||||||
}`}
|
}`}
|
||||||
onClick={() => setSelectedPlayback(timeline)}
|
|
||||||
>
|
>
|
||||||
<ActivityScrubber
|
<ActivityScrubber
|
||||||
items={[]}
|
items={[]}
|
||||||
@ -384,8 +383,9 @@ export default function DesktopTimelineView({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
doubleClickHandler={() => setSelectedPlayback(timeline)}
|
||||||
/>
|
/>
|
||||||
{graphData && (
|
{isSelected && graphData && (
|
||||||
<div className="w-full absolute left-0 top-0 h-[84px]">
|
<div className="w-full absolute left-0 top-0 h-[84px]">
|
||||||
<TimelineGraph
|
<TimelineGraph
|
||||||
id={timeline.range.start.toString()}
|
id={timeline.range.start.toString()}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user