aboutsummaryrefslogtreecommitdiff
path: root/modern/src/common
diff options
context:
space:
mode:
authorAshutosh Bishnoi <mail2bishnoi@gmail.com>2020-11-24 14:26:26 +0530
committerAshutosh Bishnoi <mail2bishnoi@gmail.com>2020-11-24 14:26:26 +0530
commit34ec9a62ac0b65665f15f6e80729495e2558547f (patch)
treee4294411fad4b24ed82b564b8ae56f6c1759812d /modern/src/common
parentdf01e1d751980843506946a194fa9f67489182b1 (diff)
downloadetbsa-traccar-web-34ec9a62ac0b65665f15f6e80729495e2558547f.tar.gz
etbsa-traccar-web-34ec9a62ac0b65665f15f6e80729495e2558547f.tar.bz2
etbsa-traccar-web-34ec9a62ac0b65665f15f6e80729495e2558547f.zip
Refactoring and Improvements in chart report
Diffstat (limited to 'modern/src/common')
-rw-r--r--modern/src/common/chartTypes.js7
-rw-r--r--modern/src/common/formatter.js25
2 files changed, 31 insertions, 1 deletions
diff --git a/modern/src/common/chartTypes.js b/modern/src/common/chartTypes.js
new file mode 100644
index 0000000..fa868a9
--- /dev/null
+++ b/modern/src/common/chartTypes.js
@@ -0,0 +1,7 @@
+import t from '../common/localization';
+
+export const chartTypes = [
+ { id: 'speed', name: t('positionSpeed') },
+ { id: 'accuracy', name: t('positionAccuracy') },
+ { id: 'altitude', name: t('positionAltitude') },
+];
diff --git a/modern/src/common/formatter.js b/modern/src/common/formatter.js
index 8ef0040..b2f305a 100644
--- a/modern/src/common/formatter.js
+++ b/modern/src/common/formatter.js
@@ -9,7 +9,7 @@ export const formatPosition = (value, key) => {
case 'fixTime':
case 'deviceTime':
case 'serverTime':
- return moment(value).format('YYYY-MM-DD HH:mm');
+ return moment(value).format('LLL');
case 'latitude':
case 'longitude':
return value.toFixed(5);
@@ -80,3 +80,26 @@ export const formatVolume = (value, unit) => {
export const formatHours = (value) => {
return moment.duration(value).humanize();
};
+
+const speedConverter = (value, unit) => {
+ switch (unit) {
+ case 'kmh':
+ return (value * 1.852).toFixed(2);
+ case 'mph':
+ return (value * 1.15078).toFixed(2);
+ case 'kn':
+ default:
+ return (value * 1).toFixed(2);
+ }
+};
+
+export const getConverter = (key) => {
+ switch (key) {
+ case 'speed':
+ return speedConverter;
+ default:
+ return function (value) {
+ return value;
+ }
+ }
+};