aboutsummaryrefslogtreecommitdiff
path: root/web/app/AttributeFormatter.js
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-06-06 11:43:09 +0500
committerAbyss777 <abyss@fox5.ru>2017-06-06 11:43:09 +0500
commitf538963be5fcee2280b22050c8a51475c3a984f8 (patch)
tree6a08cb27c330480b60bb8fd160570e308802de0c /web/app/AttributeFormatter.js
parentb6f2faab0d35d54189fefd7567b6310023c3ad7b (diff)
downloadtrackermap-web-f538963be5fcee2280b22050c8a51475c3a984f8.tar.gz
trackermap-web-f538963be5fcee2280b22050c8a51475c3a984f8.tar.bz2
trackermap-web-f538963be5fcee2280b22050c8a51475c3a984f8.zip
- Reworked fields and attributes formatting
- Convert position and reports fields in the model - Add hidden columns to Route report - Add Number attributes to possible chart types
Diffstat (limited to 'web/app/AttributeFormatter.js')
-rw-r--r--web/app/AttributeFormatter.js70
1 files changed, 70 insertions, 0 deletions
diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js
index 302a8941..9d66794d 100644
--- a/web/app/AttributeFormatter.js
+++ b/web/app/AttributeFormatter.js
@@ -26,6 +26,10 @@ Ext.define('Traccar.AttributeFormatter', {
return Ext.getStore('SpeedUnits').formatValue(value, Traccar.app.getPreference('speedUnit'));
},
+ speedConverter: function (value) {
+ return Ext.getStore('SpeedUnits').convertValue(value, Traccar.app.getPreference('speedUnit'));
+ },
+
courseFormatter: function (value) {
var courseValues = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'];
return courseValues[Math.floor(value / 45)];
@@ -35,26 +39,51 @@ Ext.define('Traccar.AttributeFormatter', {
return Ext.getStore('DistanceUnits').formatValue(value, Traccar.app.getPreference('distanceUnit'));
},
+ distanceConverter: function (value) {
+ return Ext.getStore('DistanceUnits').convertValue(value, Traccar.app.getPreference('distanceUnit'));
+ },
+
voltageFormatter: function (value) {
return Number(value.toFixed(Traccar.Style.numberPrecision)) + ' ' + Strings.sharedVoltAbbreviation;
},
+ voltageConverter: function (value) {
+ return Number(value);
+ },
+
percentageFormatter: function (value) {
return Number(value.toFixed(Traccar.Style.numberPrecision)) + ' &#37;';
},
+ percentageConverter: function (value) {
+ return Number(value);
+ },
+
temperatureFormatter: function (value) {
return Number(value.toFixed(Traccar.Style.numberPrecision)) + ' &deg;C';
},
+ temperatureConverter: function (value) {
+ return Number(value);
+ },
+
+
volumeFormatter: function (value) {
return Number(value.toFixed(Traccar.Style.numberPrecision)) + ' ' + Strings.sharedLiterAbbreviation;
},
+ volumeConverter: function (value) {
+ return Number(value);
+ },
+
consumptionFormatter: function (value) {
return Number(value.toFixed(Traccar.Style.numberPrecision)) + ' ' + Strings.sharedLiterPerHourAbbreviation;
},
+ consumptionConverter: function (value) {
+ return Number(value);
+ },
+
hoursFormatter: function (value) {
var hours = Math.round(value / 3600000);
return (hours + ' ' + Strings.sharedHourAbbreviation);
@@ -131,6 +160,18 @@ Ext.define('Traccar.AttributeFormatter', {
}
},
+ getConverter: function (key) {
+ if (key === 'speed') {
+ return this.speedConverter;
+ } else if (key === 'distance' || key === 'accuracy') {
+ return this.distanceConverter;
+ } else {
+ return function (value) {
+ return value;
+ };
+ }
+ },
+
getAttributeFormatter: function (key) {
var dataType = Ext.getStore('PositionAttributes').getAttributeDataType(key);
if (!dataType) {
@@ -154,5 +195,34 @@ Ext.define('Traccar.AttributeFormatter', {
return this.defaultFormatter;
}
}
+ },
+
+ getAttributeConverter: function (key) {
+ var dataType = Ext.getStore('PositionAttributes').getAttributeDataType(key);
+ if (!dataType) {
+ return function (value) {
+ return value;
+ };
+ } else {
+ if (dataType === 'distance') {
+ return this.distanceConverter;
+ } else if (dataType === 'speed') {
+ return this.speedConverter;
+ } else if (dataType === 'voltage') {
+ return this.voltageConverter;
+ } else if (dataType === 'percentage') {
+ return this.percentageConverter;
+ } else if (dataType === 'temperature') {
+ return this.temperatureConverter;
+ } else if (dataType === 'volume') {
+ return this.volumeConverter;
+ } else if (dataType === 'consumption') {
+ return this.consumptionConverter;
+ } else {
+ return function (value) {
+ return value;
+ };
+ }
+ }
}
});