mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-26 01:58:21 +03:00
tweaks
This commit is contained in:
parent
25aaa2d9f7
commit
42a594984d
@ -60,7 +60,7 @@ export function ConfigForm({
|
|||||||
advancedFields,
|
advancedFields,
|
||||||
disabled = false,
|
disabled = false,
|
||||||
readonly = false,
|
readonly = false,
|
||||||
showSubmit = true,
|
showSubmit = false,
|
||||||
className,
|
className,
|
||||||
liveValidate = true,
|
liveValidate = true,
|
||||||
formContext,
|
formContext,
|
||||||
|
|||||||
@ -21,6 +21,11 @@ export const AudioSection = createConfigSection({
|
|||||||
},
|
},
|
||||||
hiddenFields: ["enabled_in_config"],
|
hiddenFields: ["enabled_in_config"],
|
||||||
advancedFields: ["min_volume", "max_not_heard", "num_threads"],
|
advancedFields: ["min_volume", "max_not_heard", "num_threads"],
|
||||||
|
uiSchema: {
|
||||||
|
listen: {
|
||||||
|
"ui:widget": "audioLabels",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,12 @@ export const ObjectsSection = createConfigSection({
|
|||||||
tracking: ["track", "alert", "detect"],
|
tracking: ["track", "alert", "detect"],
|
||||||
filtering: ["filters"],
|
filtering: ["filters"],
|
||||||
},
|
},
|
||||||
hiddenFields: ["enabled_in_config", "mask", "raw_mask"],
|
hiddenFields: [
|
||||||
|
"enabled_in_config",
|
||||||
|
"mask",
|
||||||
|
"raw_mask",
|
||||||
|
"genai.enabled_in_config",
|
||||||
|
],
|
||||||
advancedFields: ["filters"],
|
advancedFields: ["filters"],
|
||||||
uiSchema: {
|
uiSchema: {
|
||||||
track: {
|
track: {
|
||||||
@ -34,6 +39,9 @@ export const ObjectsSection = createConfigSection({
|
|||||||
suppressMultiSchema: true,
|
suppressMultiSchema: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
enabled_in_config: {
|
||||||
|
"ui:widget": "hidden",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -21,7 +21,7 @@ export const RecordSection = createConfigSection({
|
|||||||
retention: ["continuous", "motion"],
|
retention: ["continuous", "motion"],
|
||||||
events: ["alerts", "detections"],
|
events: ["alerts", "detections"],
|
||||||
},
|
},
|
||||||
hiddenFields: ["enabled_in_config"],
|
hiddenFields: ["enabled_in_config", "sync_recordings"],
|
||||||
advancedFields: ["expire_interval", "preview", "export"],
|
advancedFields: ["expire_interval", "preview", "export"],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import { ColorWidget } from "./widgets/ColorWidget";
|
|||||||
import { TextareaWidget } from "./widgets/TextareaWidget";
|
import { TextareaWidget } from "./widgets/TextareaWidget";
|
||||||
import { SwitchesWidget } from "./widgets/SwitchesWidget";
|
import { SwitchesWidget } from "./widgets/SwitchesWidget";
|
||||||
import { ObjectLabelSwitchesWidget } from "./widgets/ObjectLabelSwitchesWidget";
|
import { ObjectLabelSwitchesWidget } from "./widgets/ObjectLabelSwitchesWidget";
|
||||||
|
import { AudioLabelSwitchesWidget } from "./widgets/AudioLabelSwitchesWidget";
|
||||||
import { ZoneSwitchesWidget } from "./widgets/ZoneSwitchesWidget";
|
import { ZoneSwitchesWidget } from "./widgets/ZoneSwitchesWidget";
|
||||||
|
|
||||||
import { FieldTemplate } from "./templates/FieldTemplate";
|
import { FieldTemplate } from "./templates/FieldTemplate";
|
||||||
@ -29,7 +30,6 @@ import { BaseInputTemplate } from "./templates/BaseInputTemplate";
|
|||||||
import { DescriptionFieldTemplate } from "./templates/DescriptionFieldTemplate";
|
import { DescriptionFieldTemplate } from "./templates/DescriptionFieldTemplate";
|
||||||
import { TitleFieldTemplate } from "./templates/TitleFieldTemplate";
|
import { TitleFieldTemplate } from "./templates/TitleFieldTemplate";
|
||||||
import { ErrorListTemplate } from "./templates/ErrorListTemplate";
|
import { ErrorListTemplate } from "./templates/ErrorListTemplate";
|
||||||
import { SubmitButton } from "./templates/SubmitButton";
|
|
||||||
import { MultiSchemaFieldTemplate } from "./templates/MultiSchemaFieldTemplate";
|
import { MultiSchemaFieldTemplate } from "./templates/MultiSchemaFieldTemplate";
|
||||||
|
|
||||||
export interface FrigateTheme {
|
export interface FrigateTheme {
|
||||||
@ -58,6 +58,7 @@ export const frigateTheme: FrigateTheme = {
|
|||||||
textarea: TextareaWidget,
|
textarea: TextareaWidget,
|
||||||
switches: SwitchesWidget,
|
switches: SwitchesWidget,
|
||||||
objectLabels: ObjectLabelSwitchesWidget,
|
objectLabels: ObjectLabelSwitchesWidget,
|
||||||
|
audioLabels: AudioLabelSwitchesWidget,
|
||||||
zoneNames: ZoneSwitchesWidget,
|
zoneNames: ZoneSwitchesWidget,
|
||||||
},
|
},
|
||||||
templates: {
|
templates: {
|
||||||
@ -72,7 +73,6 @@ export const frigateTheme: FrigateTheme = {
|
|||||||
MultiSchemaFieldTemplate: MultiSchemaFieldTemplate,
|
MultiSchemaFieldTemplate: MultiSchemaFieldTemplate,
|
||||||
ButtonTemplates: {
|
ButtonTemplates: {
|
||||||
...defaultRegistry.templates.ButtonTemplates,
|
...defaultRegistry.templates.ButtonTemplates,
|
||||||
SubmitButton: SubmitButton,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
fields: {
|
fields: {
|
||||||
|
|||||||
@ -1,27 +0,0 @@
|
|||||||
// Submit Button Template
|
|
||||||
import type { SubmitButtonProps } from "@rjsf/utils";
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { LuSave } from "react-icons/lu";
|
|
||||||
|
|
||||||
export function SubmitButton(props: SubmitButtonProps) {
|
|
||||||
const { uiSchema } = props;
|
|
||||||
const { t } = useTranslation(["common"]);
|
|
||||||
|
|
||||||
const shouldHide = uiSchema?.["ui:submitButtonOptions"]?.norender === true;
|
|
||||||
|
|
||||||
if (shouldHide) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const submitText =
|
|
||||||
(uiSchema?.["ui:options"]?.submitText as string) ||
|
|
||||||
t("save", { ns: "common" });
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Button type="submit" className="gap-2">
|
|
||||||
<LuSave className="h-4 w-4" />
|
|
||||||
{submitText}
|
|
||||||
</Button>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
// Object Label Switches Widget - For selecting objects via switches
|
||||||
|
import type { WidgetProps } from "@rjsf/utils";
|
||||||
|
import { SwitchesWidget } from "./SwitchesWidget";
|
||||||
|
import type { FormContext } from "./SwitchesWidget";
|
||||||
|
import { getTranslatedLabel } from "@/utils/i18n";
|
||||||
|
|
||||||
|
function getAudioLabels(context: FormContext): string[] {
|
||||||
|
let cameraLabels: string[] = [];
|
||||||
|
let globalLabels: string[] = [];
|
||||||
|
|
||||||
|
if (context) {
|
||||||
|
// context.cameraValue and context.globalValue should be the entire objects section
|
||||||
|
const trackValue = context.cameraValue?.listen;
|
||||||
|
if (Array.isArray(trackValue)) {
|
||||||
|
cameraLabels = trackValue.filter(
|
||||||
|
(item): item is string => typeof item === "string",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const globalTrackValue = context.globalValue?.listen;
|
||||||
|
if (Array.isArray(globalTrackValue)) {
|
||||||
|
globalLabels = globalTrackValue.filter(
|
||||||
|
(item): item is string => typeof item === "string",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const sourceLabels = cameraLabels.length > 0 ? cameraLabels : globalLabels;
|
||||||
|
return [...sourceLabels].sort();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAudioLabelDisplayName(label: string): string {
|
||||||
|
return getTranslatedLabel(label, "audio");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function AudioLabelSwitchesWidget(props: WidgetProps) {
|
||||||
|
return (
|
||||||
|
<SwitchesWidget
|
||||||
|
{...props}
|
||||||
|
options={{
|
||||||
|
...props.options,
|
||||||
|
getEntities: getAudioLabels,
|
||||||
|
getDisplayLabel: getAudioLabelDisplayName,
|
||||||
|
i18nKey: "audioLabels",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -14,7 +14,6 @@ import { MotionSection } from "@/components/config-form/sections/MotionSection";
|
|||||||
import { ObjectsSection } from "@/components/config-form/sections/ObjectsSection";
|
import { ObjectsSection } from "@/components/config-form/sections/ObjectsSection";
|
||||||
import { ReviewSection } from "@/components/config-form/sections/ReviewSection";
|
import { ReviewSection } from "@/components/config-form/sections/ReviewSection";
|
||||||
import { AudioSection } from "@/components/config-form/sections/AudioSection";
|
import { AudioSection } from "@/components/config-form/sections/AudioSection";
|
||||||
import { NotificationsSection } from "@/components/config-form/sections/NotificationsSection";
|
|
||||||
import { LiveSection } from "@/components/config-form/sections/LiveSection";
|
import { LiveSection } from "@/components/config-form/sections/LiveSection";
|
||||||
import { TimestampSection } from "@/components/config-form/sections/TimestampSection";
|
import { TimestampSection } from "@/components/config-form/sections/TimestampSection";
|
||||||
import type { RJSFSchema } from "@rjsf/utils";
|
import type { RJSFSchema } from "@rjsf/utils";
|
||||||
@ -46,11 +45,6 @@ const sharedSections = [
|
|||||||
},
|
},
|
||||||
{ key: "review", i18nNamespace: "config/review", component: ReviewSection },
|
{ key: "review", i18nNamespace: "config/review", component: ReviewSection },
|
||||||
{ key: "audio", i18nNamespace: "config/audio", component: AudioSection },
|
{ key: "audio", i18nNamespace: "config/audio", component: AudioSection },
|
||||||
{
|
|
||||||
key: "notifications",
|
|
||||||
i18nNamespace: "config/notifications",
|
|
||||||
component: NotificationsSection,
|
|
||||||
},
|
|
||||||
{ key: "live", i18nNamespace: "config/live", component: LiveSection },
|
{ key: "live", i18nNamespace: "config/live", component: LiveSection },
|
||||||
{
|
{
|
||||||
key: "timestamp_style",
|
key: "timestamp_style",
|
||||||
@ -127,7 +121,6 @@ const globalSectionConfigs: Record<
|
|||||||
"trusted_proxies",
|
"trusted_proxies",
|
||||||
"hash_iterations",
|
"hash_iterations",
|
||||||
"roles",
|
"roles",
|
||||||
"admin_first_time_login",
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
tls: {
|
tls: {
|
||||||
@ -330,21 +323,6 @@ const globalSectionConfigs: Record<
|
|||||||
fieldOrder: [],
|
fieldOrder: [],
|
||||||
advancedFields: [],
|
advancedFields: [],
|
||||||
},
|
},
|
||||||
camera_groups: {
|
|
||||||
i18nNamespace: "config/camera_groups",
|
|
||||||
fieldOrder: ["cameras", "icon", "order"],
|
|
||||||
advancedFields: [],
|
|
||||||
},
|
|
||||||
safe_mode: {
|
|
||||||
i18nNamespace: "config/safe_mode",
|
|
||||||
fieldOrder: [],
|
|
||||||
advancedFields: [],
|
|
||||||
},
|
|
||||||
version: {
|
|
||||||
i18nNamespace: "config/version",
|
|
||||||
fieldOrder: [],
|
|
||||||
advancedFields: [],
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// System sections (global only)
|
// System sections (global only)
|
||||||
@ -364,9 +342,6 @@ const systemSections = [
|
|||||||
"model",
|
"model",
|
||||||
"classification",
|
"classification",
|
||||||
"go2rtc",
|
"go2rtc",
|
||||||
"camera_groups",
|
|
||||||
"safe_mode",
|
|
||||||
"version",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// Integration sections (global only)
|
// Integration sections (global only)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user