From 842fd239a101e8c8ecbdb7da7a6efbfc83d3ad00 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 4 Sep 2022 16:08:25 -0700 Subject: Add event report map (fix #1022) --- modern/src/reports/EventReportPage.js | 137 +++++++++++++++++++++++----------- 1 file changed, 93 insertions(+), 44 deletions(-) (limited to 'modern') diff --git a/modern/src/reports/EventReportPage.js b/modern/src/reports/EventReportPage.js index 91c280da..623f26bd 100644 --- a/modern/src/reports/EventReportPage.js +++ b/modern/src/reports/EventReportPage.js @@ -1,7 +1,9 @@ import React, { useState } from 'react'; import { - FormControl, InputLabel, Select, MenuItem, Table, TableHead, TableRow, TableCell, TableBody, Link, + FormControl, InputLabel, Select, MenuItem, Table, TableHead, TableRow, TableCell, TableBody, Link, IconButton, } from '@mui/material'; +import GpsFixedIcon from '@mui/icons-material/GpsFixed'; +import LocationSearchingIcon from '@mui/icons-material/LocationSearching'; import { useSelector } from 'react-redux'; import { formatSpeed, formatTime } from '../common/util/formatter'; import ReportFilter from './components/ReportFilter'; @@ -15,6 +17,10 @@ import { useCatch, useEffectAsync } from '../reactHelper'; import useReportStyles from './common/useReportStyles'; import TableShimmer from '../common/components/TableShimmer'; import { useAttributePreference } from '../common/util/preferences'; +import MapView from '../map/core/MapView'; +import MapGeofence from '../map/MapGeofence'; +import MapPositions from '../map/MapPositions'; +import MapCamera from '../map/MapCamera'; const columnsArray = [ ['eventTime', 'positionFixTime'], @@ -40,6 +46,24 @@ const EventReportPage = () => { const [eventTypes, setEventTypes] = useState(['allEvents']); const [items, setItems] = useState([]); const [loading, setLoading] = useState(false); + const [selectedItem, setSelectedItem] = useState(null); + const [position, setPosition] = useState(null); + + useEffectAsync(async () => { + if (selectedItem) { + const response = await fetch(`/api/positions?id=${selectedItem.positionId}`); + if (response.ok) { + const positions = await response.json(); + if (positions.length > 0) { + setPosition(positions[0]); + } + } else { + throw Error(await response.text()); + } + } else { + setPosition(null); + } + }, [selectedItem]); useEffectAsync(async () => { const response = await fetch('/api/notifications/types'); @@ -114,51 +138,76 @@ const EventReportPage = () => { return ( } breadcrumbs={['reportTitle', 'reportEvents']}> -
- -
- - {t('reportEventTypes')} - - +
+ {selectedItem && ( +
+ + + {position && } + + {position && } +
+ )} +
+
+ +
+ + {t('reportEventTypes')} + + +
+ +
- - + + + + + {columns.map((key) => ({t(columnsMap.get(key))}))} + + + + {!loading ? items.map((item) => ( + + + {item.positionId ? selectedItem === item ? ( + setSelectedItem(null)}> + + + ) : ( + setSelectedItem(item)}> + + + ) : ''} + + {columns.map((key) => ( + + {formatValue(item, key)} + + ))} + + )) : ()} + +
+
- - - - {columns.map((key) => ({t(columnsMap.get(key))}))} - - - - {!loading ? items.map((item) => ( - - {columns.map((key) => ( - - {formatValue(item, key)} - - ))} - - )) : ()} - -
); }; -- cgit v1.2.3