aboutsummaryrefslogtreecommitdiff
path: root/web/app/AttributeFormatter.js
diff options
context:
space:
mode:
authortsmgeek <tsmgeek@gmail.com>2017-08-22 00:21:29 +0100
committertsmgeek <tsmgeek@gmail.com>2017-08-22 00:21:29 +0100
commitfdf35488b5b3cd5725c6c2e179b65377d30c6577 (patch)
treeda0b3927f3049475cd67977fe093d198920c1c37 /web/app/AttributeFormatter.js
parentf8b98b236fd676fe8945d942842640ddea5bbac8 (diff)
parente0bb9b92d07176677b3043530660af3bc30774d7 (diff)
downloadtrackermap-web-fdf35488b5b3cd5725c6c2e179b65377d30c6577.tar.gz
trackermap-web-fdf35488b5b3cd5725c6c2e179b65377d30c6577.tar.bz2
trackermap-web-fdf35488b5b3cd5725c6c2e179b65377d30c6577.zip
Merge from upstream, change .eslintrc.json
Diffstat (limited to 'web/app/AttributeFormatter.js')
-rw-r--r--web/app/AttributeFormatter.js48
1 files changed, 45 insertions, 3 deletions
diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js
index 4147edec..7ccf84b4 100644
--- a/web/app/AttributeFormatter.js
+++ b/web/app/AttributeFormatter.js
@@ -23,6 +23,7 @@ Ext.define('Traccar.AttributeFormatter', {
if (value !== undefined) {
return Number(value.toFixed(precision)) + ' ' + suffix;
}
+ return null;
};
},
@@ -54,8 +55,8 @@ Ext.define('Traccar.AttributeFormatter', {
durationFormatter: function (value) {
var hours, minutes;
hours = Math.floor(value / 3600000);
- minutes = Math.round((value % 3600000) / 60000);
- return (hours + ' ' + Strings.sharedHourAbbreviation + ' ' + minutes + ' ' + Strings.sharedMinuteAbbreviation);
+ minutes = Math.round(value % 3600000 / 60000);
+ return hours + ' ' + Strings.sharedHourAbbreviation + ' ' + minutes + ' ' + Strings.sharedMinuteAbbreviation;
},
deviceIdFormatter: function (value) {
@@ -72,6 +73,7 @@ Ext.define('Traccar.AttributeFormatter', {
group = store.getById(value);
return group ? group.get('name') : value;
}
+ return null;
},
geofenceIdFormatter: function (value) {
@@ -84,6 +86,7 @@ Ext.define('Traccar.AttributeFormatter', {
geofence = store.getById(value);
return geofence ? geofence.get('name') : '';
}
+ return null;
},
driverUniqueIdFormatter: function (value) {
@@ -96,11 +99,11 @@ Ext.define('Traccar.AttributeFormatter', {
driver = store.findRecord('uniqueId', value, 0, false, true, true);
return driver ? value + ' (' + driver.get('name') + ')' : value;
}
+ return null;
},
lastUpdateFormatter: function (value) {
var seconds, interval;
-
if (value) {
seconds = Math.floor((new Date() - value) / 1000);
if (seconds < 0) {
@@ -116,6 +119,7 @@ Ext.define('Traccar.AttributeFormatter', {
}
return Math.floor(seconds / 60) + ' ' + Strings.sharedMinutes;
}
+ return null;
},
defaultFormatter: function (value) {
@@ -184,6 +188,7 @@ Ext.define('Traccar.AttributeFormatter', {
getAttributeFormatter: function (key) {
var dataType = Ext.getStore('PositionAttributes').getAttributeDataType(key);
+<<<<<<< HEAD
switch (dataType) {
case 'distance':
@@ -204,11 +209,34 @@ Ext.define('Traccar.AttributeFormatter', {
return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedLiterPerHourAbbreviation);
default:
return this.defaultFormatter;
+=======
+ if (!dataType) {
+ return this.defaultFormatter;
+ } else if (dataType === 'distance') {
+ return this.distanceFormatter;
+ } else if (dataType === 'speed') {
+ return this.speedFormatter;
+ } else if (dataType === 'driverUniqueId') {
+ return this.driverUniqueIdFormatter;
+ } else if (dataType === 'voltage') {
+ return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedVoltAbbreviation);
+ } else if (dataType === 'percentage') {
+ return this.numberFormatterFactory(Traccar.Style.numberPrecision, '&#37;');
+ } else if (dataType === 'temperature') {
+ return this.numberFormatterFactory(Traccar.Style.numberPrecision, '&deg;C');
+ } else if (dataType === 'volume') {
+ return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedLiterAbbreviation);
+ } else if (dataType === 'consumption') {
+ return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedLiterPerHourAbbreviation);
+ } else {
+ return this.defaultFormatter;
+>>>>>>> e0bb9b92d07176677b3043530660af3bc30774d7
}
},
getAttributeConverter: function (key) {
var dataType = Ext.getStore('PositionAttributes').getAttributeDataType(key);
+<<<<<<< HEAD
switch (dataType){
case 'distance':
@@ -219,6 +247,20 @@ Ext.define('Traccar.AttributeFormatter', {
return function (value) {
return value;
};
+=======
+ if (!dataType) {
+ return function (value) {
+ return value;
+ };
+ } else if (dataType === 'distance') {
+ return this.distanceConverter;
+ } else if (dataType === 'speed') {
+ return this.speedConverter;
+ } else {
+ return function (value) {
+ return value;
+ };
+>>>>>>> e0bb9b92d07176677b3043530660af3bc30774d7
}
}
});