mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-07-27 14:19:01 +03:00
Compare commits
8
Commits
dev
...
3bc1ae2f77
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3bc1ae2f77 | ||
|
|
389ee73ad0 | ||
|
|
9d023a8c97 | ||
|
|
689f580d1a | ||
|
|
c6b355bd7c | ||
|
|
ba9a30e5c9 | ||
|
|
01d861aad6 | ||
|
|
077f4a601a |
@@ -125,5 +125,5 @@
|
|||||||
"baby": "Baby",
|
"baby": "Baby",
|
||||||
"baby_stroller": "Baby Stroller",
|
"baby_stroller": "Baby Stroller",
|
||||||
"rickshaw": "Rickshaw",
|
"rickshaw": "Rickshaw",
|
||||||
"Rodent": "Rodent"
|
"rodent": "Rodent"
|
||||||
}
|
}
|
||||||
@@ -41,19 +41,12 @@ const ffmpeg: SectionConfigOverrides = {
|
|||||||
"input_args",
|
"input_args",
|
||||||
"hwaccel_args",
|
"hwaccel_args",
|
||||||
"output_args",
|
"output_args",
|
||||||
"path",
|
|
||||||
"retry_interval",
|
|
||||||
"apple_compatibility",
|
|
||||||
"gpu",
|
|
||||||
],
|
|
||||||
hiddenFields: [],
|
|
||||||
advancedFields: [
|
|
||||||
"path",
|
|
||||||
"global_args",
|
|
||||||
"retry_interval",
|
|
||||||
"apple_compatibility",
|
"apple_compatibility",
|
||||||
|
"path",
|
||||||
"gpu",
|
"gpu",
|
||||||
],
|
],
|
||||||
|
hiddenFields: ["retry_interval"],
|
||||||
|
advancedFields: ["path", "global_args", "gpu"],
|
||||||
overrideFields: [
|
overrideFields: [
|
||||||
"inputs",
|
"inputs",
|
||||||
"path",
|
"path",
|
||||||
@@ -61,7 +54,6 @@ const ffmpeg: SectionConfigOverrides = {
|
|||||||
"input_args",
|
"input_args",
|
||||||
"hwaccel_args",
|
"hwaccel_args",
|
||||||
"output_args",
|
"output_args",
|
||||||
"retry_interval",
|
|
||||||
"apple_compatibility",
|
"apple_compatibility",
|
||||||
"gpu",
|
"gpu",
|
||||||
],
|
],
|
||||||
@@ -125,19 +117,10 @@ const ffmpeg: SectionConfigOverrides = {
|
|||||||
"global_args",
|
"global_args",
|
||||||
"input_args",
|
"input_args",
|
||||||
"output_args",
|
"output_args",
|
||||||
"retry_interval",
|
|
||||||
"apple_compatibility",
|
|
||||||
"gpu",
|
|
||||||
],
|
|
||||||
advancedFields: [
|
|
||||||
"global_args",
|
|
||||||
"input_args",
|
|
||||||
"output_args",
|
|
||||||
"path",
|
|
||||||
"retry_interval",
|
|
||||||
"apple_compatibility",
|
"apple_compatibility",
|
||||||
"gpu",
|
"gpu",
|
||||||
],
|
],
|
||||||
|
advancedFields: ["global_args", "input_args", "output_args", "path", "gpu"],
|
||||||
uiSchema: {
|
uiSchema: {
|
||||||
path: {
|
path: {
|
||||||
"ui:options": { size: "md" },
|
"ui:options": { size: "md" },
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ import Heading from "@/components/ui/heading";
|
|||||||
import get from "lodash/get";
|
import get from "lodash/get";
|
||||||
import cloneDeep from "lodash/cloneDeep";
|
import cloneDeep from "lodash/cloneDeep";
|
||||||
import isEqual from "lodash/isEqual";
|
import isEqual from "lodash/isEqual";
|
||||||
import merge from "lodash/merge";
|
|
||||||
import {
|
import {
|
||||||
Collapsible,
|
Collapsible,
|
||||||
CollapsibleContent,
|
CollapsibleContent,
|
||||||
@@ -73,6 +72,7 @@ import {
|
|||||||
buildConfigDataForPath,
|
buildConfigDataForPath,
|
||||||
flattenOverrides,
|
flattenOverrides,
|
||||||
getBaseCameraSectionValue,
|
getBaseCameraSectionValue,
|
||||||
|
mergeProfileOverrides,
|
||||||
resolveHiddenFieldEntries,
|
resolveHiddenFieldEntries,
|
||||||
sanitizeSectionData as sharedSanitizeSectionData,
|
sanitizeSectionData as sharedSanitizeSectionData,
|
||||||
requiresRestartForOverrides as sharedRequiresRestartForOverrides,
|
requiresRestartForOverrides as sharedRequiresRestartForOverrides,
|
||||||
@@ -353,7 +353,10 @@ export function ConfigSection({
|
|||||||
`profiles.${profileName}.${sectionPath}`,
|
`profiles.${profileName}.${sectionPath}`,
|
||||||
);
|
);
|
||||||
if (profileOverrides && typeof profileOverrides === "object") {
|
if (profileOverrides && typeof profileOverrides === "object") {
|
||||||
return merge(cloneDeep(baseValue ?? {}), cloneDeep(profileOverrides));
|
return mergeProfileOverrides(
|
||||||
|
(baseValue as object) ?? {},
|
||||||
|
profileOverrides as object,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return baseValue;
|
return baseValue;
|
||||||
}
|
}
|
||||||
@@ -1044,6 +1047,7 @@ export function ConfigSection({
|
|||||||
hiddenFields: effectiveHiddenFields,
|
hiddenFields: effectiveHiddenFields,
|
||||||
restartRequired: sectionConfig.restartRequired,
|
restartRequired: sectionConfig.restartRequired,
|
||||||
requiresRestart,
|
requiresRestart,
|
||||||
|
isProfile: !!profileName,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { getWidget } from "@rjsf/utils";
|
|||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { getNonNullSchema } from "../fields/nullableUtils";
|
import { getNonNullSchema } from "../fields/nullableUtils";
|
||||||
|
import type { ConfigFormContext } from "@/types/configForm";
|
||||||
|
|
||||||
export function OptionalFieldWidget(props: WidgetProps) {
|
export function OptionalFieldWidget(props: WidgetProps) {
|
||||||
const { id, value, disabled, readonly, onChange, schema, options, registry } =
|
const { id, value, disabled, readonly, onChange, schema, options, registry } =
|
||||||
@@ -13,6 +14,8 @@ export function OptionalFieldWidget(props: WidgetProps) {
|
|||||||
|
|
||||||
const innerWidgetName = (options.innerWidget as string) || undefined;
|
const innerWidgetName = (options.innerWidget as string) || undefined;
|
||||||
const isEnabled = value !== undefined && value !== null;
|
const isEnabled = value !== undefined && value !== null;
|
||||||
|
const formContext = registry?.formContext as ConfigFormContext | undefined;
|
||||||
|
const isProfile = !!formContext?.isProfile;
|
||||||
|
|
||||||
// Extract the non-null branch from anyOf [Type, null]
|
// Extract the non-null branch from anyOf [Type, null]
|
||||||
const innerSchema = getNonNullSchema(schema) ?? schema;
|
const innerSchema = getNonNullSchema(schema) ?? schema;
|
||||||
@@ -42,10 +45,17 @@ export function OptionalFieldWidget(props: WidgetProps) {
|
|||||||
const innerProps: WidgetProps = {
|
const innerProps: WidgetProps = {
|
||||||
...props,
|
...props,
|
||||||
schema: innerSchema,
|
schema: innerSchema,
|
||||||
disabled: disabled || readonly || !isEnabled,
|
disabled: disabled || readonly || (!isProfile && !isEnabled),
|
||||||
value: isEnabled ? value : getDefaultValue(),
|
value: isEnabled ? value : getDefaultValue(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// don't show the switch if we're editing in a profile
|
||||||
|
// to disable in a profile, users should edit the config manually, eg:
|
||||||
|
// skip_motion_threshold: None
|
||||||
|
if (isProfile) {
|
||||||
|
return <InnerWidget {...innerProps} />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<Switch
|
<Switch
|
||||||
|
|||||||
@@ -102,6 +102,19 @@ export default function ClassificationSelectionDialog({
|
|||||||
// control
|
// control
|
||||||
const [newClass, setNewClass] = useState(false);
|
const [newClass, setNewClass] = useState(false);
|
||||||
|
|
||||||
|
// Non-modal Radix DropdownMenu doesn't propagate wheel events to nested
|
||||||
|
// scroll containers, so attach a non-passive listener that scrolls manually.
|
||||||
|
const scrollContainerRef = useCallback((el: HTMLDivElement | null) => {
|
||||||
|
if (!el || !isDesktop) return;
|
||||||
|
const handleWheel = (e: WheelEvent) => {
|
||||||
|
if (el.scrollHeight <= el.clientHeight) return;
|
||||||
|
e.preventDefault();
|
||||||
|
el.scrollTop += e.deltaY;
|
||||||
|
};
|
||||||
|
el.addEventListener("wheel", handleWheel, { passive: false });
|
||||||
|
return () => el.removeEventListener("wheel", handleWheel);
|
||||||
|
}, []);
|
||||||
|
|
||||||
// components
|
// components
|
||||||
const Selector = isDesktop ? DropdownMenu : Drawer;
|
const Selector = isDesktop ? DropdownMenu : Drawer;
|
||||||
const SelectorTrigger = isDesktop ? DropdownMenuTrigger : DrawerTrigger;
|
const SelectorTrigger = isDesktop ? DropdownMenuTrigger : DrawerTrigger;
|
||||||
@@ -114,6 +127,8 @@ export default function ClassificationSelectionDialog({
|
|||||||
</DrawerClose>
|
</DrawerClose>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// keep modal false on desktop to prevent dismissable layer pointer events
|
||||||
|
// issue with dialog auto-close
|
||||||
return (
|
return (
|
||||||
<div className={className ?? "flex"}>
|
<div className={className ?? "flex"}>
|
||||||
<TextEntryDialog
|
<TextEntryDialog
|
||||||
@@ -122,60 +137,60 @@ export default function ClassificationSelectionDialog({
|
|||||||
title={t("createCategory.new")}
|
title={t("createCategory.new")}
|
||||||
onSave={(newCat) => onCategorizeImage(newCat)}
|
onSave={(newCat) => onCategorizeImage(newCat)}
|
||||||
/>
|
/>
|
||||||
|
<Selector {...(isDesktop ? { modal: false } : {})}>
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<Selector {...(isDesktop ? { modal: false } : {})}>
|
<TooltipTrigger asChild={isChildButton}>
|
||||||
<SelectorTrigger asChild>
|
<SelectorTrigger asChild>{children}</SelectorTrigger>
|
||||||
<TooltipTrigger asChild={isChildButton}>{children}</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
</SelectorTrigger>
|
<TooltipContent>
|
||||||
<SelectorContent
|
{tooltipLabel ?? t("categorizeImage")}
|
||||||
className={cn("", isMobile && "mx-1 gap-2 rounded-t-2xl px-4")}
|
</TooltipContent>
|
||||||
onCloseAutoFocus={(e) => e.preventDefault()}
|
</Tooltip>
|
||||||
>
|
<SelectorContent
|
||||||
{isMobile && (
|
ref={scrollContainerRef}
|
||||||
<DrawerHeader className="sr-only">
|
className={cn(
|
||||||
<DrawerTitle>Details</DrawerTitle>
|
isDesktop && "scrollbar-container max-h-[40dvh] overflow-y-auto",
|
||||||
<DrawerDescription>Details</DrawerDescription>
|
isMobile && "mx-1 gap-2 rounded-t-2xl px-4",
|
||||||
</DrawerHeader>
|
)}
|
||||||
)}
|
onCloseAutoFocus={(e) => e.preventDefault()}
|
||||||
<DropdownMenuLabel>
|
>
|
||||||
{dialogLabel ?? t("categorizeImageAs")}
|
{isMobile && (
|
||||||
</DropdownMenuLabel>
|
<DrawerHeader className="sr-only">
|
||||||
<div
|
<DrawerTitle>Details</DrawerTitle>
|
||||||
className={cn(
|
<DrawerDescription>Details</DrawerDescription>
|
||||||
"flex max-h-[40dvh] flex-col overflow-y-auto",
|
</DrawerHeader>
|
||||||
isMobile && "gap-2 pb-4",
|
)}
|
||||||
)}
|
<DropdownMenuLabel>
|
||||||
|
{dialogLabel ?? t("categorizeImageAs")}
|
||||||
|
</DropdownMenuLabel>
|
||||||
|
<div className={cn("flex flex-col", isMobile && "gap-2 pb-4")}>
|
||||||
|
{filteredClasses
|
||||||
|
.sort((a, b) => {
|
||||||
|
if (a === "none") return 1;
|
||||||
|
if (b === "none") return -1;
|
||||||
|
return a.localeCompare(b);
|
||||||
|
})
|
||||||
|
.map((category) => (
|
||||||
|
<SelectorItem
|
||||||
|
key={category}
|
||||||
|
className="flex cursor-pointer gap-2 smart-capitalize"
|
||||||
|
onClick={() => onCategorizeImage(category)}
|
||||||
|
>
|
||||||
|
{category === "none"
|
||||||
|
? t("details.none")
|
||||||
|
: category.replaceAll("_", " ")}
|
||||||
|
</SelectorItem>
|
||||||
|
))}
|
||||||
|
<Separator />
|
||||||
|
<SelectorItem
|
||||||
|
className="flex cursor-pointer gap-2 smart-capitalize"
|
||||||
|
onClick={() => setNewClass(true)}
|
||||||
>
|
>
|
||||||
{filteredClasses
|
{t("createCategory.new")}
|
||||||
.sort((a, b) => {
|
</SelectorItem>
|
||||||
if (a === "none") return 1;
|
</div>
|
||||||
if (b === "none") return -1;
|
</SelectorContent>
|
||||||
return a.localeCompare(b);
|
</Selector>
|
||||||
})
|
|
||||||
.map((category) => (
|
|
||||||
<SelectorItem
|
|
||||||
key={category}
|
|
||||||
className="flex cursor-pointer gap-2 smart-capitalize"
|
|
||||||
onClick={() => onCategorizeImage(category)}
|
|
||||||
>
|
|
||||||
{category === "none"
|
|
||||||
? t("details.none")
|
|
||||||
: category.replaceAll("_", " ")}
|
|
||||||
</SelectorItem>
|
|
||||||
))}
|
|
||||||
<Separator />
|
|
||||||
<SelectorItem
|
|
||||||
className="flex cursor-pointer gap-2 smart-capitalize"
|
|
||||||
onClick={() => setNewClass(true)}
|
|
||||||
>
|
|
||||||
{t("createCategory.new")}
|
|
||||||
</SelectorItem>
|
|
||||||
</div>
|
|
||||||
</SelectorContent>
|
|
||||||
</Selector>
|
|
||||||
<TooltipContent>{tooltipLabel ?? t("categorizeImage")}</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import {
|
|||||||
import { isDesktop, isMobile } from "react-device-detect";
|
import { isDesktop, isMobile } from "react-device-detect";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import React, { ReactNode, useMemo, useState } from "react";
|
import React, { ReactNode, useCallback, useMemo, useState } from "react";
|
||||||
import TextEntryDialog from "./dialog/TextEntryDialog";
|
import TextEntryDialog from "./dialog/TextEntryDialog";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
|
|
||||||
@@ -61,6 +61,19 @@ export default function FaceSelectionDialog({
|
|||||||
// control
|
// control
|
||||||
const [newFace, setNewFace] = useState(false);
|
const [newFace, setNewFace] = useState(false);
|
||||||
|
|
||||||
|
// Non-modal Radix DropdownMenu doesn't propagate wheel events to nested
|
||||||
|
// scroll containers, so attach a non-passive listener that scrolls manually.
|
||||||
|
const scrollContainerRef = useCallback((el: HTMLDivElement | null) => {
|
||||||
|
if (!el || !isDesktop) return;
|
||||||
|
const handleWheel = (e: WheelEvent) => {
|
||||||
|
if (el.scrollHeight <= el.clientHeight) return;
|
||||||
|
e.preventDefault();
|
||||||
|
el.scrollTop += e.deltaY;
|
||||||
|
};
|
||||||
|
el.addEventListener("wheel", handleWheel, { passive: false });
|
||||||
|
return () => el.removeEventListener("wheel", handleWheel);
|
||||||
|
}, []);
|
||||||
|
|
||||||
// components
|
// components
|
||||||
const Selector = isDesktop ? DropdownMenu : Drawer;
|
const Selector = isDesktop ? DropdownMenu : Drawer;
|
||||||
const SelectorTrigger = isDesktop ? DropdownMenuTrigger : DrawerTrigger;
|
const SelectorTrigger = isDesktop ? DropdownMenuTrigger : DrawerTrigger;
|
||||||
@@ -73,6 +86,8 @@ export default function FaceSelectionDialog({
|
|||||||
</DrawerClose>
|
</DrawerClose>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// keep modal false on desktop to prevent dismissable layer pointer events
|
||||||
|
// issue with dialog auto-close
|
||||||
return (
|
return (
|
||||||
<div className={className ?? "flex"}>
|
<div className={className ?? "flex"}>
|
||||||
{newFace && (
|
{newFace && (
|
||||||
@@ -83,52 +98,56 @@ export default function FaceSelectionDialog({
|
|||||||
onSave={(newName) => onTrainAttempt(newName)}
|
onSave={(newName) => onTrainAttempt(newName)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
<Selector {...(isDesktop ? { modal: false } : {})}>
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<Selector {...(isDesktop ? { modal: false } : {})}>
|
<TooltipTrigger asChild={isChildButton}>
|
||||||
<SelectorTrigger asChild>
|
<SelectorTrigger asChild>{children}</SelectorTrigger>
|
||||||
<TooltipTrigger asChild={isChildButton}>{children}</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
</SelectorTrigger>
|
<TooltipContent>{tooltipLabel ?? t("trainFace")}</TooltipContent>
|
||||||
<SelectorContent
|
</Tooltip>
|
||||||
className={cn("", isMobile && "mx-1 gap-2 rounded-t-2xl px-4")}
|
<SelectorContent
|
||||||
onCloseAutoFocus={(e) => e.preventDefault()}
|
ref={scrollContainerRef}
|
||||||
>
|
className={cn(
|
||||||
{isMobile && (
|
isDesktop && "scrollbar-container max-h-[40dvh] overflow-y-auto",
|
||||||
<DrawerHeader className="sr-only">
|
isMobile && "mx-1 gap-2 rounded-t-2xl px-4",
|
||||||
<DrawerTitle>Details</DrawerTitle>
|
)}
|
||||||
<DrawerDescription>Details</DrawerDescription>
|
onCloseAutoFocus={(e) => e.preventDefault()}
|
||||||
</DrawerHeader>
|
>
|
||||||
|
{isMobile && (
|
||||||
|
<DrawerHeader className="sr-only">
|
||||||
|
<DrawerTitle>Details</DrawerTitle>
|
||||||
|
<DrawerDescription>Details</DrawerDescription>
|
||||||
|
</DrawerHeader>
|
||||||
|
)}
|
||||||
|
<DropdownMenuLabel>
|
||||||
|
{dialogLabel ?? t("trainFaceAs")}
|
||||||
|
</DropdownMenuLabel>
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"flex flex-col",
|
||||||
|
isMobile &&
|
||||||
|
"max-h-[40dvh] gap-2 overflow-y-auto overflow-x-hidden pb-4",
|
||||||
)}
|
)}
|
||||||
<DropdownMenuLabel>
|
>
|
||||||
{dialogLabel ?? t("trainFaceAs")}
|
{filteredNames.sort().map((faceName) => (
|
||||||
</DropdownMenuLabel>
|
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
"flex max-h-[40dvh] flex-col overflow-y-auto overflow-x-hidden",
|
|
||||||
isMobile && "gap-2 pb-4",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{filteredNames.sort().map((faceName) => (
|
|
||||||
<SelectorItem
|
|
||||||
key={faceName}
|
|
||||||
className="flex cursor-pointer gap-2 smart-capitalize"
|
|
||||||
onClick={() => onTrainAttempt(faceName)}
|
|
||||||
>
|
|
||||||
{faceName}
|
|
||||||
</SelectorItem>
|
|
||||||
))}
|
|
||||||
<DropdownMenuSeparator />
|
|
||||||
<SelectorItem
|
<SelectorItem
|
||||||
|
key={faceName}
|
||||||
className="flex cursor-pointer gap-2 smart-capitalize"
|
className="flex cursor-pointer gap-2 smart-capitalize"
|
||||||
onClick={() => setNewFace(true)}
|
onClick={() => onTrainAttempt(faceName)}
|
||||||
>
|
>
|
||||||
{t("createFaceLibrary.new")}
|
{faceName}
|
||||||
</SelectorItem>
|
</SelectorItem>
|
||||||
</div>
|
))}
|
||||||
</SelectorContent>
|
<DropdownMenuSeparator />
|
||||||
</Selector>
|
<SelectorItem
|
||||||
<TooltipContent>{tooltipLabel ?? t("trainFace")}</TooltipContent>
|
className="flex cursor-pointer gap-2 smart-capitalize"
|
||||||
</Tooltip>
|
onClick={() => setNewFace(true)}
|
||||||
|
>
|
||||||
|
{t("createFaceLibrary.new")}
|
||||||
|
</SelectorItem>
|
||||||
|
</div>
|
||||||
|
</SelectorContent>
|
||||||
|
</Selector>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,4 +44,5 @@ export type ConfigFormContext = {
|
|||||||
requiresRestart?: boolean;
|
requiresRestart?: boolean;
|
||||||
t?: (key: string, options?: Record<string, unknown>) => string;
|
t?: (key: string, options?: Record<string, unknown>) => string;
|
||||||
renderers?: Record<string, RendererComponent>;
|
renderers?: Record<string, RendererComponent>;
|
||||||
|
isProfile?: boolean;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
import get from "lodash/get";
|
import get from "lodash/get";
|
||||||
import cloneDeep from "lodash/cloneDeep";
|
import cloneDeep from "lodash/cloneDeep";
|
||||||
import merge from "lodash/merge";
|
|
||||||
import unset from "lodash/unset";
|
import unset from "lodash/unset";
|
||||||
import isEqual from "lodash/isEqual";
|
import isEqual from "lodash/isEqual";
|
||||||
import mergeWith from "lodash/mergeWith";
|
import mergeWith from "lodash/mergeWith";
|
||||||
@@ -92,6 +91,32 @@ export function getBaseCameraSectionValue(
|
|||||||
return base !== undefined ? base : get(cam, sectionPath);
|
return base !== undefined ? base : get(cam, sectionPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mergeWith customizer that replaces arrays wholesale instead of merging them
|
||||||
|
// positionally by index. Used when the source value is meant to fully replace
|
||||||
|
// the destination (e.g. profile overrides, section config overrides), so an
|
||||||
|
// empty source array correctly clears the destination array.
|
||||||
|
const replaceArraysCustomizer = (objValue: unknown, srcValue: unknown) => {
|
||||||
|
if (Array.isArray(objValue) || Array.isArray(srcValue)) {
|
||||||
|
return srcValue !== undefined ? srcValue : objValue;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Merge profile overrides on top of base config values. Matches the backend's
|
||||||
|
// deep_merge(overrides, base_data) semantics: arrays are replaced wholesale by
|
||||||
|
// the profile's value rather than merged positionally, so an empty array in a
|
||||||
|
// profile clears the base array instead of leaving stale entries behind.
|
||||||
|
export function mergeProfileOverrides<T extends object>(
|
||||||
|
baseValue: T,
|
||||||
|
profileOverrides: object,
|
||||||
|
): T {
|
||||||
|
return mergeWith(
|
||||||
|
cloneDeep(baseValue),
|
||||||
|
cloneDeep(profileOverrides),
|
||||||
|
replaceArraysCustomizer,
|
||||||
|
) as T;
|
||||||
|
}
|
||||||
|
|
||||||
/** Sections that can appear inside a camera profile definition. */
|
/** Sections that can appear inside a camera profile definition. */
|
||||||
export const PROFILE_ELIGIBLE_SECTIONS = new Set([
|
export const PROFILE_ELIGIBLE_SECTIONS = new Set([
|
||||||
"audio",
|
"audio",
|
||||||
@@ -564,9 +589,9 @@ export function prepareSectionSavePayload(opts: {
|
|||||||
baseValue &&
|
baseValue &&
|
||||||
typeof baseValue === "object"
|
typeof baseValue === "object"
|
||||||
) {
|
) {
|
||||||
rawSectionValue = merge(
|
rawSectionValue = mergeProfileOverrides(
|
||||||
cloneDeep(baseValue),
|
baseValue as object,
|
||||||
cloneDeep(profileOverrides),
|
profileOverrides as object,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
rawSectionValue = baseValue;
|
rawSectionValue = baseValue;
|
||||||
@@ -675,13 +700,12 @@ const mergeSectionConfig = (
|
|||||||
overrides: Partial<SectionConfig> | undefined,
|
overrides: Partial<SectionConfig> | undefined,
|
||||||
): SectionConfig =>
|
): SectionConfig =>
|
||||||
mergeWith({}, base ?? {}, overrides ?? {}, (objValue, srcValue, key) => {
|
mergeWith({}, base ?? {}, overrides ?? {}, (objValue, srcValue, key) => {
|
||||||
if (Array.isArray(objValue) || Array.isArray(srcValue)) {
|
const arrayResult = replaceArraysCustomizer(objValue, srcValue);
|
||||||
return srcValue ?? objValue;
|
if (arrayResult !== undefined) return arrayResult;
|
||||||
}
|
|
||||||
|
|
||||||
if (key === "uiSchema") {
|
if (key === "uiSchema") {
|
||||||
if (objValue && srcValue) {
|
if (objValue && srcValue) {
|
||||||
return merge({}, objValue, srcValue);
|
return mergeWith({}, objValue, srcValue, replaceArraysCustomizer);
|
||||||
}
|
}
|
||||||
return srcValue ?? objValue;
|
return srcValue ?? objValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import { getTranslatedLabel } from "@/utils/i18n";
|
|||||||
import { useCameraFriendlyName } from "@/hooks/use-camera-friendly-name";
|
import { useCameraFriendlyName } from "@/hooks/use-camera-friendly-name";
|
||||||
import { AudioLevelGraph } from "@/components/audio/AudioLevelGraph";
|
import { AudioLevelGraph } from "@/components/audio/AudioLevelGraph";
|
||||||
import { useWs } from "@/api/ws";
|
import { useWs } from "@/api/ws";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
type ObjectSettingsViewProps = {
|
type ObjectSettingsViewProps = {
|
||||||
selectedCamera?: string;
|
selectedCamera?: string;
|
||||||
@@ -200,15 +201,18 @@ export default function ObjectSettingsView({
|
|||||||
|
|
||||||
<Tabs defaultValue="debug" className="w-full">
|
<Tabs defaultValue="debug" className="w-full">
|
||||||
<TabsList
|
<TabsList
|
||||||
className={`grid w-full ${cameraConfig.ffmpeg.inputs.some((input) => input.roles.includes("audio")) ? "grid-cols-3" : "grid-cols-2"}`}
|
className={cn(
|
||||||
|
"grid w-full",
|
||||||
|
cameraConfig.audio.enabled_in_config
|
||||||
|
? "grid-cols-3"
|
||||||
|
: "grid-cols-2",
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
<TabsTrigger value="debug">{t("debug.debugging")}</TabsTrigger>
|
<TabsTrigger value="debug">{t("debug.debugging")}</TabsTrigger>
|
||||||
<TabsTrigger value="objectlist">
|
<TabsTrigger value="objectlist">
|
||||||
{t("debug.objectList")}
|
{t("debug.objectList")}
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
{cameraConfig.ffmpeg.inputs.some((input) =>
|
{cameraConfig.audio.enabled_in_config && (
|
||||||
input.roles.includes("audio"),
|
|
||||||
) && (
|
|
||||||
<TabsTrigger value="audio">{t("debug.audio.title")}</TabsTrigger>
|
<TabsTrigger value="audio">{t("debug.audio.title")}</TabsTrigger>
|
||||||
)}
|
)}
|
||||||
</TabsList>
|
</TabsList>
|
||||||
@@ -325,9 +329,7 @@ export default function ObjectSettingsView({
|
|||||||
<TabsContent value="objectlist">
|
<TabsContent value="objectlist">
|
||||||
<ObjectList cameraConfig={cameraConfig} objects={memoizedObjects} />
|
<ObjectList cameraConfig={cameraConfig} objects={memoizedObjects} />
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
{cameraConfig.ffmpeg.inputs.some((input) =>
|
{cameraConfig.audio.enabled_in_config && (
|
||||||
input.roles.includes("audio"),
|
|
||||||
) && (
|
|
||||||
<TabsContent value="audio">
|
<TabsContent value="audio">
|
||||||
<AudioList
|
<AudioList
|
||||||
cameraConfig={cameraConfig}
|
cameraConfig={cameraConfig}
|
||||||
|
|||||||
Reference in New Issue
Block a user