aboutsummaryrefslogtreecommitdiff
path: root/web/app
diff options
context:
space:
mode:
Diffstat (limited to 'web/app')
-rw-r--r--web/app/store/DistanceUnits.js20
-rw-r--r--web/app/store/SpeedUnits.js4
-rw-r--r--web/app/view/report/Report.js1
-rw-r--r--web/app/view/state/StateController.js17
4 files changed, 35 insertions, 7 deletions
diff --git a/web/app/store/DistanceUnits.js b/web/app/store/DistanceUnits.js
index 506f1077c..653bf6efb 100644
--- a/web/app/store/DistanceUnits.js
+++ b/web/app/store/DistanceUnits.js
@@ -20,5 +20,23 @@ Ext.define('Traccar.store.DistanceUnits', {
data: [
{'key': 'km', 'name': strings.sharedKm},
{'key': 'mi', 'name': strings.sharedMi}
- ]
+ ],
+
+ convert: function(value, unit) {
+ switch (unit) {
+ case 'km':
+ return Math.round(value * 0.1) / 100;
+ case 'mi':
+ return Math.round(value * 0.0621371) / 100;
+ }
+ return value;
+ },
+
+ getUnitName: function(unit) {
+ if (unit) {
+ return this.findRecord('key', unit).get('name');
+ } else {
+ return '';
+ }
+ }
});
diff --git a/web/app/store/SpeedUnits.js b/web/app/store/SpeedUnits.js
index 78686fbb9..15c52625f 100644
--- a/web/app/store/SpeedUnits.js
+++ b/web/app/store/SpeedUnits.js
@@ -25,9 +25,9 @@ Ext.define('Traccar.store.SpeedUnits', {
convert: function(value, unit) {
switch (unit) {
case 'kmh':
- return value * 1.852;
+ return Math.round(value * 1.852 * 10) / 10;
case 'mph':
- return value * 1.15078;
+ return Math.round(value * 1.15078 * 10) / 10;
}
return value;
},
diff --git a/web/app/view/report/Report.js b/web/app/view/report/Report.js
index ff8cc7b3d..535be942b 100644
--- a/web/app/view/report/Report.js
+++ b/web/app/view/report/Report.js
@@ -90,7 +90,6 @@ Ext.define('Traccar.view.report.Report', {
return speedUnits.convert(value, unit) + ' ' + speedUnits.getUnitName(unit);
}
},
- { text: strings.positionCourse, dataIndex: 'course', flex: 1 },
{ text: strings.positionAddress, dataIndex: 'address', flex: 1 }
]
diff --git a/web/app/view/state/StateController.js b/web/app/view/state/StateController.js
index 58b63120b..58bc5c55c 100644
--- a/web/app/view/state/StateController.js
+++ b/web/app/view/state/StateController.js
@@ -76,17 +76,20 @@ Ext.define('Traccar.view.state.StateController', {
updatePosition: function(position) {
var other;
+ var value;
+ var unit;
var store = Ext.getStore('Parameters');
store.removeAll();
for (var key in position.data) {
if (position.data.hasOwnProperty(key) && this.keys[key] !== undefined) {
- var value = position.get(key);
+ value = position.get(key);
if (key === 'speed') {
var speedUnits = Ext.getStore('SpeedUnits');
- var unit = Traccar.getApplication().getUser().get('speedUnit') || Traccar.getApplication().getServer().get('speedUnit') || '';
+ 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,
@@ -103,12 +106,20 @@ Ext.define('Traccar.view.state.StateController', {
}
for (var key in other) {
if (other.hasOwnProperty(key)) {
+
+ value = other[key];
+ if (key === 'distance' || key === 'odometer') {
+ var distanceUnits = Ext.getStore('DistanceUnits');
+ unit = Traccar.getApplication().getUser().get('distanceUnit') || Traccar.getApplication().getServer().get('distanceUnit') || '';
+ value = distanceUnits.convert(value, unit) + ' ' + distanceUnits.getUnitName(unit);
+ }
+
store.add(Ext.create('Traccar.model.Parameter', {
priority: 999,
name: key.replace(/^./, function (match) {
return match.toUpperCase();
}),
- value: other[key]
+ value: value
}));
}
}