NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Ensure sub label is null when submitting an empty string (#16779)
Josh Hawkins1d8f1bd7ae7b
diff --git a/frigate/api/event.py b/frigate/api/event.pyindex 2df32471e8..bb1bf7395b 100644--- a/frigate/api/event.py+++ b/frigate/api/event.py@@ -991,6 +991,10 @@ def set_sub_label(new_sub_label = body.subLabelnew_score = body.subLabelScore+ if new_sub_label == "":+ new_sub_label = None+ new_score = None+if tracked_obj:tracked_obj.obj_data["sub_label"] = (new_sub_label, new_score)@@ -1001,21 +1005,19 @@ def set_sub_label(if event:event.sub_label = new_sub_label-- if new_score:- data = event.data+ data = event.data+ if new_sub_label is None:+ data["sub_label_score"] = None+ elif new_score is not None:data["sub_label_score"] = new_score- event.data = data-+ event.data = dataevent.save()return JSONResponse(- content=(- {- "success": True,- "message": "Event " + event_id + " sub label set to " + new_sub_label,- }- ),+ content={+ "success": True,+ "message": f"Event {event_id} sub label set to {new_sub_label if new_sub_label is not None else 'None'}",+ },status_code=200,)diff --git a/frigate/test/test_http.py b/frigate/test/test_http.pyindex 8c89e04338..46de1307f4 100644--- a/frigate/test/test_http.py+++ b/frigate/test/test_http.py@@ -275,7 +275,7 @@ class TestHttp(unittest.TestCase):event = client.get(f"/events/{id}").json()assert eventassert event["id"] == id- assert event["sub_label"] == ""+ assert event["sub_label"] == Nonedef test_sub_label_list(self):app = create_fastapi_app(diff --git a/web/src/components/overlay/dialog/TextEntryDialog.tsx b/web/src/components/overlay/dialog/TextEntryDialog.tsxindex d7b90aabb4..c11a84ae76 100644--- a/web/src/components/overlay/dialog/TextEntryDialog.tsx+++ b/web/src/components/overlay/dialog/TextEntryDialog.tsx@@ -86,7 +86,9 @@ export default function TextEntryDialog({)}/><DialogFooter className="pt-4">- <Button onClick={() => setOpen(false)}>Cancel</Button>+ <Button type="button" onClick={() => setOpen(false)}>+ Cancel+ </Button><Button variant="select" type="submit">Save</Button>