chore: fix use-stats and notification setting camera nickname

This commit is contained in:
ZhaiSoul 2025-08-22 15:16:29 +00:00
parent 5697c6bdd7
commit 48934e0b12
2 changed files with 9 additions and 8 deletions

View File

@ -61,10 +61,11 @@ export default function useStats(stats: FrigateStats | undefined) {
return; return;
} }
const cameraName = config.cameras?.[name]?.nickname ?? name;
if (config.cameras[name].enabled && cam["camera_fps"] == 0) { if (config.cameras[name].enabled && cam["camera_fps"] == 0) {
problems.push({ problems.push({
text: t("stats.cameraIsOffline", { text: t("stats.cameraIsOffline", {
camera: capitalizeFirstLetter(name.replaceAll("_", " ")), camera: capitalizeFirstLetter(cameraName),
}), }),
color: "text-danger", color: "text-danger",
relevantLink: "logs", relevantLink: "logs",
@ -81,10 +82,11 @@ export default function useStats(stats: FrigateStats | undefined) {
memoizedStats["cpu_usages"][cam["pid"]]?.cpu_average, memoizedStats["cpu_usages"][cam["pid"]]?.cpu_average,
); );
const cameraName = config?.cameras?.[name]?.nickname ?? name;
if (!isNaN(ffmpegAvg) && ffmpegAvg >= CameraFfmpegThreshold.error) { if (!isNaN(ffmpegAvg) && ffmpegAvg >= CameraFfmpegThreshold.error) {
problems.push({ problems.push({
text: t("stats.ffmpegHighCpuUsage", { text: t("stats.ffmpegHighCpuUsage", {
camera: capitalizeFirstLetter(name.replaceAll("_", " ")), camera: capitalizeFirstLetter(cameraName),
ffmpegAvg, ffmpegAvg,
}), }),
color: "text-danger", color: "text-danger",
@ -95,7 +97,7 @@ export default function useStats(stats: FrigateStats | undefined) {
if (!isNaN(detectAvg) && detectAvg >= CameraDetectThreshold.error) { if (!isNaN(detectAvg) && detectAvg >= CameraDetectThreshold.error) {
problems.push({ problems.push({
text: t("stats.detectHighCpuUsage", { text: t("stats.detectHighCpuUsage", {
camera: capitalizeFirstLetter(name.replaceAll("_", " ")), camera: capitalizeFirstLetter(cameraName),
detectAvg, detectAvg,
}), }),
color: "text-danger", color: "text-danger",

View File

@ -11,7 +11,6 @@ import {
} from "@/components/ui/form"; } from "@/components/ui/form";
import Heading from "@/components/ui/heading"; import Heading from "@/components/ui/heading";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Separator } from "@/components/ui/separator"; import { Separator } from "@/components/ui/separator";
import { Toaster } from "@/components/ui/sonner"; import { Toaster } from "@/components/ui/sonner";
import { StatusBarMessagesContext } from "@/context/statusbar-provider"; import { StatusBarMessagesContext } from "@/context/statusbar-provider";
@ -46,6 +45,7 @@ import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Trans, useTranslation } from "react-i18next"; import { Trans, useTranslation } from "react-i18next";
import { useDateLocale } from "@/hooks/use-date-locale"; import { useDateLocale } from "@/hooks/use-date-locale";
import { useDocDomain } from "@/hooks/use-doc-domain"; import { useDocDomain } from "@/hooks/use-doc-domain";
import { CameraNameLabel } from "@/components/camera/CameraNameLabel";
const NOTIFICATION_SERVICE_WORKER = "notifications-worker.js"; const NOTIFICATION_SERVICE_WORKER = "notifications-worker.js";
@ -698,12 +698,11 @@ export function CameraNotificationSwitch({
<LuX className="size-6 text-danger" /> <LuX className="size-6 text-danger" />
)} )}
<div className="flex flex-col"> <div className="flex flex-col">
<Label <CameraNameLabel
className="text-md cursor-pointer text-primary smart-capitalize" className="text-md cursor-pointer text-primary smart-capitalize"
htmlFor="camera" htmlFor="camera"
> camera={camera}
{camera.replaceAll("_", " ")} />
</Label>
{!isSuspended ? ( {!isSuspended ? (
<div className="flex flex-row items-center gap-2 text-sm text-success"> <div className="flex flex-row items-center gap-2 text-sm text-success">