aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-05-01 17:33:14 -0700
committerAnton Tananaev <anton@traccar.org>2022-05-01 17:33:14 -0700
commit336c00ac843da828728be7c5e1333d176f41fe51 (patch)
treed4bb0efda1f85343786ac3ecf123d591d06571e6
parent59ee36bb64ce6c4b7ea7e10f68b8b1f927af4f7d (diff)
downloadtrackermap-web-336c00ac843da828728be7c5e1333d176f41fe51.tar.gz
trackermap-web-336c00ac843da828728be7c5e1333d176f41fe51.tar.bz2
trackermap-web-336c00ac843da828728be7c5e1333d176f41fe51.zip
Proper course formatting
-rw-r--r--modern/src/common/formatter.js5
-rw-r--r--modern/src/map/StatusCard.js4
2 files changed, 7 insertions, 2 deletions
diff --git a/modern/src/common/formatter.js b/modern/src/common/formatter.js
index 6968deb7..fed29a9d 100644
--- a/modern/src/common/formatter.js
+++ b/modern/src/common/formatter.js
@@ -43,6 +43,11 @@ export const formatPosition = (value, key, t) => {
}
};
+export const formatCourse = (value) => {
+ const courseValues = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'];
+ return courseValues[Math.floor(value / 45)];
+};
+
export const formatDistance = (value, unit, t) => {
switch (unit) {
case 'mi':
diff --git a/modern/src/map/StatusCard.js b/modern/src/map/StatusCard.js
index 8b71913a..38d8833f 100644
--- a/modern/src/map/StatusCard.js
+++ b/modern/src/map/StatusCard.js
@@ -12,7 +12,7 @@ import DeleteIcon from '@material-ui/icons/Delete';
import { useTranslation } from '../LocalizationProvider';
import {
- formatDistance, formatPosition, formatSpeed, formatStatus,
+ formatCourse, formatDistance, formatSpeed, formatStatus,
} from '../common/formatter';
import RemoveDialog from '../RemoveDialog';
import { useAttributePreference } from '../common/preferences';
@@ -99,7 +99,7 @@ const StatusCard = ({ deviceId, onClose }) => {
{position.attributes.odometer
? <StatusRow name={t('positionOdometer')} value={formatDistance(position.attributes.odometer, distanceUnit, t)} />
: <StatusRow name={t('deviceTotalDistance')} value={formatDistance(position.attributes.totalDistance, distanceUnit, t)} />}
- <StatusRow name={t('positionCourse')} value={formatPosition(position.course, 'course', t)} />
+ <StatusRow name={t('positionCourse')} value={formatCourse(position.course)} />
</TableBody>
</Table>
</TableContainer>