From b56be9f7fd8dc4f0a65f7606828a023d392b473e Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 31 May 2018 15:53:56 +0500 Subject: Add engine hours in milliseconds support --- web/app/AttributeFormatter.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'web/app/AttributeFormatter.js') diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js index bb992c2..b228624 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; } -- cgit v1.2.3