diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-05-31 23:16:08 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-31 23:16:08 +1200 |
commit | b7cad4c8622997b10e42f7dbd89393dab7af9423 (patch) | |
tree | 8a1c8d478d6aa51482389aedc75ed14c31e899d5 /web/app/AttributeFormatter.js | |
parent | 29ab3eabfe35aa6ad6d2a8be3d7f7b790623ea1e (diff) | |
parent | b56be9f7fd8dc4f0a65f7606828a023d392b473e (diff) | |
download | trackermap-web-b7cad4c8622997b10e42f7dbd89393dab7af9423.tar.gz trackermap-web-b7cad4c8622997b10e42f7dbd89393dab7af9423.tar.bz2 trackermap-web-b7cad4c8622997b10e42f7dbd89393dab7af9423.zip |
Merge pull request #677 from Abyss777/engineHours
Add support of engine hours in milliseconds
Diffstat (limited to 'web/app/AttributeFormatter.js')
-rw-r--r-- | web/app/AttributeFormatter.js | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js index bb992c28..b2286249 100644 --- a/web/app/AttributeFormatter.js +++ b/web/app/AttributeFormatter.js @@ -60,11 +60,16 @@ Ext.define('Traccar.AttributeFormatter', { return Ext.getStore('VolumeUnits').convertValue(value, Traccar.app.getAttributePreference('volumeUnit')); }, + hoursFormatter: function (value) { + return Ext.getStore('HoursUnits').formatValue(value, 'h'); + }, + + hoursConverter: function (value) { + return Ext.getStore('HoursUnits').convertValue(value, 'h'); + }, + durationFormatter: function (value) { - var hours, minutes; - hours = Math.floor(value / 3600000); - minutes = Math.floor(value % 3600000 / 60000); - return hours + ' ' + Strings.sharedHourAbbreviation + ' ' + minutes + ' ' + Strings.sharedMinuteAbbreviation; + return Ext.getStore('HoursUnits').formatValue(value, 'h', true); }, deviceIdFormatter: function (value) { @@ -251,6 +256,8 @@ Ext.define('Traccar.AttributeFormatter', { return this.numberFormatterFactory(Traccar.Style.numberPrecision, '°C'); case 'volume': return this.volumeFormatter; + case 'hours': + return this.hoursFormatter; case 'consumption': return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedLiterPerHourAbbreviation); default: @@ -268,6 +275,8 @@ Ext.define('Traccar.AttributeFormatter', { return this.speedConverter; case 'volume': return this.volumeConverter; + case 'hours': + return this.hoursConverter; default: return function (value) { return value; @@ -280,6 +289,8 @@ Ext.define('Traccar.AttributeFormatter', { return Ext.getStore('SpeedUnits').formatValue(value, Traccar.app.getAttributePreference('speedUnit', 'kn'), true); } else if (attribute && attribute.get('dataType') === 'distance') { return Ext.getStore('DistanceUnits').formatValue(value, Traccar.app.getAttributePreference('distanceUnit', 'km'), true); + } else if (attribute && attribute.get('dataType') === 'hours') { + return Ext.getStore('HoursUnits').formatValue(value, 'h', true); } else { return value; } |