mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-30 18:47:40 +03:00
Cleanup typing and UI
This commit is contained in:
parent
1452c61378
commit
5876695aa1
@ -11,7 +11,11 @@ import { FrigateConfig } from "@/types/frigateConfig";
|
|||||||
import { useFormattedTimestamp } from "@/hooks/use-date-utils";
|
import { useFormattedTimestamp } from "@/hooks/use-date-utils";
|
||||||
import { getIconForLabel } from "@/utils/iconUtil";
|
import { getIconForLabel } from "@/utils/iconUtil";
|
||||||
import { useApiHost } from "@/api";
|
import { useApiHost } from "@/api";
|
||||||
import { ReviewDetailPaneType, ReviewSegment } from "@/types/review";
|
import {
|
||||||
|
ReviewDetailPaneType,
|
||||||
|
ReviewSegment,
|
||||||
|
ThreatLevel,
|
||||||
|
} from "@/types/review";
|
||||||
import { Event } from "@/types/event";
|
import { Event } from "@/types/event";
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
@ -71,6 +75,23 @@ export default function ReviewDetailDialog({
|
|||||||
|
|
||||||
const aiAnalysis = useMemo(() => review?.data?.metadata, [review]);
|
const aiAnalysis = useMemo(() => review?.data?.metadata, [review]);
|
||||||
|
|
||||||
|
const aiThreatLevel = useMemo(() => {
|
||||||
|
if (!aiAnalysis?.potential_threat_level) {
|
||||||
|
return "None";
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (aiAnalysis.potential_threat_level) {
|
||||||
|
case ThreatLevel.UNUSUAL:
|
||||||
|
return "Unusual Activity";
|
||||||
|
case ThreatLevel.SUSPICIOUS:
|
||||||
|
return "Suspicious Activity";
|
||||||
|
case ThreatLevel.DANGER:
|
||||||
|
return "Danger";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Unknown";
|
||||||
|
}, [aiAnalysis]);
|
||||||
|
|
||||||
const hasMismatch = useMemo(() => {
|
const hasMismatch = useMemo(() => {
|
||||||
if (!review || !events) {
|
if (!review || !events) {
|
||||||
return false;
|
return false;
|
||||||
@ -235,12 +256,19 @@ export default function ReviewDetailDialog({
|
|||||||
{pane == "overview" && (
|
{pane == "overview" && (
|
||||||
<div className="flex flex-col gap-5 md:mt-3">
|
<div className="flex flex-col gap-5 md:mt-3">
|
||||||
{aiAnalysis != undefined && (
|
{aiAnalysis != undefined && (
|
||||||
<div className="m-2 flex h-full w-[90%] flex-col gap-2 rounded-md bg-card p-2">
|
<div
|
||||||
|
className={cn(
|
||||||
|
"m-2 flex h-full w-full flex-col gap-2 rounded-md bg-card p-2",
|
||||||
|
isDesktop && "w-[90%]",
|
||||||
|
)}
|
||||||
|
>
|
||||||
AI Analysis
|
AI Analysis
|
||||||
<div className="text-sm text-primary/40">Description</div>
|
<div className="text-sm text-primary/40">Description</div>
|
||||||
<div className="text-sm smart-capitalize">
|
<div className="text-sm">{aiAnalysis.scene}</div>
|
||||||
{aiAnalysis.scene}
|
<div className="text-sm text-primary/40">Score</div>
|
||||||
</div>
|
<div className="text-sm">{aiAnalysis.confidence * 100}%</div>
|
||||||
|
<div className="text-sm text-primary/40">Threat Level</div>
|
||||||
|
<div className="text-sm">{aiThreatLevel}</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="flex w-full flex-row">
|
<div className="flex w-full flex-row">
|
||||||
|
|||||||
@ -20,6 +20,8 @@ export type ReviewData = {
|
|||||||
zones: string[];
|
zones: string[];
|
||||||
metadata?: {
|
metadata?: {
|
||||||
scene: string;
|
scene: string;
|
||||||
|
confidence: number;
|
||||||
|
potential_threat_level?: number;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -76,3 +78,9 @@ export type ConsolidatedSegmentData = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type TimelineZoomDirection = "in" | "out" | null;
|
export type TimelineZoomDirection = "in" | "out" | null;
|
||||||
|
|
||||||
|
export enum ThreatLevel {
|
||||||
|
UNUSUAL = 1,
|
||||||
|
SUSPICIOUS = 2,
|
||||||
|
DANGER = 3,
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user