aboutsummaryrefslogtreecommitdiff
path: root/modern/src
diff options
context:
space:
mode:
authorMatjaž Črnko <m.crnko@txt.si>2023-06-16 11:34:23 +0200
committerMatjaž Črnko <m.crnko@txt.si>2023-06-16 11:34:23 +0200
commitb77d0f87b24d90d5e0d8da43aa11d08690880755 (patch)
tree8fc85a02fc67ebd47bd63f4e7cfc3a76e7733fe1 /modern/src
parente2aeaa191688bb245113f8280e7e1edd44c08bf3 (diff)
downloadtrackermap-web-b77d0f87b24d90d5e0d8da43aa11d08690880755.tar.gz
trackermap-web-b77d0f87b24d90d5e0d8da43aa11d08690880755.tar.bz2
trackermap-web-b77d0f87b24d90d5e0d8da43aa11d08690880755.zip
fix: Modern sync Consumption, Volume Position Attribute formatter
Diffstat (limited to 'modern/src')
-rw-r--r--modern/src/common/components/PositionValue.js23
-rw-r--r--modern/src/common/util/formatter.js2
2 files changed, 23 insertions, 2 deletions
diff --git a/modern/src/common/components/PositionValue.js b/modern/src/common/components/PositionValue.js
index 9711a7bb..58841939 100644
--- a/modern/src/common/components/PositionValue.js
+++ b/modern/src/common/components/PositionValue.js
@@ -3,7 +3,21 @@ import { useSelector } from 'react-redux';
import { Link } from '@mui/material';
import { Link as RouterLink } from 'react-router-dom';
import {
- formatAlarm, formatAltitude, formatBoolean, formatCoordinate, formatCourse, formatDistance, formatNumber, formatNumericHours, formatPercentage, formatSpeed, formatTime, formatTemperature, formatVoltage,
+ formatAlarm,
+ formatAltitude,
+ formatBoolean,
+ formatCoordinate,
+ formatCourse,
+ formatDistance,
+ formatNumber,
+ formatNumericHours,
+ formatPercentage,
+ formatSpeed,
+ formatTime,
+ formatTemperature,
+ formatVoltage,
+ formatVolume,
+ formatConsumption,
} from '../util/formatter';
import { useAttributePreference, usePreference } from '../util/preferences';
import { useTranslation } from './LocalizationProvider';
@@ -24,6 +38,7 @@ const PositionValue = ({ position, property, attribute }) => {
const distanceUnit = useAttributePreference('distanceUnit');
const altitudeUnit = useAttributePreference('altitudeUnit');
const speedUnit = useAttributePreference('speedUnit');
+ const volumeUnit = useAttributePreference('volumeUnit');
const coordinateFormat = usePreference('coordinateFormat');
const hours12 = usePreference('twelveHourFormat');
@@ -39,7 +54,7 @@ const PositionValue = ({ position, property, attribute }) => {
return formatCoordinate('longitude', value, coordinateFormat);
case 'speed':
case 'obdSpeed':
- return formatSpeed(value, speedUnit, t);
+ return value != null ? formatSpeed(value, speedUnit, t) : '';
case 'course':
return formatCourse(value);
case 'altitude':
@@ -49,6 +64,10 @@ const PositionValue = ({ position, property, attribute }) => {
return formatVoltage(value, t);
case 'batteryLevel':
return value != null ? formatPercentage(value, t) : '';
+ case 'volume':
+ return value != null ? formatVolume(value, volumeUnit, t) : '';
+ case 'fuelConsumption':
+ return value != null ? formatConsumption(value, t) : '';
case 'coolantTemp':
return formatTemperature(value);
case 'alarm':
diff --git a/modern/src/common/util/formatter.js b/modern/src/common/util/formatter.js
index 3ef83dba..0f7d2cc8 100644
--- a/modern/src/common/util/formatter.js
+++ b/modern/src/common/util/formatter.js
@@ -21,6 +21,8 @@ export const formatTemperature = (value) => `${value}°C`;
export const formatVoltage = (value, t) => `${value} ${t('sharedVoltAbbreviation')}`;
+export const formatConsumption = (value, t) => `${value} ${t('sharedLiterPerHourAbbreviation')}`;
+
export const formatTime = (value, format, hours12) => {
if (value) {
const m = moment(value);