From e39fb51decc01918417b701e949e60892e8fd008 Mon Sep 17 00:00:00 2001
From: yeahme49 <58564160+yeahme49@users.noreply.github.com>
Date: Sun, 15 Jan 2023 11:25:49 -0600
Subject: [PATCH] Add Save Only button to config editor (#5090)
* Add Save Only button to save config without restarting
* Fixes
* fix formatting
* change to query parameter from header
* lint fixes
---
frigate/http.py | 17 +++++++++++------
web/src/routes/Config.jsx | 9 ++++++---
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/frigate/http.py b/frigate/http.py
index 1f4fb4e75..815c700cc 100644
--- a/frigate/http.py
+++ b/frigate/http.py
@@ -710,6 +710,8 @@ def config_raw():
@bp.route("/config/save", methods=["POST"])
def config_save():
+ save_option = request.args.get("save_option")
+
new_config = request.get_data().decode()
if not new_config:
@@ -753,13 +755,16 @@ def config_save():
400,
)
- try:
- restart_frigate()
- except Exception as e:
- logging.error(f"Error restarting Frigate: {e}")
- return "Config successfully saved, unable to restart Frigate", 200
+ if save_option == "restart":
+ try:
+ restart_frigate()
+ except Exception as e:
+ logging.error(f"Error restarting Frigate: {e}")
+ return "Config successfully saved, unable to restart Frigate", 200
- return "Config successfully saved, restarting...", 200
+ return "Config successfully saved, restarting...", 200
+ else:
+ return "Config successfully saved.", 200
@bp.route("/config/schema.json")
diff --git a/web/src/routes/Config.jsx b/web/src/routes/Config.jsx
index 590201d47..e043bbf28 100644
--- a/web/src/routes/Config.jsx
+++ b/web/src/routes/Config.jsx
@@ -17,13 +17,13 @@ export default function Config() {
const [success, setSuccess] = useState();
const [error, setError] = useState();
- const onHandleSaveConfig = async (e) => {
+ const onHandleSaveConfig = async (e, save_option) => {
if (e) {
e.stopPropagation();
}
axios
- .post('config/save', window.editor.getValue(), {
+ .post(`config/save?save_option=${save_option}`, window.editor.getValue(), {
headers: { 'Content-Type': 'text/plain' },
})
.then((response) => {
@@ -97,9 +97,12 @@ export default function Config() {
-