aboutsummaryrefslogtreecommitdiff
path: root/modern/src/reports/EventReportPage.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-07-31 16:27:18 -0700
committerAnton Tananaev <anton@traccar.org>2022-07-31 16:27:18 -0700
commita2a8644deefc80c920b05e3bbb36efb60cfc88f8 (patch)
treea61a4cbdf40f25a0e21abf88c69fea04fb38e198 /modern/src/reports/EventReportPage.js
parentb40ce605153ac162b96db205e4d38ad7c9b2e705 (diff)
downloadtrackermap-web-a2a8644deefc80c920b05e3bbb36efb60cfc88f8.tar.gz
trackermap-web-a2a8644deefc80c920b05e3bbb36efb60cfc88f8.tar.bz2
trackermap-web-a2a8644deefc80c920b05e3bbb36efb60cfc88f8.zip
Additional event data
Diffstat (limited to 'modern/src/reports/EventReportPage.js')
-rw-r--r--modern/src/reports/EventReportPage.js29
1 files changed, 23 insertions, 6 deletions
diff --git a/modern/src/reports/EventReportPage.js b/modern/src/reports/EventReportPage.js
index 264e874a..91c280da 100644
--- a/modern/src/reports/EventReportPage.js
+++ b/modern/src/reports/EventReportPage.js
@@ -1,9 +1,9 @@
import React, { useState } from 'react';
import {
- FormControl, InputLabel, Select, MenuItem, Table, TableHead, TableRow, TableCell, TableBody,
+ FormControl, InputLabel, Select, MenuItem, Table, TableHead, TableRow, TableCell, TableBody, Link,
} from '@mui/material';
import { useSelector } from 'react-redux';
-import { formatTime } from '../common/util/formatter';
+import { formatSpeed, formatTime } from '../common/util/formatter';
import ReportFilter from './components/ReportFilter';
import { prefixString } from '../common/util/stringUtils';
import { useTranslation } from '../common/components/LocalizationProvider';
@@ -14,13 +14,14 @@ import ColumnSelect from './components/ColumnSelect';
import { useCatch, useEffectAsync } from '../reactHelper';
import useReportStyles from './common/useReportStyles';
import TableShimmer from '../common/components/TableShimmer';
+import { useAttributePreference } from '../common/util/preferences';
const columnsArray = [
['eventTime', 'positionFixTime'],
['type', 'sharedType'],
['geofenceId', 'sharedGeofence'],
['maintenanceId', 'sharedMaintenance'],
- ['alarm', 'positionAlarm'],
+ ['attributes', 'commandData'],
];
const columnsMap = new Map(columnsArray);
@@ -28,11 +29,14 @@ const EventReportPage = () => {
const classes = useReportStyles();
const t = useTranslation();
+ const devices = useSelector((state) => state.devices.items);
const geofences = useSelector((state) => state.geofences.items);
+ const speedUnit = useAttributePreference('speedUnit');
+
const [allEventTypes, setAllEventTypes] = useState([['allEvents', 'eventAll']]);
- const [columns, setColumns] = usePersistedState('eventColumns', ['eventTime', 'type', 'alarm']);
+ const [columns, setColumns] = usePersistedState('eventColumns', ['eventTime', 'type', 'attributes']);
const [eventTypes, setEventTypes] = useState(['allEvents']);
const [items, setItems] = useState([]);
const [loading, setLoading] = useState(false);
@@ -88,8 +92,21 @@ const EventReportPage = () => {
return null;
case 'maintenanceId':
return item[key] > 0 ? item[key] > 0 : null;
- case 'alarm':
- return item.attributes[key] ? t(prefixString('alarm', item.attributes[key])) : null;
+ case 'attributes':
+ switch (item.type) {
+ case 'alarm':
+ return t(prefixString('alarm', item.attributes.alarm));
+ case 'deviceOverspeed':
+ return formatSpeed(item.attributes.speed, speedUnit, t);
+ case 'driverChanged':
+ return item.attributes.driverUniqueId;
+ case 'media':
+ return (<Link href={`/api/media/${devices[item.deviceId]?.uniqueId}/${item.attributes.file}`} target="_blank">{item.attributes.file}</Link>);
+ case 'commandResult':
+ return item.attributes.result;
+ default:
+ return '';
+ }
default:
return item[key];
}