aboutsummaryrefslogtreecommitdiff
path: root/modern/src/common/components/PositionValue.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-08-19 13:58:45 -0700
committerAnton Tananaev <anton@traccar.org>2023-08-19 13:59:07 -0700
commitd3c7705bedebd65c94f9eea691aaf2fe03b0cafe (patch)
tree5f98b3d9bbbd4fe8067b5a334e84aff008b8db22 /modern/src/common/components/PositionValue.js
parent0161ae449d4a7bd0781c0665d663353663ab0faf (diff)
downloadtrackermap-web-d3c7705bedebd65c94f9eea691aaf2fe03b0cafe.tar.gz
trackermap-web-d3c7705bedebd65c94f9eea691aaf2fe03b0cafe.tar.bz2
trackermap-web-d3c7705bedebd65c94f9eea691aaf2fe03b0cafe.zip
Move to Vite
Diffstat (limited to 'modern/src/common/components/PositionValue.js')
-rw-r--r--modern/src/common/components/PositionValue.js125
1 files changed, 0 insertions, 125 deletions
diff --git a/modern/src/common/components/PositionValue.js b/modern/src/common/components/PositionValue.js
deleted file mode 100644
index 58841939..00000000
--- a/modern/src/common/components/PositionValue.js
+++ /dev/null
@@ -1,125 +0,0 @@
-import React from 'react';
-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,
- formatVolume,
- formatConsumption,
-} from '../util/formatter';
-import { useAttributePreference, usePreference } from '../util/preferences';
-import { useTranslation } from './LocalizationProvider';
-import { useAdministrator } from '../util/permissions';
-import AddressValue from './AddressValue';
-import GeofencesValue from './GeofencesValue';
-
-const PositionValue = ({ position, property, attribute }) => {
- const t = useTranslation();
-
- const admin = useAdministrator();
-
- const device = useSelector((state) => state.devices.items[position.deviceId]);
-
- const key = property || attribute;
- const value = property ? position[property] : position.attributes[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');
-
- const formatValue = () => {
- switch (key) {
- case 'fixTime':
- case 'deviceTime':
- case 'serverTime':
- return formatTime(value, 'seconds', hours12);
- case 'latitude':
- return formatCoordinate('latitude', value, coordinateFormat);
- case 'longitude':
- return formatCoordinate('longitude', value, coordinateFormat);
- case 'speed':
- case 'obdSpeed':
- return value != null ? formatSpeed(value, speedUnit, t) : '';
- case 'course':
- return formatCourse(value);
- case 'altitude':
- return formatAltitude(value, altitudeUnit, t);
- case 'power':
- case 'battery':
- 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':
- return formatAlarm(value, t);
- case 'odometer':
- case 'serviceOdometer':
- case 'tripOdometer':
- case 'obdOdometer':
- case 'distance':
- case 'totalDistance':
- return value != null ? formatDistance(value, distanceUnit, t) : '';
- case 'hours':
- return value != null ? formatNumericHours(value, t) : '';
- default:
- if (typeof value === 'number') {
- return formatNumber(value);
- } if (typeof value === 'boolean') {
- return formatBoolean(value, t);
- }
- return value || '';
- }
- };
-
- switch (key) {
- case 'image':
- case 'video':
- case 'audio':
- return (<Link href={`/api/media/${device.uniqueId}/${value}`} target="_blank">{value}</Link>);
- case 'totalDistance':
- case 'hours':
- return (
- <>
- {formatValue(value)}
- &nbsp;&nbsp;
- {admin && (<Link component={RouterLink} underline="none" to={`/settings/accumulators/${position.deviceId}`}>&#9881;</Link>)}
- </>
- );
- case 'address':
- return (<AddressValue latitude={position.latitude} longitude={position.longitude} originalAddress={value} />);
- case 'network':
- if (value) {
- return (<Link component={RouterLink} underline="none" to={`/network/${position.id}`}>{t('sharedInfoTitle')}</Link>);
- }
- return '';
- case 'geofenceIds':
- if (value) {
- return (<GeofencesValue geofenceIds={value} />);
- }
- return '';
- default:
- return formatValue(value);
- }
-};
-
-export default PositionValue;