diff options
author | Anton Tananaev <anton@traccar.org> | 2024-04-21 15:52:44 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2024-04-21 15:52:44 -0700 |
commit | a308af228fe9327f3b261a0083f6a202b2cc2369 (patch) | |
tree | a99b420245b49cf016791a2b9c9c60ccb78e6e8e /src | |
parent | 75dee6d29fe222fe868b39718a9ecfeb22996e1b (diff) | |
download | trackermap-web-a308af228fe9327f3b261a0083f6a202b2cc2369.tar.gz trackermap-web-a308af228fe9327f3b261a0083f6a202b2cc2369.tar.bz2 trackermap-web-a308af228fe9327f3b261a0083f6a202b2cc2369.zip |
Hide missing values in reports
Diffstat (limited to 'src')
-rw-r--r-- | src/reports/EventReportPage.jsx | 13 | ||||
-rw-r--r-- | src/reports/StopReportPage.jsx | 15 | ||||
-rw-r--r-- | src/reports/SummaryReportPage.jsx | 15 | ||||
-rw-r--r-- | src/reports/TripReportPage.jsx | 17 |
4 files changed, 32 insertions, 28 deletions
diff --git a/src/reports/EventReportPage.jsx b/src/reports/EventReportPage.jsx index 5ffc8ac3..5dd97741 100644 --- a/src/reports/EventReportPage.jsx +++ b/src/reports/EventReportPage.jsx @@ -120,19 +120,20 @@ const EventReportPage = () => { }); const formatValue = (item, key) => { + const value = item[key]; switch (key) { case 'eventTime': - return formatTime(item[key], 'seconds', hours12); + return formatTime(value, 'seconds', hours12); case 'type': - return t(prefixString('event', item[key])); + return t(prefixString('event', value)); case 'geofenceId': - if (item[key] > 0) { - const geofence = geofences[item[key]]; + if (value > 0) { + const geofence = geofences[value]; return geofence && geofence.name; } return null; case 'maintenanceId': - return item[key] > 0 ? item[key] > 0 : null; + return value > 0 ? value : null; case 'attributes': switch (item.type) { case 'alarm': @@ -149,7 +150,7 @@ const EventReportPage = () => { return ''; } default: - return item[key]; + return value; } }; diff --git a/src/reports/StopReportPage.jsx b/src/reports/StopReportPage.jsx index 066b29a4..13a42cd4 100644 --- a/src/reports/StopReportPage.jsx +++ b/src/reports/StopReportPage.jsx @@ -88,22 +88,23 @@ const StopReportPage = () => { }); const formatValue = (item, key) => { + const value = item[key]; switch (key) { case 'startTime': case 'endTime': - return formatTime(item[key], 'minutes', hours12); + return formatTime(value, 'minutes', hours12); case 'startOdometer': - return formatDistance(item[key], distanceUnit, t); + return formatDistance(value, distanceUnit, t); case 'duration': - return formatNumericHours(item[key], t); + return formatNumericHours(value, t); case 'engineHours': - return formatNumericHours(item[key], t); + return value > 0 ? formatNumericHours(value, t) : null; case 'spentFuel': - return formatVolume(item[key], volumeUnit, t); + return value > 0 ? formatVolume(value, volumeUnit, t) : null; case 'address': - return (<AddressValue latitude={item.latitude} longitude={item.longitude} originalAddress={item[key]} />); + return (<AddressValue latitude={item.latitude} longitude={item.longitude} originalAddress={value} />); default: - return item[key]; + return value; } }; diff --git a/src/reports/SummaryReportPage.jsx b/src/reports/SummaryReportPage.jsx index ae7e043e..4172514c 100644 --- a/src/reports/SummaryReportPage.jsx +++ b/src/reports/SummaryReportPage.jsx @@ -88,24 +88,25 @@ const SummaryReportPage = () => { }); const formatValue = (item, key) => { + const value = item[key]; switch (key) { case 'deviceId': - return devices[item[key]].name; + return devices[value].name; case 'startTime': - return formatTime(item[key], 'date', hours12); + return formatTime(value, 'date', hours12); case 'startOdometer': case 'endOdometer': case 'distance': - return formatDistance(item[key], distanceUnit, t); + return formatDistance(value, distanceUnit, t); case 'averageSpeed': case 'maxSpeed': - return formatSpeed(item[key], speedUnit, t); + return value > 0 ? formatSpeed(value, speedUnit, t) : null; case 'engineHours': - return formatNumericHours(item[key], t); + return value > 0 ? formatNumericHours(value, t) : null; case 'spentFuel': - return formatVolume(item[key], volumeUnit, t); + return value > 0 ? formatVolume(value, volumeUnit, t) : null; default: - return item[key]; + return value; } }; diff --git a/src/reports/TripReportPage.jsx b/src/reports/TripReportPage.jsx index 897ee506..29bf33e5 100644 --- a/src/reports/TripReportPage.jsx +++ b/src/reports/TripReportPage.jsx @@ -130,27 +130,28 @@ const TripReportPage = () => { }); const formatValue = (item, key) => { + const value = item[key]; switch (key) { case 'startTime': case 'endTime': - return formatTime(item[key], 'minutes', hours12); + return formatTime(value, 'minutes', hours12); case 'startOdometer': case 'endOdometer': case 'distance': - return formatDistance(item[key], distanceUnit, t); + return formatDistance(value, distanceUnit, t); case 'averageSpeed': case 'maxSpeed': - return formatSpeed(item[key], speedUnit, t); + return value > 0 ? formatSpeed(value, speedUnit, t) : null; case 'duration': - return formatNumericHours(item[key], t); + return formatNumericHours(value, t); case 'spentFuel': - return formatVolume(item[key], volumeUnit, t); + return value > 0 ? formatVolume(value, volumeUnit, t) : null; case 'startAddress': - return (<AddressValue latitude={item.startLat} longitude={item.startLon} originalAddress={item[key]} />); + return (<AddressValue latitude={item.startLat} longitude={item.startLon} originalAddress={value} />); case 'endAddress': - return (<AddressValue latitude={item.endLat} longitude={item.endLon} originalAddress={item[key]} />); + return (<AddressValue latitude={item.endLat} longitude={item.endLon} originalAddress={value} />); default: - return item[key]; + return value; } }; |