From f2a9339544b996c2a8ef996d551334a1d81946e1 Mon Sep 17 00:00:00 2001 From: Justin Johnson Date: Tue, 26 Mar 2024 19:19:50 -0700 Subject: [PATCH] DBCC22-1858 Camera panel details --- src/frontend/src/Components/FriendlyTime.js | 61 +++++++++++-------- src/frontend/src/Components/map/camPopup.js | 17 ++---- src/frontend/src/pages/CameraDetailsPage.js | 5 +- src/frontend/src/pages/CameraDetailsPage.scss | 3 +- 4 files changed, 44 insertions(+), 42 deletions(-) diff --git a/src/frontend/src/Components/FriendlyTime.js b/src/frontend/src/Components/FriendlyTime.js index 7dc324512..bafbe2d4d 100644 --- a/src/frontend/src/Components/FriendlyTime.js +++ b/src/frontend/src/Components/FriendlyTime.js @@ -18,41 +18,48 @@ const datetimeFormat = { timeZoneName: 'short', }; const formatter = new Intl.DateTimeFormat('en-US', datetimeFormat); +const ONE_DAY = 1000 * 60 * 60 * 24; // 24 hours in milliseconds -export default function FriendlyTime( {date} ) { +export default function FriendlyTime({ date, asDate=false, includeFullIfHumanized=false }) { const [showTooltip, setShowTooltip] = useState(false); - // get time difference in seconds + // get time difference in milliseconds const timeDiff = (new Date() - new Date(date)); const dateFormatted = formatter.format(new Date(date)); - // if difference is less than 24hrs - if (timeDiff < 86400000 ) { - return
{ + const humanize = timeDiff < ONE_DAY; + + if (humanize && !asDate) { + return ( + + { includeFullIfHumanized && +

{dateFormatted}

+ } + +
{ + event.stopPropagation(); + setShowTooltip(!showTooltip); + }} + onKeyDown={(keyEvent) => { + if (keyEvent.keyCode == 13) { event.stopPropagation(); - setShowTooltip(!showTooltip); - }} - onKeyDown={(keyEvent) => { - if (keyEvent.keyCode == 13) { - event.stopPropagation(); - setShowTooltip(!showTooltip) - } - }}> - -

- -

- {dateFormatted} -
- } + setShowTooltip(!showTooltip) + } + }}> - // else return formatted date without tooltip - else { - return

- {dateFormatted} +

+

+ + {dateFormatted} + +
+ + ) } + + return

{dateFormatted}

; } diff --git a/src/frontend/src/Components/map/camPopup.js b/src/frontend/src/Components/map/camPopup.js index 97c4532a6..1f1d7bb28 100644 --- a/src/frontend/src/Components/map/camPopup.js +++ b/src/frontend/src/Components/map/camPopup.js @@ -79,7 +79,7 @@ export default function CamPopup(props) {

Camera

- {camera && + { camera &&

- - {camera.name} -

+ }}>{camera.name}

- {camera.is_on ? + { camera.is_on ?

DriveBC

- +
:
-
-

Unavailable

-
+

Unavailable

@@ -115,7 +110,7 @@ export default function CamPopup(props) {

DriveBC

- +
} diff --git a/src/frontend/src/pages/CameraDetailsPage.js b/src/frontend/src/pages/CameraDetailsPage.js index 773765190..16909f2f4 100644 --- a/src/frontend/src/pages/CameraDetailsPage.js +++ b/src/frontend/src/pages/CameraDetailsPage.js @@ -407,7 +407,7 @@ export default function CameraDetailsPage() { {!replay && (

DriveBC

- +
)}
@@ -418,8 +418,7 @@ export default function CameraDetailsPage() { Nearby }> -
-
+
diff --git a/src/frontend/src/pages/CameraDetailsPage.scss b/src/frontend/src/pages/CameraDetailsPage.scss index 07212bcd9..ae892e5bf 100644 --- a/src/frontend/src/pages/CameraDetailsPage.scss +++ b/src/frontend/src/pages/CameraDetailsPage.scss @@ -488,6 +488,7 @@ } .credit { + margin-top: 0.25rem; font-size: 0.75rem; font-style: italic; } @@ -522,7 +523,7 @@ top: 0rem; bottom: 0; width: 100%; - height: 388px; + height: 370px; .map { width: 100%;