mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-23 00:28:22 +03:00
don't save model config back to yaml when saving detectors
This commit is contained in:
parent
19acfe0f7c
commit
d1422f295b
@ -10,7 +10,6 @@ const detectorHiddenFields = [
|
|||||||
const detectors: SectionConfigOverrides = {
|
const detectors: SectionConfigOverrides = {
|
||||||
base: {
|
base: {
|
||||||
sectionDocs: "/configuration/object_detectors",
|
sectionDocs: "/configuration/object_detectors",
|
||||||
restartRequired: [],
|
|
||||||
fieldOrder: [],
|
fieldOrder: [],
|
||||||
advancedFields: [],
|
advancedFields: [],
|
||||||
hiddenFields: detectorHiddenFields,
|
hiddenFields: detectorHiddenFields,
|
||||||
|
|||||||
@ -146,5 +146,26 @@ export function sanitizeOverridesForSection(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// detectors: Strip readonly model fields that are generated on startup
|
||||||
|
// and should never be persisted back to the config file.
|
||||||
|
if (sectionPath === "detectors") {
|
||||||
|
const overridesObj = overrides as JsonObject;
|
||||||
|
const cleaned: JsonObject = {};
|
||||||
|
|
||||||
|
Object.entries(overridesObj).forEach(([key, value]) => {
|
||||||
|
if (!isJsonObject(value)) {
|
||||||
|
cleaned[key] = value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cleanedValue = { ...value } as JsonObject;
|
||||||
|
delete cleanedValue.model;
|
||||||
|
delete cleanedValue.model_path;
|
||||||
|
cleaned[key] = cleanedValue;
|
||||||
|
});
|
||||||
|
|
||||||
|
return cleaned;
|
||||||
|
}
|
||||||
|
|
||||||
return overrides;
|
return overrides;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import type {
|
|||||||
UiSchema,
|
UiSchema,
|
||||||
} from "@rjsf/utils";
|
} from "@rjsf/utils";
|
||||||
import { toFieldPathId } from "@rjsf/utils";
|
import { toFieldPathId } from "@rjsf/utils";
|
||||||
|
import { cloneDeep, set as lodashSet } from "lodash";
|
||||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import {
|
import {
|
||||||
@ -297,8 +298,8 @@ export function DetectorHardwareField(props: FieldProps) {
|
|||||||
}, [detectors]);
|
}, [detectors]);
|
||||||
|
|
||||||
const updateDetectors = useCallback(
|
const updateDetectors = useCallback(
|
||||||
(nextDetectors: JsonObject) => {
|
(nextDetectors: JsonObject, path?: FieldPathList) => {
|
||||||
onChange(nextDetectors as unknown, [] as FieldPathList);
|
onChange(nextDetectors as unknown, path ?? ([] as FieldPathList));
|
||||||
},
|
},
|
||||||
[onChange],
|
[onChange],
|
||||||
);
|
);
|
||||||
@ -562,14 +563,12 @@ export function DetectorHardwareField(props: FieldProps) {
|
|||||||
|
|
||||||
const handleInstanceChange = (
|
const handleInstanceChange = (
|
||||||
nextValue: unknown,
|
nextValue: unknown,
|
||||||
_path: FieldPathList,
|
path: FieldPathList,
|
||||||
_errors?: ErrorSchema,
|
_errors?: ErrorSchema,
|
||||||
_id?: string,
|
_id?: string,
|
||||||
) => {
|
) => {
|
||||||
const nextDetectors = {
|
const nextDetectors = cloneDeep(detectors);
|
||||||
...detectors,
|
lodashSet(nextDetectors, path, nextValue);
|
||||||
[key]: nextValue ?? {},
|
|
||||||
} as JsonObject;
|
|
||||||
updateDetectors(nextDetectors);
|
updateDetectors(nextDetectors);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user