Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Save Only button to config editor #5090

Merged
merged 5 commits into from
Jan 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change to query parameter from header
  • Loading branch information
yeahme49 committed Jan 15, 2023
commit 176c3557207f2defad2ef40e962dc319cb69ec7e
2 changes: 1 addition & 1 deletion frigate/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ def config_raw():

@bp.route("/config/save", methods=["POST"])
def config_save():
save_option = request.headers.get("Save-Option")
save_option = request.args.get("save_option")

new_config = request.get_data().decode()

Expand Down
33 changes: 5 additions & 28 deletions web/src/routes/Config.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,14 @@ 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(), {
headers: { 'Content-Type': 'text/plain', 'Save-Option': 'restart' },
})
.then((response) => {
if (response.status === 200) {
setSuccess(response.data);
}
})
.catch((error) => {
if (error.response) {
setError(error.response.data.message);
} else {
setError(error.message);
}
});
};

const onHandleSaveConfigOnly = async (e) => {
if (e) {
e.stopPropagation();
}

axios
.post('config/save', window.editor.getValue(), {
headers: { 'Content-Type': 'text/plain', 'Save-Option': 'saveonly' },
.post('config/save?save_option='+save_option, window.editor.getValue(), {
headers: { 'Content-Type': 'text/plain' },
})
.then((response) => {
if (response.status === 200) {
Expand Down Expand Up @@ -120,10 +97,10 @@ export default function Config() {
<Button className="mx-2" onClick={(e) => handleCopyConfig(e)}>
Copy Config
</Button>
<Button className="mx-2" onClick={(e) => onHandleSaveConfig(e)}>
<Button className="mx-2" onClick={(e) => onHandleSaveConfig(e, "restart")}>
Save & Restart
</Button>
<Button className="mx-2" onClick={(e) => onHandleSaveConfigOnly(e)}>
<Button className="mx-2" onClick={(e) => onHandleSaveConfig(e, "saveonly")}>
Save Only
</Button>
</div>
Expand Down