[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
This commit is contained in:
spacebares 2022-12-18 22:26:54 -08:00
parent 368c07cc34
commit e1dab61ae7
2 changed files with 12 additions and 0 deletions

View File

@ -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))

View File

@ -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)}
/>
)}
<StarRecording
className="h-10 w-10 text-yellow-300 cursor-pointer"
onClick={() => onFilter("favorites", searchParams.favorites ? 0 : 1)}
fill={searchParams.favorites == 1 ? 'currentColor' : 'none'}
/>
<div ref={datePicker} className="ml-auto">
<CalendarIcon
className="h-8 w-8 cursor-pointer"