diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-08-07 07:42:21 -1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-07 07:42:21 -1000 |
commit | db406fcc787df2fa865e5c5fe333f152e533cda1 (patch) | |
tree | f8a0ca5cf0b897106c618a8b2cb83f31f155d86d /modern/src/common/formatter.js | |
parent | 59c60f8fcfabe855231e3dfecf9b363b7488024f (diff) | |
parent | 1521abf0372dd1f91d690e2931cc87d71642acb6 (diff) | |
download | trackermap-web-db406fcc787df2fa865e5c5fe333f152e533cda1.tar.gz trackermap-web-db406fcc787df2fa865e5c5fe333f152e533cda1.tar.bz2 trackermap-web-db406fcc787df2fa865e5c5fe333f152e533cda1.zip |
Merge pull request #888 from mail2bishnoi/quick_device_menu
Quick device menu
Diffstat (limited to 'modern/src/common/formatter.js')
-rw-r--r-- | modern/src/common/formatter.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/modern/src/common/formatter.js b/modern/src/common/formatter.js index 3c0341b7..f0bb2e11 100644 --- a/modern/src/common/formatter.js +++ b/modern/src/common/formatter.js @@ -98,3 +98,25 @@ export const formatCoordinate = (key, value, unit) => { return `${value.toFixed(6)}°`; } }; + +export const getStatusColor = (status) => { + switch (status) { + case 'online': + return 'green'; + case 'offline': + return 'red'; + case 'unknown': + default: + return 'gray'; + } +}; + +export const getBatteryStatus = (batteryLevel) => { + if (batteryLevel >= 70) { + return 'green'; + } + if (batteryLevel > 30) { + return 'gray'; + } + return 'red'; +}; |