mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
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
This commit is contained in:
parent
621aa0cf61
commit
e39fb51dec
@ -710,6 +710,8 @@ def config_raw():
|
|||||||
|
|
||||||
@bp.route("/config/save", methods=["POST"])
|
@bp.route("/config/save", methods=["POST"])
|
||||||
def config_save():
|
def config_save():
|
||||||
|
save_option = request.args.get("save_option")
|
||||||
|
|
||||||
new_config = request.get_data().decode()
|
new_config = request.get_data().decode()
|
||||||
|
|
||||||
if not new_config:
|
if not new_config:
|
||||||
@ -753,6 +755,7 @@ def config_save():
|
|||||||
400,
|
400,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if save_option == "restart":
|
||||||
try:
|
try:
|
||||||
restart_frigate()
|
restart_frigate()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -760,6 +763,8 @@ def config_save():
|
|||||||
return "Config successfully saved, unable to restart Frigate", 200
|
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")
|
@bp.route("/config/schema.json")
|
||||||
|
@ -17,13 +17,13 @@ export default function Config() {
|
|||||||
const [success, setSuccess] = useState();
|
const [success, setSuccess] = useState();
|
||||||
const [error, setError] = useState();
|
const [error, setError] = useState();
|
||||||
|
|
||||||
const onHandleSaveConfig = async (e) => {
|
const onHandleSaveConfig = async (e, save_option) => {
|
||||||
if (e) {
|
if (e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
axios
|
axios
|
||||||
.post('config/save', window.editor.getValue(), {
|
.post(`config/save?save_option=${save_option}`, window.editor.getValue(), {
|
||||||
headers: { 'Content-Type': 'text/plain' },
|
headers: { 'Content-Type': 'text/plain' },
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
@ -97,9 +97,12 @@ export default function Config() {
|
|||||||
<Button className="mx-2" onClick={(e) => handleCopyConfig(e)}>
|
<Button className="mx-2" onClick={(e) => handleCopyConfig(e)}>
|
||||||
Copy Config
|
Copy Config
|
||||||
</Button>
|
</Button>
|
||||||
<Button className="mx-2" onClick={(e) => onHandleSaveConfig(e)}>
|
<Button className="mx-2" onClick={(e) => onHandleSaveConfig(e, "restart")}>
|
||||||
Save & Restart
|
Save & Restart
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button className="mx-2" onClick={(e) => onHandleSaveConfig(e, "saveonly")}>
|
||||||
|
Save Only
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user