diff options
author | amilasilva88 <amilasilva88@gmail.com> | 2015-08-13 20:28:58 +0800 |
---|---|---|
committer | amilasilva88 <amilasilva88@gmail.com> | 2015-08-13 20:28:58 +0800 |
commit | 0350d762a7c08199e79dc401b6c6821d7e2a21bd (patch) | |
tree | 5b0751fb43278026aee2c153ae131e17776beecd /web/app | |
parent | a5b29b0e5df4ba84c8eaa8944258b9c9e12472db (diff) | |
download | traccar-server-0350d762a7c08199e79dc401b6c6821d7e2a21bd.tar.gz traccar-server-0350d762a7c08199e79dc401b6c6821d7e2a21bd.tar.bz2 traccar-server-0350d762a7c08199e79dc401b6c6821d7e2a21bd.zip |
Added ODOMeter and Modification to Mobile UI
Diffstat (limited to 'web/app')
-rw-r--r-- | web/app/store/DistanceUnits.js | 22 | ||||
-rw-r--r-- | web/app/store/SpeedUnits.js | 6 | ||||
-rw-r--r-- | web/app/view/main/MainMobile.js | 5 | ||||
-rw-r--r-- | web/app/view/report/Report.js | 9 | ||||
-rw-r--r-- | web/app/view/state/StateController.js | 13 |
5 files changed, 50 insertions, 5 deletions
diff --git a/web/app/store/DistanceUnits.js b/web/app/store/DistanceUnits.js index 506f1077c..7f0f93b70 100644 --- a/web/app/store/DistanceUnits.js +++ b/web/app/store/DistanceUnits.js @@ -20,5 +20,25 @@ Ext.define('Traccar.store.DistanceUnits', { data: [ {'key': 'km', 'name': strings.sharedKm}, {'key': 'mi', 'name': strings.sharedMi} - ] + ], + + convert: function(value, unit) { + switch (unit) { + case 'km': + value = value * 0.001; + return Math.round(value * 100) / 100; + case 'mi': + value = value * 0.000621371; + return Math.round(value * 100) / 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..934d03717 100644 --- a/web/app/store/SpeedUnits.js +++ b/web/app/store/SpeedUnits.js @@ -25,9 +25,11 @@ Ext.define('Traccar.store.SpeedUnits', { convert: function(value, unit) { switch (unit) { case 'kmh': - return value * 1.852; + value = value * 1.852; + return Math.round(value * 10) / 10; case 'mph': - return value * 1.15078; + value = value * 1.15078; + return Math.round(value * 10) / 10; } return value; }, diff --git a/web/app/view/main/MainMobile.js b/web/app/view/main/MainMobile.js index f32ad9fb1..1cdd6f525 100644 --- a/web/app/view/main/MainMobile.js +++ b/web/app/view/main/MainMobile.js @@ -40,6 +40,11 @@ Ext.define('Traccar.view.main.MainMobile', { xtype: 'deviceView', header: false, flex: 1 + },{ + region: 'east', + xtype: 'stateView', + header: false, + flex: 1 }] }); diff --git a/web/app/view/report/Report.js b/web/app/view/report/Report.js index ff8cc7b3d..f081333d4 100644 --- a/web/app/view/report/Report.js +++ b/web/app/view/report/Report.js @@ -90,7 +90,14 @@ Ext.define('Traccar.view.report.Report', { return speedUnits.convert(value, unit) + ' ' + speedUnits.getUnitName(unit); } }, - { text: strings.positionCourse, dataIndex: 'course', flex: 1 }, + /* { text: strings.positionCourse, dataIndex: 'course', flex: 1 }, */ + { text: 'ODO Meter', dataIndex: 'odoMeter', flex: 1, + renderer: function(value) { + var distanceUnits = Ext.getStore('DistanceUnits'); + var unit = Traccar.getApplication().getUser().get('distanceUnit') || Traccar.getApplication().getServer().get('distanceUnit') || ''; + return distanceUnits.convert(value, unit) + ' ' + distanceUnits.getUnitName(unit); + } + }, { 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..858feab52 100644 --- a/web/app/view/state/StateController.js +++ b/web/app/view/state/StateController.js @@ -59,9 +59,13 @@ Ext.define('Traccar.view.state.StateController', { priority: 6, name: strings.positionSpeed }, - 'course': { +/* 'course': { priority: 7, name: strings.positionCourse + },*/ + 'odoMeter': { + priority: 7, + name: 'ODO Meter' }, 'address': { priority: 8, @@ -87,6 +91,13 @@ Ext.define('Traccar.view.state.StateController', { var unit = Traccar.getApplication().getUser().get('speedUnit') || Traccar.getApplication().getServer().get('speedUnit') || ''; value = speedUnits.convert(value, unit) + ' ' + speedUnits.getUnitName(unit); } + + if (key === 'odoMeter') { + var distanceUnits = Ext.getStore('DistanceUnits'); + var 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: this.keys[key].priority, name: this.keys[key].name, |