ensure update_topic is added to api calls

this needs further backend implementation to work correctly
This commit is contained in:
Josh Hawkins 2026-01-25 09:05:58 -06:00
parent 73ae2db1a5
commit 260237bf1a
2 changed files with 23 additions and 1 deletions

View File

@ -89,6 +89,17 @@ export function createConfigSection({
i18nNamespace, i18nNamespace,
defaultConfig, defaultConfig,
}: CreateSectionOptions) { }: CreateSectionOptions) {
const cameraUpdateTopicMap: Record<string, string> = {
detect: "detect",
record: "record",
snapshots: "snapshots",
motion: "motion",
objects: "objects",
review: "review",
audio: "audio",
notifications: "notifications",
};
const ConfigSection = function ConfigSection({ const ConfigSection = function ConfigSection({
level, level,
cameraName, cameraName,
@ -110,6 +121,13 @@ export function createConfigSection({
> | null>(null); > | null>(null);
const [isSaving, setIsSaving] = useState(false); const [isSaving, setIsSaving] = useState(false);
const updateTopic =
level === "camera" && cameraName
? cameraUpdateTopicMap[sectionPath]
? `config/cameras/${cameraName}/${cameraUpdateTopicMap[sectionPath]}`
: undefined
: `config/${sectionPath}`;
// Default: show title for camera level (since it might be collapsible), hide for global // Default: show title for camera level (since it might be collapsible), hide for global
const shouldShowTitle = showTitle ?? level === "camera"; const shouldShowTitle = showTitle ?? level === "camera";
@ -280,6 +298,7 @@ export function createConfigSection({
await axios.put("config/set", { await axios.put("config/set", {
requires_restart: requiresRestart ? 0 : 1, requires_restart: requiresRestart ? 0 : 1,
update_topic: updateTopic,
config_data: { config_data: {
[basePath]: overrides, [basePath]: overrides,
}, },
@ -345,6 +364,7 @@ export function createConfigSection({
sanitizeSectionData, sanitizeSectionData,
buildOverrides, buildOverrides,
schemaDefaults, schemaDefaults,
updateTopic,
]); ]);
// Handle reset to global - removes camera-level override by deleting the section // Handle reset to global - removes camera-level override by deleting the section
@ -357,6 +377,7 @@ export function createConfigSection({
// Send empty string to delete the key from config (see update_yaml in backend) // Send empty string to delete the key from config (see update_yaml in backend)
await axios.put("config/set", { await axios.put("config/set", {
requires_restart: requiresRestart ? 0 : 1, requires_restart: requiresRestart ? 0 : 1,
update_topic: updateTopic,
config_data: { config_data: {
[basePath]: "", [basePath]: "",
}, },
@ -379,7 +400,7 @@ export function createConfigSection({
}), }),
); );
} }
}, [level, cameraName, requiresRestart, t, refreshConfig]); }, [level, cameraName, requiresRestart, t, refreshConfig, updateTopic]);
if (!sectionSchema) { if (!sectionSchema) {
return null; return null;

View File

@ -215,6 +215,7 @@ const GlobalConfigSection = memo(function GlobalConfigSection({
setIsSaving(true); setIsSaving(true);
try { try {
await axios.put("config/set", { await axios.put("config/set", {
update_topic: `config/${sectionKey}`,
config_data: { config_data: {
[sectionKey]: pendingData, [sectionKey]: pendingData,
}, },