Add capability to link directly to an event ID in the web UI

This commit is contained in:
Scott Stancil 2023-09-14 08:12:55 -04:00
parent 9185753322
commit 42fd2f282d

View File

@ -51,7 +51,7 @@ export default function Events({ path, ...props }) {
const [searchParams, setSearchParams] = useState({ const [searchParams, setSearchParams] = useState({
before: null, before: null,
after: null, after: null,
cameras: props.cameras ?? 'all', cameras: props.event ? '' : props.cameras ?? 'all',
labels: props.labels ?? 'all', labels: props.labels ?? 'all',
zones: props.zones ?? 'all', zones: props.zones ?? 'all',
sub_labels: props.sub_labels ?? 'all', sub_labels: props.sub_labels ?? 'all',
@ -69,7 +69,7 @@ export default function Events({ path, ...props }) {
validBox: null, validBox: null,
}); });
const [uploading, setUploading] = useState([]); const [uploading, setUploading] = useState([]);
const [viewEvent, setViewEvent] = useState(); const [viewEvent, setViewEvent] = useState(props.event);
const [eventOverlay, setEventOverlay] = useState(); const [eventOverlay, setEventOverlay] = useState();
const [eventDetailType, setEventDetailType] = useState('clip'); const [eventDetailType, setEventDetailType] = useState('clip');
const [downloadEvent, setDownloadEvent] = useState({ const [downloadEvent, setDownloadEvent] = useState({
@ -87,6 +87,10 @@ export default function Events({ path, ...props }) {
}); });
const eventsFetcher = useCallback((path, params) => { const eventsFetcher = useCallback((path, params) => {
if (props.event) {
path = `${path}/${props.event}`;
return axios.get(path).then((res) => [res.data]);
}
params = { ...params, include_thumbnails: 0, limit: API_LIMIT }; params = { ...params, include_thumbnails: 0, limit: API_LIMIT };
return axios.get(path, { params }).then((res) => res.data); return axios.get(path, { params }).then((res) => res.data);
}, []); }, []);