diff options
author | Anton Tananaev <anton@traccar.org> | 2022-04-17 19:04:29 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-04-17 19:04:29 -0700 |
commit | c3ab840588f176d4c8822db75798fc2073b058db (patch) | |
tree | 5beec983ae76daabe165482fd43cad2a01edf17d /modern | |
parent | 36c361b6c3ee8f951cf3906d7f451e30e2f46ada (diff) | |
download | trackermap-web-c3ab840588f176d4c8822db75798fc2073b058db.tar.gz trackermap-web-c3ab840588f176d4c8822db75798fc2073b058db.tar.bz2 trackermap-web-c3ab840588f176d4c8822db75798fc2073b058db.zip |
Move alarm formatter
Diffstat (limited to 'modern')
-rw-r--r-- | modern/src/DevicesList.js | 5 | ||||
-rw-r--r-- | modern/src/common/formatter.js | 5 |
2 files changed, 7 insertions, 3 deletions
diff --git a/modern/src/DevicesList.js b/modern/src/DevicesList.js index cdb2a040..ee3cb02b 100644 --- a/modern/src/DevicesList.js +++ b/modern/src/DevicesList.js @@ -23,9 +23,8 @@ import ErrorIcon from '@material-ui/icons/Error'; import { devicesActions } from './store'; import EditCollectionView from './EditCollectionView'; import { useEffectAsync } from './reactHelper'; -import { formatBoolean, formatPercentage, getStatusColor } from './common/formatter'; +import { formatAlarm, formatBoolean, formatPercentage, getStatusColor } from './common/formatter'; import { useTranslation } from './LocalizationProvider'; -import { prefixString } from './common/stringUtils'; const useStyles = makeStyles((theme) => ({ list: { @@ -90,7 +89,7 @@ const DeviceRow = ({ data, index, style }) => { {position && ( <> {position.attributes.hasOwnProperty('alarm') && ( - <Tooltip title={`${t('eventAlarm')}: ${t(prefixString('alarm', position.attributes.alarm))}`}> + <Tooltip title={`${t('eventAlarm')}: ${formatAlarm(position.attributes.alarm, t)}`}> <IconButton size="small"> <ErrorIcon fontSize="small" className={classes.negative} /> </IconButton> diff --git a/modern/src/common/formatter.js b/modern/src/common/formatter.js index 2a7c9095..c1f024a7 100644 --- a/modern/src/common/formatter.js +++ b/modern/src/common/formatter.js @@ -1,4 +1,5 @@ import moment from 'moment'; +import { prefixString } from './stringUtils'; export const formatBoolean = (value, t) => (value ? t('sharedYes') : t('sharedNo')); @@ -9,6 +10,8 @@ export const formatPercentage = (value) => `${value}%`; export const formatDate = (value, format = 'YYYY-MM-DD HH:mm') => moment(value).format(format); export const formatTime = (value, format = 'YYYY-MM-DD HH:mm:ss') => moment(value).format(format); +export const formatAlarm = (value, t) => t(prefixString('alarm', value)); + export const formatPosition = (value, key, t) => { if (value != null && typeof value === 'object') { value = value[key]; @@ -27,6 +30,8 @@ export const formatPosition = (value, key, t) => { return value.toFixed(1); case 'batteryLevel': return formatPercentage(value); + case 'alarm': + return formatAlarm(value, t); default: if (typeof value === 'number') { return formatNumber(value); |