From e1dab61ae7a7f98bb3bb6123dda73740ac7a477e Mon Sep 17 00:00:00 2001 From: spacebares <57186372+spacebares@users.noreply.github.com> Date: Sun, 18 Dec 2022 22:26:54 -0800 Subject: [PATCH] [API] filter for favorite events * Added /api/events filter for favorite (retain_indefinitely) events * New Star button to filter for favorite events on the Events page --- frigate/http.py | 4 ++++ web/src/routes/Events.jsx | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/frigate/http.py b/frigate/http.py index 901097679..c5bd1722a 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -565,6 +565,7 @@ def events(): has_clip = request.args.get("has_clip", type=int) has_snapshot = request.args.get("has_snapshot", type=int) include_thumbnails = request.args.get("include_thumbnails", default=1, type=int) + favorites = request.args.get("favorites", type=int) clauses = [] excluded_fields = [] @@ -634,6 +635,9 @@ def events(): excluded_fields.append(Event.thumbnail) else: selected_columns.append(Event.thumbnail) + + if favorites: + clauses.append((Event.retain_indefinitely == favorites)) if len(clauses) == 0: clauses.append((True)) diff --git a/web/src/routes/Events.jsx b/web/src/routes/Events.jsx index e8807411e..5c0b5581a 100644 --- a/web/src/routes/Events.jsx +++ b/web/src/routes/Events.jsx @@ -58,6 +58,7 @@ export default function Events({ path, ...props }) { labels: props.labels ?? 'all', zones: props.zones ?? 'all', sub_labels: props.sub_labels ?? 'all', + favorites: props.favorites ?? 0, }); const [state, setState] = useState({ showDownloadMenu: false, @@ -334,6 +335,13 @@ export default function Events({ path, ...props }) { onSelectSingle={(item) => onFilter("sub_labels", item)} /> )} + + onFilter("favorites", searchParams.favorites ? 0 : 1)} + fill={searchParams.favorites == 1 ? 'currentColor' : 'none'} + /> +