From 3ad3edfadba59e94d95e967e9d5cd28ae671cae4 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 18 Aug 2015 13:47:52 +1200 Subject: Re-factor web interface part --- web/app/view/state/StateController.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'web/app/view/state') 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 })); } } -- cgit v1.2.3