mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-10 10:33:11 +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 = {
|
||||
base: {
|
||||
sectionDocs: "/configuration/object_detectors",
|
||||
restartRequired: [],
|
||||
fieldOrder: [],
|
||||
advancedFields: [],
|
||||
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;
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import type {
|
||||
UiSchema,
|
||||
} from "@rjsf/utils";
|
||||
import { toFieldPathId } from "@rjsf/utils";
|
||||
import { cloneDeep, set as lodashSet } from "lodash";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
@ -297,8 +298,8 @@ export function DetectorHardwareField(props: FieldProps) {
|
||||
}, [detectors]);
|
||||
|
||||
const updateDetectors = useCallback(
|
||||
(nextDetectors: JsonObject) => {
|
||||
onChange(nextDetectors as unknown, [] as FieldPathList);
|
||||
(nextDetectors: JsonObject, path?: FieldPathList) => {
|
||||
onChange(nextDetectors as unknown, path ?? ([] as FieldPathList));
|
||||
},
|
||||
[onChange],
|
||||
);
|
||||
@ -562,14 +563,12 @@ export function DetectorHardwareField(props: FieldProps) {
|
||||
|
||||
const handleInstanceChange = (
|
||||
nextValue: unknown,
|
||||
_path: FieldPathList,
|
||||
path: FieldPathList,
|
||||
_errors?: ErrorSchema,
|
||||
_id?: string,
|
||||
) => {
|
||||
const nextDetectors = {
|
||||
...detectors,
|
||||
[key]: nextValue ?? {},
|
||||
} as JsonObject;
|
||||
const nextDetectors = cloneDeep(detectors);
|
||||
lodashSet(nextDetectors, path, nextValue);
|
||||
updateDetectors(nextDetectors);
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user