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

View File

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