From c3ab840588f176d4c8822db75798fc2073b058db Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 17 Apr 2022 19:04:29 -0700 Subject: Move alarm formatter --- modern/src/common/formatter.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'modern/src/common') 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); -- cgit v1.2.3