diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-06-21 17:35:25 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-06-21 17:35:25 +1200 |
commit | e36f444cac7abef61dd63a7104f17e6b8de1637c (patch) | |
tree | 801f93bca1e18d441a19d43bf1a427ab52c8bfde | |
parent | 4a4b947cbbff599100e937400384b913b9152909 (diff) | |
download | trackermap-server-e36f444cac7abef61dd63a7104f17e6b8de1637c.tar.gz trackermap-server-e36f444cac7abef61dd63a7104f17e6b8de1637c.tar.bz2 trackermap-server-e36f444cac7abef61dd63a7104f17e6b8de1637c.zip |
Implement parameters ordering
-rw-r--r-- | web/app/model/Parameter.js | 1 | ||||
-rw-r--r-- | web/app/store/Parameters.js | 6 | ||||
-rw-r--r-- | web/app/view/map/MapController.js | 7 | ||||
-rw-r--r-- | web/app/view/state/StateController.js | 55 |
4 files changed, 51 insertions, 18 deletions
diff --git a/web/app/model/Parameter.js b/web/app/model/Parameter.js index 6310f4aee..b08156a2a 100644 --- a/web/app/model/Parameter.js +++ b/web/app/model/Parameter.js @@ -18,6 +18,7 @@ Ext.define('Traccar.model.Parameter', { extend: 'Ext.data.Model', fields: [ + { name: 'priority', type: 'int' }, { name: 'name', type: 'string' }, { name: 'value', type: 'string' } ] diff --git a/web/app/store/Parameters.js b/web/app/store/Parameters.js index 508dabc97..8b34d465b 100644 --- a/web/app/store/Parameters.js +++ b/web/app/store/Parameters.js @@ -16,5 +16,9 @@ Ext.define('Traccar.store.Parameters', { extend: 'Ext.data.Store', - model: 'Traccar.model.Parameter' + model: 'Traccar.model.Parameter', + + sorters: [{ + property: 'priority' + }] }); diff --git a/web/app/view/map/MapController.js b/web/app/view/map/MapController.js index cad8f502a..cbe3ea6c3 100644 --- a/web/app/view/map/MapController.js +++ b/web/app/view/map/MapController.js @@ -49,16 +49,11 @@ Ext.define('Traccar.view.map.MapController', { var i; for (i = 0; i < data.length; i++) { - // TODO check if exists and update var store = Ext.getStore('LiveData'); var found = store.query('deviceId', data[i].deviceId); if (found.getCount() > 0) { - var model = found.first(); - model.set(data[i]); - - //store.commitChanges(); need for update? - + found.first().set(data[i]); } else { store.add(Ext.create('Traccar.model.Position', data[i])); } diff --git a/web/app/view/state/StateController.js b/web/app/view/state/StateController.js index 15f0639ba..fc23bbe96 100644 --- a/web/app/view/state/StateController.js +++ b/web/app/view/state/StateController.js @@ -35,14 +35,38 @@ Ext.define('Traccar.view.state.StateController', { }, keys: { - 'fixTime': strings.report_time, - 'latitude': strings.report_latitude, - 'longitude': strings.report_longitude, - 'valid': strings.report_valid, - 'altitude': strings.report_altitude, - 'speed': strings.report_speed, - 'course': strings.report_course, - 'protocol': strings.state_protocol + 'fixTime': { + priority: 1, + name: strings.report_time + }, + 'latitude': { + priority: 2, + name: strings.report_latitude + }, + 'longitude': { + priority: 3, + name: strings.report_longitude + }, + 'valid': { + priority: 4, + name: strings.report_valid + }, + 'altitude': { + priority: 5, + name: strings.report_altitude + }, + 'speed': { + priority: 6, + name: strings.report_speed + }, + 'course': { + priority: 7, + name: strings.report_course + }, + 'protocol': { + priority: 8, + name: strings.state_protocol + } }, updatePosition: function(position) { @@ -53,11 +77,20 @@ Ext.define('Traccar.view.state.StateController', { for (var key in position.data) { if (position.data.hasOwnProperty(key) && this.keys[key] !== undefined) { store.add(Ext.create('Traccar.model.Parameter', { - name: this.keys[key], + priority: this.keys[key].priority, + name: this.keys[key].name, value: position.get(key) })); } } + + // TODO: decode XML + var xml = position.get('other'); + store.add(Ext.create('Traccar.model.Parameter', { + priority: 99, + name: 'Other', + value: xml + })); }, selectDevice: function(device) { @@ -75,8 +108,8 @@ Ext.define('Traccar.view.state.StateController', { }, update: function(store, data) { - if (this.deviceId === data[0].get('deviceId')) { - this.updatePosition(data[0]); + if (this.deviceId === data.get('deviceId')) { + this.updatePosition(data); } } |