diff options
-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); |