diff options
author | Abyss777 <abyss@fox5.ru> | 2017-08-18 11:52:06 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-08-18 11:52:06 +0500 |
commit | 65116928b2b7a8e5e2b70bf490b3225896cf2c71 (patch) | |
tree | af24b231822fb045a7ae4d03e533775285d41e47 /web/app/AttributeFormatter.js | |
parent | 01af5f520e24a33d7e22523d8ed11e9f14a19516 (diff) | |
parent | b3d3c720f34e12e7af83e6be3bd87e304931bbe1 (diff) | |
download | trackermap-web-65116928b2b7a8e5e2b70bf490b3225896cf2c71.tar.gz trackermap-web-65116928b2b7a8e5e2b70bf490b3225896cf2c71.tar.bz2 trackermap-web-65116928b2b7a8e5e2b70bf490b3225896cf2c71.zip |
Merge branch 'master' into disable_vehicle_features
Diffstat (limited to 'web/app/AttributeFormatter.js')
-rw-r--r-- | web/app/AttributeFormatter.js | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js index 2d394f57..87689a28 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) { @@ -180,26 +184,24 @@ Ext.define('Traccar.AttributeFormatter', { 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 === '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, '%'); + } else if (dataType === 'temperature') { + return this.numberFormatterFactory(Traccar.Style.numberPrecision, '°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 { - 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, '%'); - } else if (dataType === 'temperature') { - return this.numberFormatterFactory(Traccar.Style.numberPrecision, '°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; - } + return this.defaultFormatter; } }, @@ -209,16 +211,14 @@ Ext.define('Traccar.AttributeFormatter', { return function (value) { return value; }; + } else if (dataType === 'distance') { + return this.distanceConverter; + } else if (dataType === 'speed') { + return this.speedConverter; } else { - if (dataType === 'distance') { - return this.distanceConverter; - } else if (dataType === 'speed') { - return this.speedConverter; - } else { - return function (value) { - return value; - }; - } + return function (value) { + return value; + }; } } }); |