aboutsummaryrefslogtreecommitdiff
path: root/web/app/store/DistanceUnits.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/app/store/DistanceUnits.js')
-rw-r--r--web/app/store/DistanceUnits.js20
1 files changed, 19 insertions, 1 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 '';
+ }
+ }
});