aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-07-25 19:43:16 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-07-25 19:43:16 +1200
commite637bd7c022560dcc9c48516dc22a884a5de8122 (patch)
treec34369d5081238915e3f3660d27d4acedde25467 /web
parent87156d38c250abd9a1cba9b9af289d5ff0acb075 (diff)
downloadtraccar-server-e637bd7c022560dcc9c48516dc22a884a5de8122.tar.gz
traccar-server-e637bd7c022560dcc9c48516dc22a884a5de8122.tar.bz2
traccar-server-e637bd7c022560dcc9c48516dc22a884a5de8122.zip
Convert speed value to units
Diffstat (limited to 'web')
-rw-r--r--web/app/store/SpeedUnits.js16
-rw-r--r--web/app/view/report/Report.js11
-rw-r--r--web/app/view/state/StateController.js8
3 files changed, 32 insertions, 3 deletions
diff --git a/web/app/store/SpeedUnits.js b/web/app/store/SpeedUnits.js
index b658fc936..ee345621b 100644
--- a/web/app/store/SpeedUnits.js
+++ b/web/app/store/SpeedUnits.js
@@ -20,5 +20,19 @@ Ext.define('Traccar.store.SpeedUnits', {
data : [
{'key': 'kph', 'name': strings.shared_kph},
{'key': 'mph', 'name': strings.shared_mph}
- ]
+ ],
+
+ convert: function(value, unit) {
+ switch (unit) {
+ case 'kph':
+ return value * 1.852;
+ case 'mph':
+ return value * 1.15078;
+ }
+ return value;
+ },
+
+ getUnitName: function(unit) {
+ return this.findRecord('key', unit).get('name');
+ }
});
diff --git a/web/app/view/report/Report.js b/web/app/view/report/Report.js
index d52243139..320d336fa 100644
--- a/web/app/view/report/Report.js
+++ b/web/app/view/report/Report.js
@@ -80,7 +80,16 @@ Ext.define('Traccar.view.report.Report', {
{ text: strings.position_latitude, dataIndex: 'latitude', flex: 1 },
{ text: strings.position_longitude, dataIndex: 'longitude', flex: 1 },
{ text: strings.position_altitude, dataIndex: 'altitude', flex: 1 },
- { text: strings.position_speed, dataIndex: 'speed', flex: 1 },
+ {
+ text: strings.position_speed,
+ dataIndex: 'speed',
+ flex: 1,
+ renderer: function(value) {
+ var speedUnits = Ext.getStore('SpeedUnits');
+ var unit = Traccar.getApplication().getUser().get('speedUnit') || Traccar.getApplication().getServer().get('speedUnit') || '';
+ return speedUnits.convert(value, unit) + ' ' + speedUnits.getUnitName(unit);
+ }
+ },
{ text: strings.position_course, dataIndex: 'course', flex: 1 },
{ text: strings.position_address, dataIndex: 'address', flex: 1 }
]
diff --git a/web/app/view/state/StateController.js b/web/app/view/state/StateController.js
index 1e2c271d1..66b1c48ac 100644
--- a/web/app/view/state/StateController.js
+++ b/web/app/view/state/StateController.js
@@ -81,10 +81,16 @@ Ext.define('Traccar.view.state.StateController', {
for (var key in position.data) {
if (position.data.hasOwnProperty(key) && this.keys[key] !== undefined) {
+ var value = position.get(key);
+ if (key === 'speed') {
+ var speedUnits = Ext.getStore('SpeedUnits');
+ var unit = Traccar.getApplication().getUser().get('speedUnit') || Traccar.getApplication().getServer().get('speedUnit') || '';
+ value = speedUnits.convert(value, unit) + ' ' + speedUnits.getUnitName(unit);
+ }
store.add(Ext.create('Traccar.model.Parameter', {
priority: this.keys[key].priority,
name: this.keys[key].name,
- value: position.get(key)
+ value: value
}));
}
}