mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-19 23:08:08 +02:00
Camera connection quality indicator (#21297)
* add camera connection quality metrics and indicator * formatting * move stall calcs to watchdog * clean up * change watchdog to 1s and separately track time for ffmpeg retry_interval * implement status caching to reduce message volume
This commit is contained in:
committed by
Nicolas Mowen
parent
004bb7d80d
commit
dde738cfdc
76
web/src/components/camera/ConnectionQualityIndicator.tsx
Normal file
76
web/src/components/camera/ConnectionQualityIndicator.tsx
Normal file
@@ -0,0 +1,76 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type ConnectionQualityIndicatorProps = {
|
||||
quality: "excellent" | "fair" | "poor" | "unusable";
|
||||
expectedFps: number;
|
||||
reconnects: number;
|
||||
stalls: number;
|
||||
};
|
||||
|
||||
export function ConnectionQualityIndicator({
|
||||
quality,
|
||||
expectedFps,
|
||||
reconnects,
|
||||
stalls,
|
||||
}: ConnectionQualityIndicatorProps) {
|
||||
const { t } = useTranslation(["views/system"]);
|
||||
|
||||
const getColorClass = (quality: string): string => {
|
||||
switch (quality) {
|
||||
case "excellent":
|
||||
return "bg-success";
|
||||
case "fair":
|
||||
return "bg-yellow-500";
|
||||
case "poor":
|
||||
return "bg-orange-500";
|
||||
case "unusable":
|
||||
return "bg-destructive";
|
||||
default:
|
||||
return "bg-gray-500";
|
||||
}
|
||||
};
|
||||
|
||||
const qualityLabel = t(`cameras.connectionQuality.${quality}`);
|
||||
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div
|
||||
className={cn(
|
||||
"inline-block size-3 cursor-pointer rounded-full",
|
||||
getColorClass(quality),
|
||||
)}
|
||||
/>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent className="max-w-xs">
|
||||
<div className="space-y-2">
|
||||
<div className="font-semibold">
|
||||
{t("cameras.connectionQuality.title")}
|
||||
</div>
|
||||
<div className="text-sm">
|
||||
<div className="capitalize">{qualityLabel}</div>
|
||||
<div className="mt-2 space-y-1 text-xs">
|
||||
<div>
|
||||
{t("cameras.connectionQuality.expectedFps")}:{" "}
|
||||
{expectedFps.toFixed(1)} {t("cameras.connectionQuality.fps")}
|
||||
</div>
|
||||
<div>
|
||||
{t("cameras.connectionQuality.reconnectsLastHour")}:{" "}
|
||||
{reconnects}
|
||||
</div>
|
||||
<div>
|
||||
{t("cameras.connectionQuality.stallsLastHour")}: {stalls}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user