mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-01-02 00:07:11 +01:00
Filtering on Frigate+ submits in frontend (#8344)
* Initial draft for filtering Frigate+ submits in frontend
* Hide filter when Frigate+ is not enabled
* Update http.py
* Revert "Update http.py"
This reverts commit fa292682d6
.
This commit is contained in:
parent
8b6e3a0d37
commit
8b6b83bd62
@ -946,7 +946,7 @@ def events():
|
|||||||
if is_submitted is not None:
|
if is_submitted is not None:
|
||||||
if is_submitted == 0:
|
if is_submitted == 0:
|
||||||
clauses.append((Event.plus_id.is_null()))
|
clauses.append((Event.plus_id.is_null()))
|
||||||
else:
|
elif is_submitted > 0:
|
||||||
clauses.append((Event.plus_id != ""))
|
clauses.append((Event.plus_id != ""))
|
||||||
|
|
||||||
if len(clauses) == 0:
|
if len(clauses) == 0:
|
||||||
|
19
web/src/icons/Submitted.jsx
Normal file
19
web/src/icons/Submitted.jsx
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { h } from 'preact';
|
||||||
|
import { memo } from 'preact/compat';
|
||||||
|
|
||||||
|
export function Submitted({ className = 'h-6 w-6', inner_fill = 'none', outer_stroke = 'currentColor', onClick = () => {} }) {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
className={className}
|
||||||
|
viewBox="0 0 32 32"
|
||||||
|
onClick={onClick}
|
||||||
|
>
|
||||||
|
<rect x="10" y="15" fill={inner_fill} width="12" height="2"/>
|
||||||
|
<rect x="15" y="10" fill={inner_fill} width="2" height="12"/>
|
||||||
|
<circle fill="none" stroke={outer_stroke} stroke-width="2" stroke-miterlimit="10" cx="16" cy="16" r="12"/>
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default memo(Submitted);
|
@ -11,6 +11,7 @@ import axios from 'axios';
|
|||||||
import { useState, useRef, useCallback, useMemo } from 'preact/hooks';
|
import { useState, useRef, useCallback, useMemo } from 'preact/hooks';
|
||||||
import VideoPlayer from '../components/VideoPlayer';
|
import VideoPlayer from '../components/VideoPlayer';
|
||||||
import { StarRecording } from '../icons/StarRecording';
|
import { StarRecording } from '../icons/StarRecording';
|
||||||
|
import { Submitted } from '../icons/Submitted';
|
||||||
import { Snapshot } from '../icons/Snapshot';
|
import { Snapshot } from '../icons/Snapshot';
|
||||||
import { UploadPlus } from '../icons/UploadPlus';
|
import { UploadPlus } from '../icons/UploadPlus';
|
||||||
import { Clip } from '../icons/Clip';
|
import { Clip } from '../icons/Clip';
|
||||||
@ -63,6 +64,7 @@ export default function Events({ path, ...props }) {
|
|||||||
time_range: '00:00,24:00',
|
time_range: '00:00,24:00',
|
||||||
timezone,
|
timezone,
|
||||||
favorites: props.favorites ?? 0,
|
favorites: props.favorites ?? 0,
|
||||||
|
is_submitted: props.is_submitted ?? -1,
|
||||||
event: props.event,
|
event: props.event,
|
||||||
});
|
});
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
@ -281,6 +283,16 @@ export default function Events({ path, ...props }) {
|
|||||||
[path, searchParams, setSearchParams]
|
[path, searchParams, setSearchParams]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const onClickFilterSubmitted = useCallback(
|
||||||
|
() => {
|
||||||
|
if( ++searchParams.is_submitted > 1 ) {
|
||||||
|
searchParams.is_submitted = -1;
|
||||||
|
}
|
||||||
|
onFilter('is_submitted', searchParams.is_submitted);
|
||||||
|
},
|
||||||
|
[searchParams, onFilter]
|
||||||
|
);
|
||||||
|
|
||||||
const isDone = (eventPages?.[eventPages.length - 1]?.length ?? 0) < API_LIMIT;
|
const isDone = (eventPages?.[eventPages.length - 1]?.length ?? 0) < API_LIMIT;
|
||||||
|
|
||||||
// hooks for infinite scroll
|
// hooks for infinite scroll
|
||||||
@ -394,11 +406,22 @@ export default function Events({ path, ...props }) {
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<StarRecording
|
<div className="ml-auto flex">
|
||||||
className="h-10 w-10 text-yellow-300 cursor-pointer ml-auto"
|
{config.plus.enabled && (
|
||||||
onClick={() => onFilter('favorites', searchParams.favorites ? 0 : 1)}
|
<Submitted
|
||||||
fill={searchParams.favorites == 1 ? 'currentColor' : 'none'}
|
className="h-10 w-10 text-yellow-300 cursor-pointer ml-auto"
|
||||||
/>
|
onClick={() => onClickFilterSubmitted()}
|
||||||
|
inner_fill={searchParams.is_submitted == 1 ? 'currentColor' : 'gray'}
|
||||||
|
outer_stroke={searchParams.is_submitted >= 0 ? 'currentColor' : 'gray'}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<StarRecording
|
||||||
|
className="h-10 w-10 text-yellow-300 cursor-pointer ml-auto"
|
||||||
|
onClick={() => onFilter('favorites', searchParams.favorites ? 0 : 1)}
|
||||||
|
fill={searchParams.favorites == 1 ? 'currentColor' : 'none'}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div ref={datePicker} className="ml-right">
|
<div ref={datePicker} className="ml-right">
|
||||||
<CalendarIcon
|
<CalendarIcon
|
||||||
|
Loading…
Reference in New Issue
Block a user