This commit is contained in:
Josh Hawkins 2026-02-02 08:34:46 -06:00
parent 5f262621c4
commit edc980ab8b
7 changed files with 41 additions and 9 deletions

View File

@ -26,6 +26,7 @@
"globalDetect": "Object Detection",
"globalRecording": "Recording",
"globalSnapshots": "Snapshots",
"globalFfmpeg": "FFmpeg",
"globalMotion": "Motion detection",
"globalObjects": "Objects",
"globalReview": "Review",

View File

@ -4,6 +4,12 @@ const detectors: SectionConfigOverrides = {
base: {
fieldOrder: [],
advancedFields: [],
hiddenFields: [
"*.model.labelmap",
"*.model.attributes_map",
"*.model",
"*.model_path",
],
},
};

View File

@ -7,6 +7,9 @@ const live: SectionConfigOverrides = {
hiddenFields: ["enabled_in_config"],
advancedFields: ["quality"],
},
global: {
hiddenFields: ["streams"],
},
};
export default live;

View File

@ -40,6 +40,9 @@ const objects: SectionConfigOverrides = {
suppressMultiSchema: true,
},
},
prompt: {
"ui:widget": "textarea",
},
required_zones: {
"ui:widget": "zoneNames",
"ui:options": {
@ -52,6 +55,9 @@ const objects: SectionConfigOverrides = {
},
},
},
global: {
hiddenFields: ["genai.required_zones"],
},
};
export default objects;

View File

@ -19,11 +19,8 @@ import { ConfigFormContext } from "@/types/configForm";
* provided by RJSF. This avoids ambiguity with underscores in field names and
* skips dynamic filter labels for per-object filter fields.
*/
function buildTranslationPath(path: Array<string | number>): string {
const segments = path.filter(
(segment): segment is string => typeof segment === "string",
);
function buildTranslationPath(segments: string[], sectionI18nPrefix?: string) {
// Example: filters.person.threshold -> filters.threshold or ov1.model -> model
const filtersIndex = segments.indexOf("filters");
if (filtersIndex !== -1 && segments.length > filtersIndex + 2) {
const normalized = [
@ -33,6 +30,22 @@ function buildTranslationPath(path: Array<string | number>): string {
return normalized.join(".");
}
// Example: detectors.ov1.type -> detectors.type
const detectorsIndex = segments.indexOf("detectors");
if (detectorsIndex !== -1 && segments.length > detectorsIndex + 2) {
const normalized = [
...segments.slice(0, detectorsIndex + 1),
...segments.slice(detectorsIndex + 2),
];
return normalized.join(".");
}
// If we are in the detectors section but 'detectors' is not in the path (specialized section)
// then the first segment is the dynamic detector name.
if (sectionI18nPrefix === "detectors" && segments.length > 1) {
return segments.slice(1).join(".");
}
return segments.join(".");
}
@ -130,7 +143,7 @@ export function FieldTemplate(props: FieldTemplateProps) {
const pathSegments = fieldPathId.path.filter(
(segment): segment is string => typeof segment === "string",
);
const translationPath = buildTranslationPath(pathSegments);
const translationPath = buildTranslationPath(pathSegments, sectionI18nPrefix);
const filterObjectLabel = getFilterObjectLabel(pathSegments);
const translatedFilterObjectLabel = filterObjectLabel
? getTranslatedLabel(filterObjectLabel, "object")

View File

@ -63,7 +63,7 @@ export function WrapIfAdditionalTemplate<
className={cn("grid grid-cols-12 items-start gap-2", classNames)}
style={style}
>
<div className="col-span-12 space-y-2 md:col-span-5">
<div className="col-span-12 space-y-2 md:col-span-1">
{displayLabel && <Label htmlFor={keyId}>{keyLabel}</Label>}
<Input
id={keyId}
@ -75,11 +75,11 @@ export function WrapIfAdditionalTemplate<
onBlur={!readonly ? onKeyRenameBlur : undefined}
/>
</div>
<div className="col-span-12 space-y-2 md:col-span-6">
<div className="col-span-12 space-y-2 md:col-span-10">
{displayLabel && <Label htmlFor={id}>{valueLabel}</Label>}
<div className="min-w-0">{children}</div>
</div>
<div className="col-span-12 flex items-center md:col-span-1 md:justify-end">
<div className="col-span-12 flex items-center md:col-span-1 md:justify-center">
<Button
type="button"
variant="ghost"

View File

@ -86,6 +86,7 @@ const allSettingsViews = [
"globalDetect",
"globalRecording",
"globalSnapshots",
"globalFfmpeg",
"globalMotion",
"globalObjects",
"globalReview",
@ -163,6 +164,7 @@ const createSectionPage = (
const GlobalDetectSettingsPage = createSectionPage("detect", "global");
const GlobalRecordingSettingsPage = createSectionPage("record", "global");
const GlobalSnapshotsSettingsPage = createSectionPage("snapshots", "global");
const GlobalFfmpegSettingsPage = createSectionPage("ffmpeg", "global");
const GlobalMotionSettingsPage = createSectionPage("motion", "global");
const GlobalObjectsSettingsPage = createSectionPage("objects", "global");
const GlobalReviewSettingsPage = createSectionPage("review", "global");
@ -264,6 +266,7 @@ const settingsGroups = [
{ key: "globalDetect", component: GlobalDetectSettingsPage },
{ key: "globalRecording", component: GlobalRecordingSettingsPage },
{ key: "globalSnapshots", component: GlobalSnapshotsSettingsPage },
{ key: "globalFfmpeg", component: GlobalFfmpegSettingsPage },
{ key: "globalMotion", component: GlobalMotionSettingsPage },
{ key: "globalObjects", component: GlobalObjectsSettingsPage },
{ key: "globalReview", component: GlobalReviewSettingsPage },