diff options
author | Abyss777 <abyss@fox5.ru> | 2018-05-31 15:53:56 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2018-05-31 16:02:05 +0500 |
commit | b56be9f7fd8dc4f0a65f7606828a023d392b473e (patch) | |
tree | 8a1c8d478d6aa51482389aedc75ed14c31e899d5 /web/app/AttributeFormatter.js | |
parent | 29ab3eabfe35aa6ad6d2a8be3d7f7b790623ea1e (diff) | |
download | trackermap-web-b56be9f7fd8dc4f0a65f7606828a023d392b473e.tar.gz trackermap-web-b56be9f7fd8dc4f0a65f7606828a023d392b473e.tar.bz2 trackermap-web-b56be9f7fd8dc4f0a65f7606828a023d392b473e.zip |
Add engine hours in milliseconds support
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; } |