mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-09 15:05:26 +03:00
Compare commits
3 Commits
1eaeb42749
...
9da178edb6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9da178edb6 | ||
|
|
9bc8c93d20 | ||
|
|
64b5162000 |
@ -9,7 +9,11 @@
|
|||||||
"empty": {
|
"empty": {
|
||||||
"alert": "There are no alerts to review",
|
"alert": "There are no alerts to review",
|
||||||
"detection": "There are no detections to review",
|
"detection": "There are no detections to review",
|
||||||
"motion": "No motion data found"
|
"motion": "No motion data found",
|
||||||
|
"recordingsDisabled": {
|
||||||
|
"title": "Recordings must be enabled",
|
||||||
|
"description": "Review items can only be created for a camera when recordings are enabled for that camera."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"timeline": "Timeline",
|
"timeline": "Timeline",
|
||||||
"timeline.aria": "Select timeline",
|
"timeline.aria": "Select timeline",
|
||||||
|
|||||||
@ -166,6 +166,9 @@
|
|||||||
"tips": {
|
"tips": {
|
||||||
"descriptionSaved": "Successfully saved description",
|
"descriptionSaved": "Successfully saved description",
|
||||||
"saveDescriptionFailed": "Failed to update the description: {{errorMessage}}"
|
"saveDescriptionFailed": "Failed to update the description: {{errorMessage}}"
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"label": "Title"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"itemMenu": {
|
"itemMenu": {
|
||||||
|
|||||||
@ -2,15 +2,18 @@ import React from "react";
|
|||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
import Heading from "../ui/heading";
|
import Heading from "../ui/heading";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
type EmptyCardProps = {
|
type EmptyCardProps = {
|
||||||
|
className?: string;
|
||||||
icon: React.ReactNode;
|
icon: React.ReactNode;
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description?: string;
|
||||||
buttonText?: string;
|
buttonText?: string;
|
||||||
link?: string;
|
link?: string;
|
||||||
};
|
};
|
||||||
export function EmptyCard({
|
export function EmptyCard({
|
||||||
|
className,
|
||||||
icon,
|
icon,
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
@ -18,10 +21,12 @@ export function EmptyCard({
|
|||||||
link,
|
link,
|
||||||
}: EmptyCardProps) {
|
}: EmptyCardProps) {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center gap-2">
|
<div className={cn("flex flex-col items-center gap-2", className)}>
|
||||||
{icon}
|
{icon}
|
||||||
<Heading as="h4">{title}</Heading>
|
<Heading as="h4">{title}</Heading>
|
||||||
|
{description && (
|
||||||
<div className="mb-3 text-secondary-foreground">{description}</div>
|
<div className="mb-3 text-secondary-foreground">{description}</div>
|
||||||
|
)}
|
||||||
{buttonText?.length && (
|
{buttonText?.length && (
|
||||||
<Button size="sm" variant="select">
|
<Button size="sm" variant="select">
|
||||||
<Link to={link ?? "#"}>{buttonText}</Link>
|
<Link to={link ?? "#"}>{buttonText}</Link>
|
||||||
|
|||||||
@ -39,6 +39,7 @@ import { Trans, useTranslation } from "react-i18next";
|
|||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { LuCircle } from "react-icons/lu";
|
import { LuCircle } from "react-icons/lu";
|
||||||
import { MdAutoAwesome } from "react-icons/md";
|
import { MdAutoAwesome } from "react-icons/md";
|
||||||
|
import { GenAISummaryDialog } from "../overlay/chip/GenAISummaryChip";
|
||||||
|
|
||||||
type ReviewCardProps = {
|
type ReviewCardProps = {
|
||||||
event: ReviewSegment;
|
event: ReviewSegment;
|
||||||
@ -219,12 +220,14 @@ export default function ReviewCard({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{event.data.metadata?.title && (
|
{event.data.metadata?.title && (
|
||||||
<div className="flex items-center gap-1.5 rounded bg-secondary/50">
|
<GenAISummaryDialog review={event}>
|
||||||
|
<div className="flex items-center gap-1.5 rounded bg-secondary/50 hover:underline">
|
||||||
<MdAutoAwesome className="size-3 shrink-0 text-primary" />
|
<MdAutoAwesome className="size-3 shrink-0 text-primary" />
|
||||||
<span className="truncate text-xs text-primary">
|
<span className="truncate text-xs text-primary">
|
||||||
{event.data.metadata.title}
|
{event.data.metadata.title}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
</GenAISummaryDialog>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -6,16 +6,15 @@ import {
|
|||||||
ThreatLevel,
|
ThreatLevel,
|
||||||
THREAT_LEVEL_LABELS,
|
THREAT_LEVEL_LABELS,
|
||||||
} from "@/types/review";
|
} from "@/types/review";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import React, { useEffect, useMemo, useState } from "react";
|
||||||
import { isDesktop } from "react-device-detect";
|
import { isDesktop } from "react-device-detect";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { MdAutoAwesome } from "react-icons/md";
|
import { MdAutoAwesome } from "react-icons/md";
|
||||||
|
|
||||||
type GenAISummaryChipProps = {
|
type GenAISummaryChipProps = {
|
||||||
review?: ReviewSegment;
|
review?: ReviewSegment;
|
||||||
onClick: () => void;
|
|
||||||
};
|
};
|
||||||
export function GenAISummaryChip({ review, onClick }: GenAISummaryChipProps) {
|
export function GenAISummaryChip({ review }: GenAISummaryChipProps) {
|
||||||
const [isVisible, setIsVisible] = useState(false);
|
const [isVisible, setIsVisible] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -29,7 +28,6 @@ export function GenAISummaryChip({ review, onClick }: GenAISummaryChipProps) {
|
|||||||
isVisible ? "translate-y-0 opacity-100" : "-translate-y-4 opacity-0",
|
isVisible ? "translate-y-0 opacity-100" : "-translate-y-4 opacity-0",
|
||||||
isDesktop ? "bg-card" : "bg-secondary-foreground",
|
isDesktop ? "bg-card" : "bg-secondary-foreground",
|
||||||
)}
|
)}
|
||||||
onClick={onClick}
|
|
||||||
>
|
>
|
||||||
<MdAutoAwesome className="shrink-0" />
|
<MdAutoAwesome className="shrink-0" />
|
||||||
<span className="truncate">{review?.data.metadata?.title}</span>
|
<span className="truncate">{review?.data.metadata?.title}</span>
|
||||||
@ -40,10 +38,12 @@ export function GenAISummaryChip({ review, onClick }: GenAISummaryChipProps) {
|
|||||||
type GenAISummaryDialogProps = {
|
type GenAISummaryDialogProps = {
|
||||||
review?: ReviewSegment;
|
review?: ReviewSegment;
|
||||||
onOpen?: (open: boolean) => void;
|
onOpen?: (open: boolean) => void;
|
||||||
|
children: React.ReactNode;
|
||||||
};
|
};
|
||||||
export function GenAISummaryDialog({
|
export function GenAISummaryDialog({
|
||||||
review,
|
review,
|
||||||
onOpen,
|
onOpen,
|
||||||
|
children,
|
||||||
}: GenAISummaryDialogProps) {
|
}: GenAISummaryDialogProps) {
|
||||||
const { t } = useTranslation(["views/explore"]);
|
const { t } = useTranslation(["views/explore"]);
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ export function GenAISummaryDialog({
|
|||||||
return (
|
return (
|
||||||
<Overlay open={open} onOpenChange={setOpen}>
|
<Overlay open={open} onOpenChange={setOpen}>
|
||||||
<Trigger asChild>
|
<Trigger asChild>
|
||||||
<GenAISummaryChip review={review} onClick={() => setOpen(true)} />
|
<div>{children}</div>
|
||||||
</Trigger>
|
</Trigger>
|
||||||
<Content
|
<Content
|
||||||
className={cn(
|
className={cn(
|
||||||
@ -115,6 +115,10 @@ export function GenAISummaryDialog({
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{t("aiAnalysis.title")}
|
{t("aiAnalysis.title")}
|
||||||
|
<div className="text-sm text-primary/40">
|
||||||
|
{t("details.title.label")}
|
||||||
|
</div>
|
||||||
|
<div className="text-sm">{aiAnalysis.title}</div>
|
||||||
<div className="text-sm text-primary/40">
|
<div className="text-sm text-primary/40">
|
||||||
{t("details.description.label")}
|
{t("details.description.label")}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -31,6 +31,7 @@ import { PiSlidersHorizontalBold } from "react-icons/pi";
|
|||||||
import { MdAutoAwesome } from "react-icons/md";
|
import { MdAutoAwesome } from "react-icons/md";
|
||||||
import { isPWA } from "@/utils/isPWA";
|
import { isPWA } from "@/utils/isPWA";
|
||||||
import { isInIframe } from "@/utils/isIFrame";
|
import { isInIframe } from "@/utils/isIFrame";
|
||||||
|
import { GenAISummaryDialog } from "../overlay/chip/GenAISummaryChip";
|
||||||
|
|
||||||
type DetailStreamProps = {
|
type DetailStreamProps = {
|
||||||
reviewItems?: ReviewSegment[];
|
reviewItems?: ReviewSegment[];
|
||||||
@ -438,7 +439,18 @@ function ReviewGroup({
|
|||||||
{review.data.metadata.title}
|
{review.data.metadata.title}
|
||||||
</TooltipContent>
|
</TooltipContent>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<span className="truncate">{review.data.metadata.title}</span>
|
<GenAISummaryDialog
|
||||||
|
review={review}
|
||||||
|
onOpen={(open) => {
|
||||||
|
if (open) {
|
||||||
|
onSeek(review.start_time, false);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span className="truncate hover:underline">
|
||||||
|
{review.data.metadata.title}
|
||||||
|
</span>
|
||||||
|
</GenAISummaryDialog>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="flex flex-row items-center gap-1.5">
|
<div className="flex flex-row items-center gap-1.5">
|
||||||
|
|||||||
4
web/src/types/card.ts
Normal file
4
web/src/types/card.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export type EmptyCardData = {
|
||||||
|
title: string;
|
||||||
|
description?: string;
|
||||||
|
};
|
||||||
@ -56,6 +56,8 @@ import { GiSoundWaves } from "react-icons/gi";
|
|||||||
import useKeyboardListener from "@/hooks/use-keyboard-listener";
|
import useKeyboardListener from "@/hooks/use-keyboard-listener";
|
||||||
import { useTimelineZoom } from "@/hooks/use-timeline-zoom";
|
import { useTimelineZoom } from "@/hooks/use-timeline-zoom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { EmptyCard } from "@/components/card/EmptyCard";
|
||||||
|
import { EmptyCardData } from "@/types/card";
|
||||||
|
|
||||||
type EventViewProps = {
|
type EventViewProps = {
|
||||||
reviewItems?: SegmentedReviewData;
|
reviewItems?: SegmentedReviewData;
|
||||||
@ -132,6 +134,24 @@ export default function EventView({
|
|||||||
}
|
}
|
||||||
}, [filter, showReviewed, reviewSummary]);
|
}, [filter, showReviewed, reviewSummary]);
|
||||||
|
|
||||||
|
const emptyCardData: EmptyCardData = useMemo(() => {
|
||||||
|
if (
|
||||||
|
!config ||
|
||||||
|
Object.values(config.cameras).find(
|
||||||
|
(cam) => cam.record.enabled_in_config,
|
||||||
|
) != undefined
|
||||||
|
) {
|
||||||
|
return {
|
||||||
|
title: t("empty." + severity.replace(/_/g, " ")),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: t("empty.recordingsDisabled.title"),
|
||||||
|
description: t("empty.recordingsDisabled.description"),
|
||||||
|
};
|
||||||
|
}, [config, severity, t]);
|
||||||
|
|
||||||
// review interaction
|
// review interaction
|
||||||
|
|
||||||
const [selectedReviews, setSelectedReviews] = useState<ReviewSegment[]>([]);
|
const [selectedReviews, setSelectedReviews] = useState<ReviewSegment[]>([]);
|
||||||
@ -412,6 +432,7 @@ export default function EventView({
|
|||||||
timeRange={timeRange}
|
timeRange={timeRange}
|
||||||
startTime={startTime}
|
startTime={startTime}
|
||||||
loading={severity != severityToggle}
|
loading={severity != severityToggle}
|
||||||
|
emptyCardData={emptyCardData}
|
||||||
markItemAsReviewed={markItemAsReviewed}
|
markItemAsReviewed={markItemAsReviewed}
|
||||||
markAllItemsAsReviewed={markAllItemsAsReviewed}
|
markAllItemsAsReviewed={markAllItemsAsReviewed}
|
||||||
onSelectReview={onSelectReview}
|
onSelectReview={onSelectReview}
|
||||||
@ -430,6 +451,7 @@ export default function EventView({
|
|||||||
startTime={startTime}
|
startTime={startTime}
|
||||||
filter={filter}
|
filter={filter}
|
||||||
motionOnly={motionOnly}
|
motionOnly={motionOnly}
|
||||||
|
emptyCardData={emptyCardData}
|
||||||
onOpenRecording={onOpenRecording}
|
onOpenRecording={onOpenRecording}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@ -455,6 +477,7 @@ type DetectionReviewProps = {
|
|||||||
timeRange: { before: number; after: number };
|
timeRange: { before: number; after: number };
|
||||||
startTime?: number;
|
startTime?: number;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
|
emptyCardData: EmptyCardData;
|
||||||
markItemAsReviewed: (review: ReviewSegment) => void;
|
markItemAsReviewed: (review: ReviewSegment) => void;
|
||||||
markAllItemsAsReviewed: (currentItems: ReviewSegment[]) => void;
|
markAllItemsAsReviewed: (currentItems: ReviewSegment[]) => void;
|
||||||
onSelectReview: (
|
onSelectReview: (
|
||||||
@ -478,6 +501,7 @@ function DetectionReview({
|
|||||||
timeRange,
|
timeRange,
|
||||||
startTime,
|
startTime,
|
||||||
loading,
|
loading,
|
||||||
|
emptyCardData,
|
||||||
markItemAsReviewed,
|
markItemAsReviewed,
|
||||||
markAllItemsAsReviewed,
|
markAllItemsAsReviewed,
|
||||||
onSelectReview,
|
onSelectReview,
|
||||||
@ -737,10 +761,12 @@ function DetectionReview({
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{!loading && currentItems?.length === 0 && (
|
{!loading && currentItems?.length === 0 && (
|
||||||
<div className="absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 flex-col items-center justify-center text-center">
|
<EmptyCard
|
||||||
<LuFolderCheck className="size-16" />
|
className="y-translate-1/2 absolute left-[50%] top-[50%] -translate-x-1/2"
|
||||||
{t("empty." + severity.replace(/_/g, " "))}
|
title={emptyCardData.title}
|
||||||
</div>
|
description={emptyCardData.description}
|
||||||
|
icon={<LuFolderCheck className="size-16" />}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@ -875,6 +901,7 @@ type MotionReviewProps = {
|
|||||||
startTime?: number;
|
startTime?: number;
|
||||||
filter?: ReviewFilter;
|
filter?: ReviewFilter;
|
||||||
motionOnly?: boolean;
|
motionOnly?: boolean;
|
||||||
|
emptyCardData: EmptyCardData;
|
||||||
onOpenRecording: (data: RecordingStartingPoint) => void;
|
onOpenRecording: (data: RecordingStartingPoint) => void;
|
||||||
};
|
};
|
||||||
function MotionReview({
|
function MotionReview({
|
||||||
@ -885,9 +912,9 @@ function MotionReview({
|
|||||||
startTime,
|
startTime,
|
||||||
filter,
|
filter,
|
||||||
motionOnly = false,
|
motionOnly = false,
|
||||||
|
emptyCardData,
|
||||||
onOpenRecording,
|
onOpenRecording,
|
||||||
}: MotionReviewProps) {
|
}: MotionReviewProps) {
|
||||||
const { t } = useTranslation(["views/events"]);
|
|
||||||
const segmentDuration = 30;
|
const segmentDuration = 30;
|
||||||
const { data: config } = useSWR<FrigateConfig>("config");
|
const { data: config } = useSWR<FrigateConfig>("config");
|
||||||
|
|
||||||
@ -1080,9 +1107,12 @@ function MotionReview({
|
|||||||
|
|
||||||
if (motionData?.length === 0) {
|
if (motionData?.length === 0) {
|
||||||
return (
|
return (
|
||||||
<div className="absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 flex-col items-center justify-center text-center">
|
<div className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2">
|
||||||
<LuFolderX className="size-16" />
|
<EmptyCard
|
||||||
{t("empty.motion")}
|
title={emptyCardData.title}
|
||||||
|
description={emptyCardData.description}
|
||||||
|
icon={<LuFolderX className="size-16" />}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,7 +66,10 @@ import {
|
|||||||
import { CameraNameLabel } from "@/components/camera/FriendlyNameLabel";
|
import { CameraNameLabel } from "@/components/camera/FriendlyNameLabel";
|
||||||
import { useAllowedCameras } from "@/hooks/use-allowed-cameras";
|
import { useAllowedCameras } from "@/hooks/use-allowed-cameras";
|
||||||
import { DetailStreamProvider } from "@/context/detail-stream-context";
|
import { DetailStreamProvider } from "@/context/detail-stream-context";
|
||||||
import { GenAISummaryDialog } from "@/components/overlay/chip/GenAISummaryChip";
|
import {
|
||||||
|
GenAISummaryDialog,
|
||||||
|
GenAISummaryChip,
|
||||||
|
} from "@/components/overlay/chip/GenAISummaryChip";
|
||||||
|
|
||||||
const DATA_REFRESH_TIME = 600000; // 10 minutes
|
const DATA_REFRESH_TIME = 600000; // 10 minutes
|
||||||
|
|
||||||
@ -739,7 +742,9 @@ export function RecordingView({
|
|||||||
<GenAISummaryDialog
|
<GenAISummaryDialog
|
||||||
review={activeReviewItem}
|
review={activeReviewItem}
|
||||||
onOpen={onAnalysisOpen}
|
onOpen={onAnalysisOpen}
|
||||||
/>
|
>
|
||||||
|
<GenAISummaryChip review={activeReviewItem} />
|
||||||
|
</GenAISummaryDialog>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<DynamicVideoPlayer
|
<DynamicVideoPlayer
|
||||||
@ -997,7 +1002,9 @@ function Timeline({
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{isMobile && timelineType == "timeline" && (
|
{isMobile && timelineType == "timeline" && (
|
||||||
<GenAISummaryDialog review={activeReviewItem} onOpen={onAnalysisOpen} />
|
<GenAISummaryDialog review={activeReviewItem} onOpen={onAnalysisOpen}>
|
||||||
|
<GenAISummaryChip review={activeReviewItem} />
|
||||||
|
</GenAISummaryDialog>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{timelineType != "detail" && (
|
{timelineType != "detail" && (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user