mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-01-22 20:18:30 +03:00
Improve usability of GenAI summary dialog and make clicking on the description directly open it
This commit is contained in:
parent
1eaeb42749
commit
64b5162000
@ -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": {
|
||||||
|
|||||||
@ -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">
|
||||||
|
|||||||
@ -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