aboutsummaryrefslogtreecommitdiff
path: root/web/app/AttributeFormatter.js
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-05-18 10:01:49 +0500
committerAbyss777 <abyss@fox5.ru>2017-05-18 16:18:26 +0500
commit788a499b346724d753798597fb18f8aef17e1588 (patch)
tree07a29a92434aba956697360d6ef867ca1a328060 /web/app/AttributeFormatter.js
parent31187bc2a3ae41ab553a6472b7592895e3641fe8 (diff)
downloadtrackermap-web-788a499b346724d753798597fb18f8aef17e1588.tar.gz
trackermap-web-788a499b346724d753798597fb18f8aef17e1588.tar.bz2
trackermap-web-788a499b346724d753798597fb18f8aef17e1588.zip
Implement known position attributes
Diffstat (limited to 'web/app/AttributeFormatter.js')
-rw-r--r--web/app/AttributeFormatter.js47
1 files changed, 46 insertions, 1 deletions
diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js
index 2142465c..ecab9fdb 100644
--- a/web/app/AttributeFormatter.js
+++ b/web/app/AttributeFormatter.js
@@ -35,6 +35,26 @@ Ext.define('Traccar.AttributeFormatter', {
return Ext.getStore('DistanceUnits').formatValue(value, Traccar.app.getPreference('distanceUnit'));
},
+ voltageFormatter: function (value) {
+ return Number(value.toFixed(Traccar.Style.numberPrecision)) + ' ' + Strings.sharedVoltAbbreviation;
+ },
+
+ percentageFormatter: function (value) {
+ return Number(value.toFixed(Traccar.Style.numberPrecision)) + ' &#37;';
+ },
+
+ temperatureFormatter: function (value) {
+ return Number(value.toFixed(Traccar.Style.numberPrecision)) + ' &deg;C';
+ },
+
+ volumeFormatter: function (value) {
+ return Number(value.toFixed(Traccar.Style.numberPrecision)) + ' ' + Strings.sharedLiterAbbreviation;
+ },
+
+ consumptionFormatter: function (value) {
+ return Number(value.toFixed(Traccar.Style.numberPrecision)) + ' ' + Strings.sharedLiterPerHourAbbreviation;
+ },
+
hoursFormatter: function (value) {
var hours = Math.round(value / 3600000);
return (hours + ' ' + Strings.sharedHourAbbreviation);
@@ -76,7 +96,7 @@ Ext.define('Traccar.AttributeFormatter', {
return this.speedFormatter;
} else if (key === 'course') {
return this.courseFormatter;
- } else if (key === 'distance' || key === 'odometer' || key === 'totalDistance' || key === 'accuracy') {
+ } else if (key === 'accuracy') {
return this.distanceFormatter;
} else if (key === 'hours') {
return this.hoursFormatter;
@@ -87,5 +107,30 @@ Ext.define('Traccar.AttributeFormatter', {
} else {
return this.defaultFormatter;
}
+ },
+
+ getAttributeFormatter: function (key) {
+ var dataType = Ext.getStore('PositionAttributes').getAttributeDataType(key);
+ if (!dataType) {
+ return this.defaultFormatter;
+ } else {
+ if (dataType === 'distance') {
+ return this.distanceFormatter;
+ } else if (dataType === 'speed') {
+ return this.speedFormatter;
+ } else if (dataType === 'voltage') {
+ return this.voltageFormatter;
+ } else if (dataType === 'percentage') {
+ return this.percentageFormatter;
+ } else if (dataType === 'temperature') {
+ return this.temperatureFormatter;
+ } else if (dataType === 'volume') {
+ return this.volumeFormatter;
+ } else if (dataType === 'consumption') {
+ return this.consumptionFormatter;
+ } else {
+ return this.defaultFormatter;
+ }
+ }
}
});