From 838ef636f8b6b097292faf2458d16dff170f1e8e Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Mon, 11 Mar 2024 07:05:44 -0600 Subject: [PATCH] Layout tweaks (#10365) * Cleanup review items * Fix spacing * Fix -1 text * Cleanup scroll * Show activity indicator when review items are null * Show no preview text when not found * Add padding to buttons * Simplify comparisons --- .../components/filter/ReviewFilterGroup.tsx | 6 +-- .../components/player/PreviewVideoPlayer.tsx | 5 ++ web/src/views/events/EventView.tsx | 47 +++++++++++++------ web/src/views/events/RecordingView.tsx | 2 +- 4 files changed, 41 insertions(+), 19 deletions(-) diff --git a/web/src/components/filter/ReviewFilterGroup.tsx b/web/src/components/filter/ReviewFilterGroup.tsx index 2a2229ec9..0ebb00a20 100644 --- a/web/src/components/filter/ReviewFilterGroup.tsx +++ b/web/src/components/filter/ReviewFilterGroup.tsx @@ -212,7 +212,7 @@ function CamerasFilterButton({ ))} -
+
-
+
); } diff --git a/web/src/views/events/EventView.tsx b/web/src/views/events/EventView.tsx index 24cf7aa84..eaae92a0f 100644 --- a/web/src/views/events/EventView.tsx +++ b/web/src/views/events/EventView.tsx @@ -85,7 +85,7 @@ export default function EventView({ } if (!summary) { - return { alert: 0, detection: 0, significant_motion: 0 }; + return { alert: -1, detection: -1, significant_motion: -1 }; } if (filter?.showReviewed == 1) { @@ -106,6 +106,10 @@ export default function EventView({ // review paging const reviewItems = useMemo(() => { + if (!reviews) { + return undefined; + } + const all: ReviewSegment[] = []; const alerts: ReviewSegment[] = []; const detections: ReviewSegment[] = []; @@ -167,7 +171,7 @@ export default function EventView({ const exportReview = useCallback( (id: string) => { - const review = reviewItems.all?.find((seg) => seg.id == id); + const review = reviewItems?.all?.find((seg) => seg.id == id); if (!review) { return; @@ -206,7 +210,9 @@ export default function EventView({ aria-label="Select alerts" > -
Alerts ∙ {reviewCounts.alert}
+
+ Alerts{` ∙ ${reviewCounts.alert > -1 ? reviewCounts.alert : ""}`} +
- Detections ∙ {reviewCounts.detection} + Detections + {` ∙ ${reviewCounts.detection > -1 ? reviewCounts.detection : ""}`}
; - reviewItems: { + reviewItems?: { all: ReviewSegment[]; alert: ReviewSegment[]; detection: ReviewSegment[]; @@ -310,10 +317,14 @@ function DetectionReview({ // review data const currentItems = useMemo(() => { + if (!reviewItems) { + return null; + } + const current = reviewItems[severity]; if (!current || current.length == 0) { - return null; + return []; } if (filter?.showReviewed != 1) { @@ -323,7 +334,7 @@ function DetectionReview({ } // only refresh when severity or filter changes // eslint-disable-next-line react-hooks/exhaustive-deps - }, [severity, filter, reviewItems.all.length]); + }, [severity, filter, reviewItems?.all.length]); // preview @@ -348,7 +359,7 @@ function DetectionReview({ // timeline interaction const { alignStartDateToTimeline } = useEventUtils( - reviewItems.all, + reviewItems?.all ?? [], segmentDuration, ); @@ -441,10 +452,16 @@ function DetectionReview({ /> )} - {itemsToReview == 0 && ( -
+ {!currentItems && ( +
+ +
+ )} + + {currentItems?.length === 0 && ( +
- There are no {severity.replace(/_/g, " ")} items to review + There are no {severity.replace(/_/g, " ")}s to review
)} @@ -479,7 +496,7 @@ function DetectionReview({
); })} - {(itemsToReview ?? 0) > 0 && ( + {(currentItems?.length ?? 0) > 0 && (itemsToReview ?? 0) > 0 && (