mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-08 20:25:26 +03:00
Display data for review items
This commit is contained in:
parent
320677fe2b
commit
9b9808ca38
@ -1,14 +1,47 @@
|
|||||||
|
import TimeAgo from "@/components/dynamic/TimeAgo";
|
||||||
|
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 { useState } from "react";
|
import { FrigateConfig } from "@/types/frigateConfig";
|
||||||
|
import { ReviewSegment, ReviewSeverity } from "@/types/review";
|
||||||
|
import { formatUnixTimestampToDateTime } from "@/utils/dateUtil";
|
||||||
|
import { useMemo, useState } from "react";
|
||||||
import { LuCalendar, LuFilter, LuVideo } from "react-icons/lu";
|
import { LuCalendar, LuFilter, LuVideo } from "react-icons/lu";
|
||||||
import { MdCircle } from "react-icons/md";
|
import { MdCircle } from "react-icons/md";
|
||||||
|
import useSWR from "swr";
|
||||||
type ReviewSeverity = "alert" | "detection" | "significant_motion";
|
|
||||||
|
|
||||||
export default function Events() {
|
export default function Events() {
|
||||||
|
const { data: config } = useSWR<FrigateConfig>("config");
|
||||||
const [severity, setSeverity] = useState<ReviewSeverity>("alert");
|
const [severity, setSeverity] = useState<ReviewSeverity>("alert");
|
||||||
|
|
||||||
|
const { data: reviewSegments } = useSWR<ReviewSegment[]>("review");
|
||||||
|
|
||||||
|
const previewTimes = useMemo(() => {
|
||||||
|
if (!reviewSegments) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const startDate = new Date();
|
||||||
|
startDate.setMinutes(0, 0, 0);
|
||||||
|
|
||||||
|
const endDate = new Date(reviewSegments.at(-1)!!.end_time);
|
||||||
|
endDate.setHours(0, 0, 0, 0);
|
||||||
|
return {
|
||||||
|
start: startDate.getTime() / 1000,
|
||||||
|
end: endDate.getTime() / 1000,
|
||||||
|
};
|
||||||
|
}, [reviewSegments]);
|
||||||
|
const { data: allPreviews } = useSWR<Preview[]>(
|
||||||
|
previewTimes
|
||||||
|
? `preview/all/start/${previewTimes.start}/end/${previewTimes.end}`
|
||||||
|
: null,
|
||||||
|
{ revalidateOnFocus: false }
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!config) {
|
||||||
|
return <ActivityIndicator />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="w-full flex justify-between">
|
<div className="w-full flex justify-between">
|
||||||
@ -64,6 +97,27 @@ export default function Events() {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="flex flex-wrap gap-2 mt-2">
|
||||||
|
{reviewSegments?.map((value) => {
|
||||||
|
if (value.severity == severity) {
|
||||||
|
return (
|
||||||
|
<div className="relative h-[234px] w-[416px] bg-blue-500 rounded-lg">
|
||||||
|
{value.camera} {value.data.objects}
|
||||||
|
<div className="absolute left-1 right-1 bottom-0 flex justify-between">
|
||||||
|
<TimeAgo time={value.start_time * 1000} />
|
||||||
|
{formatUnixTimestampToDateTime(value.start_time, {
|
||||||
|
strftime_fmt:
|
||||||
|
config.ui.time_format == "24hour"
|
||||||
|
? "%b %-d, %H:%M"
|
||||||
|
: "%b %-d, %I:%M %p",
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,7 @@ export interface ReviewSegment {
|
|||||||
|
|
||||||
export type ReviewSeverity = "alert" | "detection" | "significant_motion";
|
export type ReviewSeverity = "alert" | "detection" | "significant_motion";
|
||||||
|
|
||||||
export type ReviewData = {
|
type ReviewData = {
|
||||||
audio: string[];
|
audio: string[];
|
||||||
detections: string[];
|
detections: string[];
|
||||||
objects: string[];
|
objects: string[];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user