diff options
Diffstat (limited to 'modern/src/common')
-rw-r--r-- | modern/src/common/formatter.js | 5 |
1 files changed, 5 insertions, 0 deletions
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); |