mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-17 13:48:21 +03:00
Some checks are pending
CI / AMD64 Build (push) Waiting to run
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
* debug replay implementation * fix masks after dev rebase * fix squash merge issues * fix * fix * fix * no need to write debug replay camera to config * camera and filter button and dropdown * add filters * add ability to edit motion and object config for debug replay * add debug draw overlay to debug replay * add guard to prevent crash when camera is no longer in camera_states * fix overflow due to radix absolutely positioned elements * increase number of messages * ensure deep_merge replaces existing list values when override is true * add back button * add debug replay to explore and review menus * clean up * clean up * update instructions to prevent exposing exception info * fix typing * refactor output logic * refactor with helper function * move init to function for consistency
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
// Zone Switches Widget - For selecting zones via switches
|
|
import type { WidgetProps } from "@rjsf/utils";
|
|
import { SwitchesWidget } from "./SwitchesWidget";
|
|
import type { FormContext } from "./SwitchesWidget";
|
|
|
|
function getZoneNames(context: FormContext): string[] {
|
|
if (context?.fullCameraConfig) {
|
|
const zones = context.fullCameraConfig.zones;
|
|
if (typeof zones === "object" && zones !== null) {
|
|
// zones is a dict/object, get the keys
|
|
return Object.keys(zones).sort();
|
|
}
|
|
}
|
|
return [];
|
|
}
|
|
|
|
function getZoneDisplayName(zoneName: string, context?: FormContext): string {
|
|
// Try to get the config from context
|
|
// In the config form context, we may not have the full config directly,
|
|
// so we'll try to use the zone config if available
|
|
if (context?.fullCameraConfig?.zones) {
|
|
const zones = context.fullCameraConfig.zones;
|
|
if (typeof zones === "object" && zones !== null) {
|
|
const zoneConfig = (zones as Record<string, { friendly_name?: string }>)[
|
|
zoneName
|
|
];
|
|
if (zoneConfig?.friendly_name) {
|
|
return zoneConfig.friendly_name;
|
|
}
|
|
}
|
|
}
|
|
// Fallback to cleaning up the zone name
|
|
return String(zoneName).replace(/_/g, " ");
|
|
}
|
|
|
|
export function ZoneSwitchesWidget(props: WidgetProps) {
|
|
return (
|
|
<SwitchesWidget
|
|
{...props}
|
|
options={{
|
|
...props.options,
|
|
getEntities: getZoneNames,
|
|
getDisplayLabel: getZoneDisplayName,
|
|
i18nKey: "zoneNames",
|
|
listClassName: "relative max-h-64 overflow-y-auto scrollbar-container",
|
|
}}
|
|
/>
|
|
);
|
|
}
|