From c000fa00d3a4b71a814864b9c805885f85bdd8dc Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 24 Oct 2022 21:50:03 -0700 Subject: Improve map markers --- modern/src/map/MapPositions.js | 7 ++++--- modern/src/other/EventPage.js | 12 ++++++++++-- modern/src/other/ReplayPage.js | 2 +- modern/src/reports/EventReportPage.js | 2 +- modern/src/reports/RouteReportPage.js | 2 +- modern/src/reports/StopReportPage.js | 13 ++++++++----- 6 files changed, 25 insertions(+), 13 deletions(-) (limited to 'modern') diff --git a/modern/src/map/MapPositions.js b/modern/src/map/MapPositions.js index 704c24bd..e4365fab 100644 --- a/modern/src/map/MapPositions.js +++ b/modern/src/map/MapPositions.js @@ -1,13 +1,13 @@ import { useId, useCallback, useEffect } from 'react'; import { useSelector } from 'react-redux'; import { map } from './core/MapView'; -import { getStatusColor } from '../common/util/formatter'; +import { formatTime, getStatusColor } from '../common/util/formatter'; import usePersistedState from '../common/util/usePersistedState'; import { mapIconKey } from './core/preloadImages'; import { findFonts } from './core/mapUtil'; import { useAttributePreference } from '../common/util/preferences'; -const MapPositions = ({ positions, onClick, showStatus, selectedPosition }) => { +const MapPositions = ({ positions, onClick, showStatus, selectedPosition, titleField }) => { const id = useId(); const clusters = `${id}-clusters`; const direction = `${id}-direction`; @@ -24,6 +24,7 @@ const MapPositions = ({ positions, onClick, showStatus, selectedPosition }) => { id: position.id, deviceId: position.deviceId, name: device.name, + fixTime: formatTime(position.fixTime), category: mapIconKey(device.category), color: showStatus ? position.attributes.color || getStatusColor(device.status) : 'neutral', rotation: position.course, @@ -84,7 +85,7 @@ const MapPositions = ({ positions, onClick, showStatus, selectedPosition }) => { 'icon-image': '{category}-{color}', 'icon-size': iconScale, 'icon-allow-overlap': true, - 'text-field': '{name}', + 'text-field': `{${titleField || 'name'}}`, 'text-allow-overlap': true, 'text-anchor': 'bottom', 'text-offset': [0, -2 * iconScale], diff --git a/modern/src/other/EventPage.js b/modern/src/other/EventPage.js index 9da8be79..8adc142c 100644 --- a/modern/src/other/EventPage.js +++ b/modern/src/other/EventPage.js @@ -13,6 +13,7 @@ import MapCamera from '../map/MapCamera'; import MapPositions from '../map/MapPositions'; import MapGeofence from '../map/MapGeofence'; import StatusCard from '../common/components/StatusCard'; +import { formatNotificationTitle } from '../common/util/formatter'; const useStyles = makeStyles(() => ({ root: { @@ -39,6 +40,13 @@ const EventPage = () => { const [position, setPosition] = useState(); const [showCard, setShowCard] = useState(false); + const formatType = (event) => formatNotificationTitle(t, { + type: event.type, + attributes: { + alarms: event.attributes.alarm, + }, + }); + const onMarkerClick = useCallback((positionId) => { setShowCard(!!positionId); }, [setShowCard]); @@ -75,13 +83,13 @@ const EventPage = () => { navigate('/')}> - {t('positionEvent')} + {formatType(event)}
- {position && } + {position && } {position && } {position && showCard && ( diff --git a/modern/src/other/ReplayPage.js b/modern/src/other/ReplayPage.js index ab549eba..8839138f 100644 --- a/modern/src/other/ReplayPage.js +++ b/modern/src/other/ReplayPage.js @@ -161,7 +161,7 @@ const ReplayPage = () => { {index < positions.length && ( - + )} diff --git a/modern/src/reports/EventReportPage.js b/modern/src/reports/EventReportPage.js index 623f26bd..ce1772e4 100644 --- a/modern/src/reports/EventReportPage.js +++ b/modern/src/reports/EventReportPage.js @@ -143,7 +143,7 @@ const EventReportPage = () => {
- {position && } + {position && } {position && }
diff --git a/modern/src/reports/RouteReportPage.js b/modern/src/reports/RouteReportPage.js index a1212ecd..8d967b19 100644 --- a/modern/src/reports/RouteReportPage.js +++ b/modern/src/reports/RouteReportPage.js @@ -83,7 +83,7 @@ const RouteReportPage = () => { ); })} - +
diff --git a/modern/src/reports/StopReportPage.js b/modern/src/reports/StopReportPage.js index 36c4d124..a322304e 100644 --- a/modern/src/reports/StopReportPage.js +++ b/modern/src/reports/StopReportPage.js @@ -100,11 +100,14 @@ const StopReportPage = () => {
- -- cgit v1.2.3