mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-06 19:25:22 +03:00
Cleanup
This commit is contained in:
parent
7185e877ef
commit
a997638934
@ -238,7 +238,14 @@ class TestHttp(unittest.TestCase):
|
|||||||
|
|
||||||
def test_event_time_filtering(self):
|
def test_event_time_filtering(self):
|
||||||
app = create_app(
|
app = create_app(
|
||||||
FrigateConfig(**self.minimal_config), self.db, None, None, None
|
FrigateConfig(**self.minimal_config),
|
||||||
|
self.db,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
PlusApi(),
|
||||||
)
|
)
|
||||||
morning_id = "123456.random"
|
morning_id = "123456.random"
|
||||||
evening_id = "654321.random"
|
evening_id = "654321.random"
|
||||||
|
|||||||
@ -49,7 +49,7 @@ const monthsAgo = (num) => {
|
|||||||
export default function Events({ path, ...props }) {
|
export default function Events({ path, ...props }) {
|
||||||
const apiHost = useApiHost();
|
const apiHost = useApiHost();
|
||||||
const { data: config } = useSWR('config');
|
const { data: config } = useSWR('config');
|
||||||
const timezone = useMemo(() => config.ui?.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone, [config]);
|
const timezone = useMemo(() => config?.ui?.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone, [config]);
|
||||||
const [searchParams, setSearchParams] = useState({
|
const [searchParams, setSearchParams] = useState({
|
||||||
before: null,
|
before: null,
|
||||||
after: null,
|
after: null,
|
||||||
@ -100,7 +100,7 @@ export default function Events({ path, ...props }) {
|
|||||||
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);
|
||||||
},
|
},
|
||||||
[searchParams],
|
[searchParams]
|
||||||
);
|
);
|
||||||
|
|
||||||
const getKey = useCallback(
|
const getKey = useCallback(
|
||||||
@ -113,7 +113,7 @@ export default function Events({ path, ...props }) {
|
|||||||
|
|
||||||
return ['events', searchParams];
|
return ['events', searchParams];
|
||||||
},
|
},
|
||||||
[searchParams],
|
[searchParams]
|
||||||
);
|
);
|
||||||
|
|
||||||
const { data: eventPages, mutate, size, setSize, isValidating } = useSWRInfinite(getKey, eventsFetcher);
|
const { data: eventPages, mutate, size, setSize, isValidating } = useSWRInfinite(getKey, eventsFetcher);
|
||||||
@ -136,7 +136,7 @@ export default function Events({ path, ...props }) {
|
|||||||
labels: Object.values(allLabels || {}),
|
labels: Object.values(allLabels || {}),
|
||||||
sub_labels: (allSubLabels || []).length > 0 ? [...Object.values(allSubLabels), 'None'] : [],
|
sub_labels: (allSubLabels || []).length > 0 ? [...Object.values(allSubLabels), 'None'] : [],
|
||||||
}),
|
}),
|
||||||
[config, allLabels, allSubLabels],
|
[config, allLabels, allSubLabels]
|
||||||
);
|
);
|
||||||
|
|
||||||
const onSave = async (e, eventId, save) => {
|
const onSave = async (e, eventId, save) => {
|
||||||
@ -241,14 +241,14 @@ export default function Events({ path, ...props }) {
|
|||||||
setSearchParams({ ...searchParams, before: dates.before, after: dates.after });
|
setSearchParams({ ...searchParams, before: dates.before, after: dates.after });
|
||||||
setState({ ...state, showDatePicker: false });
|
setState({ ...state, showDatePicker: false });
|
||||||
},
|
},
|
||||||
[searchParams, setSearchParams, state, setState],
|
[searchParams, setSearchParams, state, setState]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleSelectTimeRange = useCallback(
|
const handleSelectTimeRange = useCallback(
|
||||||
(timeRange) => {
|
(timeRange) => {
|
||||||
setSearchParams({ ...searchParams, time_range: timeRange });
|
setSearchParams({ ...searchParams, time_range: timeRange });
|
||||||
},
|
},
|
||||||
[searchParams],
|
[searchParams]
|
||||||
);
|
);
|
||||||
|
|
||||||
const onFilter = useCallback(
|
const onFilter = useCallback(
|
||||||
@ -266,7 +266,7 @@ export default function Events({ path, ...props }) {
|
|||||||
.join('&');
|
.join('&');
|
||||||
route(`${path}?${queryString}`);
|
route(`${path}?${queryString}`);
|
||||||
},
|
},
|
||||||
[path, searchParams, setSearchParams],
|
[path, searchParams, setSearchParams]
|
||||||
);
|
);
|
||||||
|
|
||||||
const isDone = (eventPages?.[eventPages.length - 1]?.length ?? 0) < API_LIMIT;
|
const isDone = (eventPages?.[eventPages.length - 1]?.length ?? 0) < API_LIMIT;
|
||||||
@ -284,7 +284,7 @@ export default function Events({ path, ...props }) {
|
|||||||
});
|
});
|
||||||
if (node) observer.current.observe(node);
|
if (node) observer.current.observe(node);
|
||||||
},
|
},
|
||||||
[size, setSize, isValidating, isDone],
|
[size, setSize, isValidating, isDone]
|
||||||
);
|
);
|
||||||
|
|
||||||
const onSendToPlus = async (id, false_positive, validBox) => {
|
const onSendToPlus = async (id, false_positive, validBox) => {
|
||||||
@ -307,9 +307,9 @@ export default function Events({ path, ...props }) {
|
|||||||
return { ...event, plus_id: response.data.plus_id };
|
return { ...event, plus_id: response.data.plus_id };
|
||||||
}
|
}
|
||||||
return event;
|
return event;
|
||||||
}),
|
})
|
||||||
),
|
),
|
||||||
false,
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,13 +415,13 @@ export default function Events({ path, ...props }) {
|
|||||||
downloadEvent.end_time &&
|
downloadEvent.end_time &&
|
||||||
downloadEvent.has_snapshot &&
|
downloadEvent.has_snapshot &&
|
||||||
!downloadEvent.plus_id && (
|
!downloadEvent.plus_id && (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
icon={UploadPlus}
|
icon={UploadPlus}
|
||||||
label={uploading.includes(downloadEvent.id) ? 'Uploading...' : 'Send to Frigate+'}
|
label={uploading.includes(downloadEvent.id) ? 'Uploading...' : 'Send to Frigate+'}
|
||||||
value="plus"
|
value="plus"
|
||||||
onSelect={() => showSubmitToPlus(downloadEvent.id, downloadEvent.label, downloadEvent.box)}
|
onSelect={() => showSubmitToPlus(downloadEvent.id, downloadEvent.label, downloadEvent.box)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{downloadEvent.plus_id && (
|
{downloadEvent.plus_id && (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
icon={UploadPlus}
|
icon={UploadPlus}
|
||||||
@ -776,7 +776,7 @@ export default function Events({ path, ...props }) {
|
|||||||
: `${apiHost}/api/events/${event.id}/thumbnail.jpg`
|
: `${apiHost}/api/events/${event.id}/thumbnail.jpg`
|
||||||
}
|
}
|
||||||
alt={`${event.label} at ${((event?.data?.top_score || event.top_score) * 100).toFixed(
|
alt={`${event.label} at ${((event?.data?.top_score || event.top_score) * 100).toFixed(
|
||||||
0,
|
0
|
||||||
)}% confidence`}
|
)}% confidence`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user