diff --git a/frigate/api/app.py b/frigate/api/app.py index f4f513e14..0064758aa 100644 --- a/frigate/api/app.py +++ b/frigate/api/app.py @@ -159,9 +159,9 @@ def config(): config["plus"] = {"enabled": current_app.plus_api.is_active()} for detector, detector_config in config["detectors"].items(): - detector_config["model"]["labelmap"] = ( - current_app.frigate_config.model.merged_labelmap - ) + detector_config["model"][ + "labelmap" + ] = current_app.frigate_config.model.merged_labelmap return jsonify(config) @@ -292,7 +292,7 @@ def config_set(): f.close() # Validate the config schema try: - FrigateConfig.parse_raw(new_raw_config) + config_obj = FrigateConfig.parse_raw(new_raw_config) except Exception: with open(config_file, "w") as f: f.write(old_raw_config) @@ -314,6 +314,13 @@ def config_set(): 500, ) + json = request.get_json(silent=True) or {} + + if json.get("requires_restart", 1) == 0: + current_app.frigate_config = FrigateConfig.runtime_config( + config_obj, current_app.plus_api + ) + return make_response( jsonify( { diff --git a/frigate/util/builtin.py b/frigate/util/builtin.py index 30388251d..aa009aa04 100644 --- a/frigate/util/builtin.py +++ b/frigate/util/builtin.py @@ -204,17 +204,22 @@ def update_yaml_from_url(file_path, url): key_path.pop(i - 1) except ValueError: pass - new_value = new_value_list[0] - update_yaml_file(file_path, key_path, new_value) + + if len(new_value_list) > 1: + update_yaml_file(file_path, key_path, new_value_list) + else: + update_yaml_file(file_path, key_path, new_value_list[0]) def update_yaml_file(file_path, key_path, new_value): yaml = YAML() + yaml.indent(mapping=2, sequence=4, offset=2) with open(file_path, "r") as f: data = yaml.load(f) data = update_yaml(data, key_path, new_value) - + with open("/config/test.yaml", "w") as f: + yaml.dump(data, f) with open(file_path, "w") as f: yaml.dump(data, f) diff --git a/web/src/components/filter/CameraGroupSelector.tsx b/web/src/components/filter/CameraGroupSelector.tsx index f737598c1..5ed50be7c 100644 --- a/web/src/components/filter/CameraGroupSelector.tsx +++ b/web/src/components/filter/CameraGroupSelector.tsx @@ -19,6 +19,7 @@ import { DropdownMenuTrigger, } from "../ui/dropdown-menu"; import FilterCheckBox from "./FilterCheckBox"; +import axios from "axios"; type CameraGroupSelectorProps = { className?: string; @@ -68,7 +69,11 @@ export function CameraGroupSelector({ className }: CameraGroupSelectorProps) {