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": {
|
||||
"descriptionSaved": "Successfully saved description",
|
||||
"saveDescriptionFailed": "Failed to update the description: {{errorMessage}}"
|
||||
},
|
||||
"title": {
|
||||
"label": "Title"
|
||||
}
|
||||
},
|
||||
"itemMenu": {
|
||||
|
||||
@ -6,16 +6,15 @@ import {
|
||||
ThreatLevel,
|
||||
THREAT_LEVEL_LABELS,
|
||||
} from "@/types/review";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { isDesktop } from "react-device-detect";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { MdAutoAwesome } from "react-icons/md";
|
||||
|
||||
type GenAISummaryChipProps = {
|
||||
review?: ReviewSegment;
|
||||
onClick: () => void;
|
||||
};
|
||||
export function GenAISummaryChip({ review, onClick }: GenAISummaryChipProps) {
|
||||
export function GenAISummaryChip({ review }: GenAISummaryChipProps) {
|
||||
const [isVisible, setIsVisible] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
@ -29,7 +28,6 @@ export function GenAISummaryChip({ review, onClick }: GenAISummaryChipProps) {
|
||||
isVisible ? "translate-y-0 opacity-100" : "-translate-y-4 opacity-0",
|
||||
isDesktop ? "bg-card" : "bg-secondary-foreground",
|
||||
)}
|
||||
onClick={onClick}
|
||||
>
|
||||
<MdAutoAwesome className="shrink-0" />
|
||||
<span className="truncate">{review?.data.metadata?.title}</span>
|
||||
@ -40,10 +38,12 @@ export function GenAISummaryChip({ review, onClick }: GenAISummaryChipProps) {
|
||||
type GenAISummaryDialogProps = {
|
||||
review?: ReviewSegment;
|
||||
onOpen?: (open: boolean) => void;
|
||||
children: React.ReactNode;
|
||||
};
|
||||
export function GenAISummaryDialog({
|
||||
review,
|
||||
onOpen,
|
||||
children,
|
||||
}: GenAISummaryDialogProps) {
|
||||
const { t } = useTranslation(["views/explore"]);
|
||||
|
||||
@ -104,7 +104,7 @@ export function GenAISummaryDialog({
|
||||
return (
|
||||
<Overlay open={open} onOpenChange={setOpen}>
|
||||
<Trigger asChild>
|
||||
<GenAISummaryChip review={review} onClick={() => setOpen(true)} />
|
||||
<div>{children}</div>
|
||||
</Trigger>
|
||||
<Content
|
||||
className={cn(
|
||||
@ -115,6 +115,10 @@ export function GenAISummaryDialog({
|
||||
)}
|
||||
>
|
||||
{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">
|
||||
{t("details.description.label")}
|
||||
</div>
|
||||
|
||||
@ -31,6 +31,7 @@ import { PiSlidersHorizontalBold } from "react-icons/pi";
|
||||
import { MdAutoAwesome } from "react-icons/md";
|
||||
import { isPWA } from "@/utils/isPWA";
|
||||
import { isInIframe } from "@/utils/isIFrame";
|
||||
import { GenAISummaryDialog } from "../overlay/chip/GenAISummaryChip";
|
||||
|
||||
type DetailStreamProps = {
|
||||
reviewItems?: ReviewSegment[];
|
||||
@ -438,7 +439,18 @@ function ReviewGroup({
|
||||
{review.data.metadata.title}
|
||||
</TooltipContent>
|
||||
</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 className="flex flex-row items-center gap-1.5">
|
||||
|
||||
@ -66,7 +66,10 @@ import {
|
||||
import { CameraNameLabel } from "@/components/camera/FriendlyNameLabel";
|
||||
import { useAllowedCameras } from "@/hooks/use-allowed-cameras";
|
||||
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
|
||||
|
||||
@ -739,7 +742,9 @@ export function RecordingView({
|
||||
<GenAISummaryDialog
|
||||
review={activeReviewItem}
|
||||
onOpen={onAnalysisOpen}
|
||||
/>
|
||||
>
|
||||
<GenAISummaryChip review={activeReviewItem} />
|
||||
</GenAISummaryDialog>
|
||||
)}
|
||||
|
||||
<DynamicVideoPlayer
|
||||
@ -997,7 +1002,9 @@ function Timeline({
|
||||
)}
|
||||
>
|
||||
{isMobile && timelineType == "timeline" && (
|
||||
<GenAISummaryDialog review={activeReviewItem} onOpen={onAnalysisOpen} />
|
||||
<GenAISummaryDialog review={activeReviewItem} onOpen={onAnalysisOpen}>
|
||||
<GenAISummaryChip review={activeReviewItem} />
|
||||
</GenAISummaryDialog>
|
||||
)}
|
||||
|
||||
{timelineType != "detail" && (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user