diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-21 07:20:14 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-21 07:20:14 -0700 |
commit | 2110974542f2700b5d801a540eded8e850be04aa (patch) | |
tree | 677886959b0cdb56ad3cee95966649e695edafd9 | |
parent | adad08583e7829ce004388d949b8829cb7f92065 (diff) | |
download | trackermap-web-2110974542f2700b5d801a540eded8e850be04aa.tar.gz trackermap-web-2110974542f2700b5d801a540eded8e850be04aa.tar.bz2 trackermap-web-2110974542f2700b5d801a540eded8e850be04aa.zip |
Fix hours and accumulators
-rw-r--r-- | modern/src/common/components/PositionValue.js | 2 | ||||
-rw-r--r-- | modern/src/reports/ChartReportPage.js | 3 | ||||
-rw-r--r-- | modern/src/settings/AccumulatorsPage.js | 14 |
3 files changed, 14 insertions, 5 deletions
diff --git a/modern/src/common/components/PositionValue.js b/modern/src/common/components/PositionValue.js index 5810ae5e..83fc0ef2 100644 --- a/modern/src/common/components/PositionValue.js +++ b/modern/src/common/components/PositionValue.js @@ -43,6 +43,8 @@ const PositionValue = ({ position, property, attribute }) => { case 'distance': case 'totalDistance': return formatDistance(value, distanceUnit, t); + case 'hours': + return formatNumber(value / 1000); default: if (typeof value === 'number') { return formatNumber(value); diff --git a/modern/src/reports/ChartReportPage.js b/modern/src/reports/ChartReportPage.js index 3a2dfbf2..977c5158 100644 --- a/modern/src/reports/ChartReportPage.js +++ b/modern/src/reports/ChartReportPage.js @@ -57,6 +57,9 @@ const ChartReportPage = () => { case 'volume': formatted[key] = volumeFromLiters(value, volumeUnit).toFixed(2); break; + case 'hours': + formatted[key] = (value / 1000).toFixed(2); + break; default: formatted[key] = value; break; diff --git a/modern/src/settings/AccumulatorsPage.js b/modern/src/settings/AccumulatorsPage.js index 37c77d5a..500c4e4a 100644 --- a/modern/src/settings/AccumulatorsPage.js +++ b/modern/src/settings/AccumulatorsPage.js @@ -16,6 +16,8 @@ import { useTranslation } from '../common/components/LocalizationProvider'; import PageLayout from '../common/components/PageLayout'; import SettingsMenu from './components/SettingsMenu'; import { useCatch } from '../reactHelper'; +import { useAttributePreference } from '../common/util/preferences'; +import { distanceFromMeters, distanceToMeters, distanceUnitString } from '../common/util/converter'; const useStyles = makeStyles((theme) => ({ container: { @@ -43,6 +45,8 @@ const AccumulatorsPage = () => { const classes = useStyles(); const t = useTranslation(); + const distanceUnit = useAttributePreference('distanceUnit'); + const { deviceId } = useParams(); const position = useSelector((state) => state.positions.items[deviceId]); @@ -85,15 +89,15 @@ const AccumulatorsPage = () => { <AccordionDetails className={classes.details}> <TextField type="number" - value={item.hours} - onChange={(event) => setItem({ ...item, hours: Number(event.target.value) })} + value={item.hours / 1000} + onChange={(event) => setItem({ ...item, hours: Number(event.target.value) * 1000 })} label={t('positionHours')} /> <TextField type="number" - value={item.totalDistance} - onChange={(event) => setItem({ ...item, totalDistance: Number(event.target.value) })} - label={t('deviceTotalDistance')} + value={distanceFromMeters(item.totalDistance, distanceUnit)} + onChange={(event) => setItem({ ...item, totalDistance: distanceToMeters(Number(event.target.value), distanceUnit) })} + label={`${t('deviceTotalDistance')} (${distanceUnitString(distanceUnit, t)})`} /> </AccordionDetails> </Accordion> |