mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-06-21 03:41:55 +03:00
display zone names consistently using friendly_name or raw id without transformation
This commit is contained in:
parent
37ea6b46b5
commit
36e5dcc75a
@ -243,12 +243,7 @@ export default function CameraReviewClassification({
|
|||||||
handleZoneToggle("alerts.required_zones", zone.name)
|
handleZoneToggle("alerts.required_zones", zone.name)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Label
|
<Label className="font-normal">
|
||||||
className={cn(
|
|
||||||
"font-normal",
|
|
||||||
!zone.friendly_name && "smart-capitalize",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{zone.friendly_name || zone.name}
|
{zone.friendly_name || zone.name}
|
||||||
</Label>
|
</Label>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -29,8 +29,8 @@ function getZoneDisplayName(zoneName: string, context?: FormContext): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Fallback to cleaning up the zone name
|
// Fallback to the raw zone id verbatim (no friendly_name available)
|
||||||
return String(zoneName).replace(/_/g, " ");
|
return String(zoneName);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ZoneSwitchesWidget(props: WidgetProps) {
|
export function ZoneSwitchesWidget(props: WidgetProps) {
|
||||||
|
|||||||
@ -1197,14 +1197,7 @@ function LifecycleIconRow({
|
|||||||
backgroundColor: `rgb(${color})`,
|
backgroundColor: `rgb(${color})`,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<span
|
<span>{item.data?.zones_friendly_names?.[zidx]}</span>
|
||||||
className={cn(
|
|
||||||
item.data?.zones_friendly_names?.[zidx] === zone &&
|
|
||||||
"smart-capitalize",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{item.data?.zones_friendly_names?.[zidx]}
|
|
||||||
</span>
|
|
||||||
</Badge>
|
</Badge>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@ -7,12 +7,12 @@ export function resolveZoneName(
|
|||||||
zoneId: string,
|
zoneId: string,
|
||||||
cameraId?: string,
|
cameraId?: string,
|
||||||
) {
|
) {
|
||||||
if (!config) return String(zoneId).replace(/_/g, " ");
|
if (!config) return String(zoneId);
|
||||||
|
|
||||||
if (cameraId) {
|
if (cameraId) {
|
||||||
const camera = config.cameras?.[String(cameraId)];
|
const camera = config.cameras?.[String(cameraId)];
|
||||||
const zone = camera?.zones?.[zoneId];
|
const zone = camera?.zones?.[zoneId];
|
||||||
return zone?.friendly_name || String(zoneId).replace(/_/g, " ");
|
return zone?.friendly_name || String(zoneId);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const camKey in config.cameras) {
|
for (const camKey in config.cameras) {
|
||||||
@ -21,12 +21,12 @@ export function resolveZoneName(
|
|||||||
if (!cam?.zones) continue;
|
if (!cam?.zones) continue;
|
||||||
if (Object.prototype.hasOwnProperty.call(cam.zones, zoneId)) {
|
if (Object.prototype.hasOwnProperty.call(cam.zones, zoneId)) {
|
||||||
const zone = cam.zones[zoneId];
|
const zone = cam.zones[zoneId];
|
||||||
return zone?.friendly_name || String(zoneId).replace(/_/g, " ");
|
return zone?.friendly_name || String(zoneId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback: return a cleaned-up zoneId string
|
// Fallback: display the raw zone id verbatim (no friendly_name available)
|
||||||
return String(zoneId).replace(/_/g, " ");
|
return String(zoneId);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useZoneFriendlyName(zoneId: string, cameraId?: string): string {
|
export function useZoneFriendlyName(zoneId: string, cameraId?: string): string {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user