Skip to content

Commit

Permalink
Add capability to link directly to an event ID in the web UI (#7803)
Browse files Browse the repository at this point in the history
* Add capability to link directly to an event ID in the web UI

* Move event ID to searchParams, add View All button

* Use searchParams inside eventsFetcher
  • Loading branch information
hoverduck authored Sep 21, 2023
1 parent 4a65795 commit c743dfd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions web/src/routes/Events.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default function Events({ path, ...props }) {
zones: props.zones ?? 'all',
sub_labels: props.sub_labels ?? 'all',
favorites: props.favorites ?? 0,
event: props.event,
});
const [state, setState] = useState({
showDownloadMenu: false,
Expand All @@ -69,7 +70,7 @@ export default function Events({ path, ...props }) {
validBox: null,
});
const [uploading, setUploading] = useState([]);
const [viewEvent, setViewEvent] = useState();
const [viewEvent, setViewEvent] = useState(props.event);
const [eventOverlay, setEventOverlay] = useState();
const [eventDetailType, setEventDetailType] = useState('clip');
const [downloadEvent, setDownloadEvent] = useState({
Expand All @@ -87,9 +88,13 @@ export default function Events({ path, ...props }) {
});

const eventsFetcher = useCallback((path, params) => {
if (searchParams.event) {
path = `${path}/${searchParams.event}`;
return axios.get(path).then((res) => [res.data]);
}
params = { ...params, include_thumbnails: 0, limit: API_LIMIT };
return axios.get(path, { params }).then((res) => res.data);
}, []);
}, [searchParams]);

const getKey = useCallback(
(index, prevData) => {
Expand Down Expand Up @@ -355,6 +360,11 @@ export default function Events({ path, ...props }) {
onSelectSingle={(item) => onFilter('sub_labels', item)}
/>
)}
{searchParams.event && (
<Button className="ml-2" onClick={() => onFilter('event',null)} type="text">
View All
</Button>
)}

<StarRecording
className="h-10 w-10 text-yellow-300 cursor-pointer ml-auto"
Expand Down

0 comments on commit c743dfd

Please sign in to comment.