diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-08-18 13:47:52 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-08-18 13:47:52 +1200 |
commit | 3ad3edfadba59e94d95e967e9d5cd28ae671cae4 (patch) | |
tree | f7ab337c360bf50a79855787e9fa80e45ebd808c | |
parent | 17ff0791718807be18e9f63aa095ed86d4b82b1c (diff) | |
download | traccar-server-3ad3edfadba59e94d95e967e9d5cd28ae671cae4.tar.gz traccar-server-3ad3edfadba59e94d95e967e9d5cd28ae671cae4.tar.bz2 traccar-server-3ad3edfadba59e94d95e967e9d5cd28ae671cae4.zip |
Re-factor web interface part
-rw-r--r-- | web/app/store/DistanceUnits.js | 8 | ||||
-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 | 8 | ||||
-rw-r--r-- | web/app/view/state/StateController.js | 28 |
5 files changed, 19 insertions, 36 deletions
diff --git a/web/app/store/DistanceUnits.js b/web/app/store/DistanceUnits.js index 7f0f93b70..653bf6efb 100644 --- a/web/app/store/DistanceUnits.js +++ b/web/app/store/DistanceUnits.js @@ -25,11 +25,9 @@ Ext.define('Traccar.store.DistanceUnits', { convert: function(value, unit) { switch (unit) { case 'km': - value = value * 0.001; - return Math.round(value * 100) / 100; + return Math.round(value * 0.1) / 100; case 'mi': - value = value * 0.000621371; - return Math.round(value * 100) / 100; + return Math.round(value * 0.0621371) / 100; } return value; }, @@ -40,5 +38,5 @@ Ext.define('Traccar.store.DistanceUnits', { } else { return ''; } - }, + } }); diff --git a/web/app/store/SpeedUnits.js b/web/app/store/SpeedUnits.js index 934d03717..15c52625f 100644 --- a/web/app/store/SpeedUnits.js +++ b/web/app/store/SpeedUnits.js @@ -25,11 +25,9 @@ Ext.define('Traccar.store.SpeedUnits', { convert: function(value, unit) { switch (unit) { case 'kmh': - value = value * 1.852; - return Math.round(value * 10) / 10; + return Math.round(value * 1.852 * 10) / 10; case 'mph': - value = value * 1.15078; - return Math.round(value * 10) / 10; + return Math.round(value * 1.15078 * 10) / 10; } return value; }, diff --git a/web/app/view/main/MainMobile.js b/web/app/view/main/MainMobile.js index 1cdd6f525..f32ad9fb1 100644 --- a/web/app/view/main/MainMobile.js +++ b/web/app/view/main/MainMobile.js @@ -40,11 +40,6 @@ 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 5466c7887..535be942b 100644 --- a/web/app/view/report/Report.js +++ b/web/app/view/report/Report.js @@ -90,14 +90,6 @@ Ext.define('Traccar.view.report.Report', { return speedUnits.convert(value, unit) + ' ' + speedUnits.getUnitName(unit); } }, - /* { text: strings.positionCourse, dataIndex: 'course', flex: 1 }, */ - { text: 'Odometer', 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 685805418..58bc5c55c 100644 --- a/web/app/view/state/StateController.js +++ b/web/app/view/state/StateController.js @@ -59,13 +59,9 @@ Ext.define('Traccar.view.state.StateController', { priority: 6, name: strings.positionSpeed }, -/* 'course': { + 'course': { priority: 7, name: strings.positionCourse - },*/ - 'odometer': { - priority: 7, - name: 'Odometer' }, 'address': { priority: 8, @@ -80,24 +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); } - 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, @@ -114,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 })); } } |