From ad87f5786e9f86baf806dd2c58a2b5f74850c3b0 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Sat, 4 May 2024 14:54:50 -0500 Subject: [PATCH] Misc UI fixes (#11237) * add close button to all toasters * check if persistent options are loaded * add id to prevent message duplication in bottom bar --- .../components/filter/CameraGroupSelector.tsx | 6 +++- web/src/components/settings/MasksAndZones.tsx | 9 ++++-- .../settings/MotionMaskEditPane.tsx | 2 +- web/src/components/settings/MotionTuner.tsx | 9 ++++-- .../settings/ObjectMaskEditPane.tsx | 2 +- .../components/settings/ObjectSettings.tsx | 29 ++++++++++--------- web/src/components/settings/PolygonItem.tsx | 2 +- web/src/components/settings/ZoneEditPane.tsx | 2 +- web/src/components/ui/sonner.tsx | 2 ++ web/src/pages/ConfigEditor.tsx | 2 +- web/src/pages/Logs.tsx | 2 +- web/src/views/events/EventView.tsx | 2 +- web/src/views/events/RecordingView.tsx | 2 +- 13 files changed, 45 insertions(+), 26 deletions(-) diff --git a/web/src/components/filter/CameraGroupSelector.tsx b/web/src/components/filter/CameraGroupSelector.tsx index 3b9b3e20f..d67fea65a 100644 --- a/web/src/components/filter/CameraGroupSelector.tsx +++ b/web/src/components/filter/CameraGroupSelector.tsx @@ -273,7 +273,11 @@ function NewGroupDialog({ return ( <> - + { diff --git a/web/src/components/settings/MasksAndZones.tsx b/web/src/components/settings/MasksAndZones.tsx index 2679cf5ca..66eb33952 100644 --- a/web/src/components/settings/MasksAndZones.tsx +++ b/web/src/components/settings/MasksAndZones.tsx @@ -178,7 +178,12 @@ export default function MasksAndZones({ setAllPolygons([...(editingPolygons ?? [])]); setHoveredPolygonIndex(null); setUnsavedChanges(false); - addMessage("masks_zones", "Restart required (masks/zones changed)"); + addMessage( + "masks_zones", + "Restart required (masks/zones changed)", + undefined, + "masks_zones", + ); }, [editingPolygons, setUnsavedChanges, addMessage]); useEffect(() => { @@ -366,7 +371,7 @@ export default function MasksAndZones({ <> {cameraConfig && editingPolygons && (
- +
{editPane == "zone" && ( - + {polygon.name.length ? "Edit" : "New"} Motion Mask diff --git a/web/src/components/settings/MotionTuner.tsx b/web/src/components/settings/MotionTuner.tsx index badaa75a4..b837e7ab6 100644 --- a/web/src/components/settings/MotionTuner.tsx +++ b/web/src/components/settings/MotionTuner.tsx @@ -153,7 +153,12 @@ export default function MotionTuner({ useEffect(() => { if (changedValue) { - addMessage("motion_tuner", "Unsaved motion tuner changes"); + addMessage( + "motion_tuner", + "Unsaved motion tuner changes", + undefined, + "motion_tuner", + ); } else { clearMessages("motion_tuner"); } @@ -169,7 +174,7 @@ export default function MotionTuner({ return (
- +
Motion Detection Tuner diff --git a/web/src/components/settings/ObjectMaskEditPane.tsx b/web/src/components/settings/ObjectMaskEditPane.tsx index c95b17bae..d97297b98 100644 --- a/web/src/components/settings/ObjectMaskEditPane.tsx +++ b/web/src/components/settings/ObjectMaskEditPane.tsx @@ -245,7 +245,7 @@ export default function ObjectMaskEditPane({ return ( <> - + {polygon.name.length ? "Edit" : "New"} Object Mask diff --git a/web/src/components/settings/ObjectSettings.tsx b/web/src/components/settings/ObjectSettings.tsx index 15d51aa54..c3ced115b 100644 --- a/web/src/components/settings/ObjectSettings.tsx +++ b/web/src/components/settings/ObjectSettings.tsx @@ -64,7 +64,7 @@ export default function ObjectSettings({ }, ]; - const [options, setOptions] = usePersistence( + const [options, setOptions, optionsLoaded] = usePersistence( `${selectedCamera}-feed`, emptyObject, ); @@ -87,17 +87,20 @@ export default function ObjectSettings({ const memoizedObjects = useDeepMemo(objects); - const searchParams = useMemo( - () => - new URLSearchParams( - Object.keys(options || {}).reduce((memo, key) => { - //@ts-expect-error we know this is correct - memo.push([key, options[key] === true ? "1" : "0"]); - return memo; - }, []), - ), - [options], - ); + const searchParams = useMemo(() => { + if (!optionsLoaded) { + return new URLSearchParams(); + } + + const params = new URLSearchParams( + Object.keys(options || {}).reduce((memo, key) => { + //@ts-expect-error we know this is correct + memo.push([key, options[key] === true ? "1" : "0"]); + return memo; + }, []), + ); + return params; + }, [options, optionsLoaded]); useEffect(() => { document.title = "Object Settings - Frigate"; @@ -109,7 +112,7 @@ export default function ObjectSettings({ return (
- +
Debug diff --git a/web/src/components/settings/PolygonItem.tsx b/web/src/components/settings/PolygonItem.tsx index 9d8972341..bfd73725d 100644 --- a/web/src/components/settings/PolygonItem.tsx +++ b/web/src/components/settings/PolygonItem.tsx @@ -202,7 +202,7 @@ export default function PolygonItem({ return ( <> - +
- + {polygon.name.length ? "Edit" : "New"} Zone diff --git a/web/src/components/ui/sonner.tsx b/web/src/components/ui/sonner.tsx index 15690ddc7..21da14e4e 100644 --- a/web/src/components/ui/sonner.tsx +++ b/web/src/components/ui/sonner.tsx @@ -18,6 +18,8 @@ const Toaster = ({ ...props }: ToasterProps) => { actionButton: "group-[.toast]:bg-primary group-[.toast]:text-primary", cancelButton: "group-[.toast]:bg-muted group-[.toast]:text-muted-foreground", + closeButton: + "group-[.toast]:bg-secondary border-primary border-[1px]", success: "group toast group-[.toaster]:bg-success group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg", error: diff --git a/web/src/pages/ConfigEditor.tsx b/web/src/pages/ConfigEditor.tsx index 126d6c66a..7c30b5447 100644 --- a/web/src/pages/ConfigEditor.tsx +++ b/web/src/pages/ConfigEditor.tsx @@ -158,7 +158,7 @@ function ConfigEditor() { )}
- +
); } diff --git a/web/src/pages/Logs.tsx b/web/src/pages/Logs.tsx index c166968ab..e6cf07be5 100644 --- a/web/src/pages/Logs.tsx +++ b/web/src/pages/Logs.tsx @@ -332,7 +332,7 @@ function Logs() { return (
- +
diff --git a/web/src/views/events/EventView.tsx b/web/src/views/events/EventView.tsx index 4d5b5b75b..90ca54531 100644 --- a/web/src/views/events/EventView.tsx +++ b/web/src/views/events/EventView.tsx @@ -238,7 +238,7 @@ export default function EventView({ return (
- +
{isMobile && ( diff --git a/web/src/views/events/RecordingView.tsx b/web/src/views/events/RecordingView.tsx index 4e90937df..5494b6e87 100644 --- a/web/src/views/events/RecordingView.tsx +++ b/web/src/views/events/RecordingView.tsx @@ -261,7 +261,7 @@ export function RecordingView({ return (
- +