From 1c6c340c4d60abf9328a168562977010b7a8ab84 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Sun, 10 Nov 2024 16:41:59 -0600 Subject: [PATCH] add submitted filter to dialog --- .../overlay/dialog/SearchFilterDialog.tsx | 114 ++++++++++++++++-- 1 file changed, 104 insertions(+), 10 deletions(-) diff --git a/web/src/components/overlay/dialog/SearchFilterDialog.tsx b/web/src/components/overlay/dialog/SearchFilterDialog.tsx index 42ac74327..df293dbe1 100644 --- a/web/src/components/overlay/dialog/SearchFilterDialog.tsx +++ b/web/src/components/overlay/dialog/SearchFilterDialog.tsx @@ -119,6 +119,7 @@ export default function SearchFilterDialog({ } /> + submittedToFrigatePlus={ + currentFilter.is_submitted !== undefined + ? currentFilter.is_submitted === 1 + : undefined + } + setSnapshotClip={(snapshot, clip, submitted) => setCurrentFilter({ ...currentFilter, has_snapshot: snapshot !== undefined ? (snapshot ? 1 : 0) : undefined, has_clip: clip !== undefined ? (clip ? 1 : 0) : undefined, + is_submitted: + submitted !== undefined ? (submitted ? 1 : 0) : undefined, }) } /> @@ -508,17 +516,22 @@ export function ScoreFilterContent({ } type SnapshotClipContentProps = { + config?: FrigateConfig; hasSnapshot: boolean | undefined; hasClip: boolean | undefined; + submittedToFrigatePlus: boolean | undefined; setSnapshotClip: ( snapshot: boolean | undefined, clip: boolean | undefined, + submittedToFrigate: boolean | undefined, ) => void; }; -function SnapshotClipFilterContent({ +export function SnapshotClipFilterContent({ + config, hasSnapshot, hasClip, + submittedToFrigatePlus, setSnapshotClip, }: SnapshotClipContentProps) { const [isSnapshotFilterActive, setIsSnapshotFilterActive] = useState( @@ -527,6 +540,11 @@ function SnapshotClipFilterContent({ const [isClipFilterActive, setIsClipFilterActive] = useState( hasClip !== undefined, ); + const [isFrigatePlusFilterActive, setIsFrigatePlusFilterActive] = useState( + submittedToFrigatePlus !== undefined && + isSnapshotFilterActive && + hasSnapshot === true, + ); useEffect(() => { setIsSnapshotFilterActive(hasSnapshot !== undefined); @@ -536,6 +554,14 @@ function SnapshotClipFilterContent({ setIsClipFilterActive(hasClip !== undefined); }, [hasClip]); + useEffect(() => { + setIsFrigatePlusFilterActive( + submittedToFrigatePlus !== undefined && + isSnapshotFilterActive && + hasSnapshot === true, + ); + }, [submittedToFrigatePlus, isSnapshotFilterActive, hasSnapshot]); + return (
@@ -551,9 +577,9 @@ function SnapshotClipFilterContent({ onCheckedChange={(checked) => { setIsSnapshotFilterActive(checked as boolean); if (checked) { - setSnapshotClip(true, hasClip); + setSnapshotClip(true, hasClip, submittedToFrigatePlus); } else { - setSnapshotClip(undefined, hasClip); + setSnapshotClip(undefined, hasClip, undefined); } }} /> @@ -570,8 +596,10 @@ function SnapshotClipFilterContent({ hasSnapshot === undefined ? undefined : hasSnapshot ? "yes" : "no" } onValueChange={(value) => { - if (value === "yes") setSnapshotClip(true, hasClip); - else if (value === "no") setSnapshotClip(false, hasClip); + if (value === "yes") + setSnapshotClip(true, hasClip, submittedToFrigatePlus); + else if (value === "no") + setSnapshotClip(false, hasClip, undefined); }} disabled={!isSnapshotFilterActive} > @@ -592,6 +620,66 @@ function SnapshotClipFilterContent({
+ {config?.plus?.enabled && ( +
+
+ { + setIsFrigatePlusFilterActive(checked as boolean); + if (checked) { + setSnapshotClip(hasSnapshot, hasClip, true); + } else { + setSnapshotClip(hasSnapshot, hasClip, undefined); + } + }} + /> + +
+ { + if (value === "yes") + setSnapshotClip(hasSnapshot, hasClip, true); + else if (value === "no") + setSnapshotClip(hasSnapshot, hasClip, false); + else setSnapshotClip(hasSnapshot, hasClip, undefined); + }} + disabled={!isFrigatePlusFilterActive} + > + + Yes + + + No + + +
+ )} +
{ setIsClipFilterActive(checked as boolean); if (checked) { - setSnapshotClip(hasSnapshot, true); + setSnapshotClip(hasSnapshot, true, submittedToFrigatePlus); } else { - setSnapshotClip(hasSnapshot, undefined); + setSnapshotClip( + hasSnapshot, + undefined, + submittedToFrigatePlus, + ); } }} /> @@ -618,8 +710,10 @@ function SnapshotClipFilterContent({ type="single" value={hasClip === undefined ? undefined : hasClip ? "yes" : "no"} onValueChange={(value) => { - if (value === "yes") setSnapshotClip(hasSnapshot, true); - else if (value === "no") setSnapshotClip(hasSnapshot, false); + if (value === "yes") + setSnapshotClip(hasSnapshot, true, submittedToFrigatePlus); + else if (value === "no") + setSnapshotClip(hasSnapshot, false, submittedToFrigatePlus); }} disabled={!isClipFilterActive} >