Skip to content

Commit

Permalink
Fix webUI success / error messages (#7820)
Browse files Browse the repository at this point in the history
* Fix export error handling

* Ensure that config editor success / error is updated each time

* Set response

* Formatting
  • Loading branch information
NickM-27 authored Sep 16, 2023
1 parent 9185753 commit b9e6afa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion frigate/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,12 @@ def export_recording(camera_name: str, start_time, end_time):
)

if recordings_count <= 0:
return "No recordings found for time range", 400
return make_response(
jsonify(
{"success": False, "message": "No recordings found for time range"}
),
400,
)

exporter = RecordingExporter(
current_app.frigate_config,
Expand Down
3 changes: 3 additions & 0 deletions web/src/routes/Config.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ export default function Config() {
})
.then((response) => {
if (response.status === 200) {
setError('');
setSuccess(response.data);
}
})
.catch((error) => {
setSuccess('');

if (error.response) {
setError(error.response.data.message);
} else {
Expand Down
2 changes: 1 addition & 1 deletion web/src/routes/Export.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function Export() {
}
})
.catch((error) => {
if (error.response) {
if (error.response?.data?.message) {
setMessage({ text: `Failed to start export: ${error.response.data.message}`, error: true });
} else {
setMessage({ text: `Failed to start export: ${error.message}`, error: true });
Expand Down

0 comments on commit b9e6afa

Please sign in to comment.