From e36f444cac7abef61dd63a7104f17e6b8de1637c Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 21 Jun 2015 17:35:25 +1200 Subject: Implement parameters ordering --- web/app/model/Parameter.js | 1 + web/app/store/Parameters.js | 6 +++- web/app/view/map/MapController.js | 7 +---- web/app/view/state/StateController.js | 55 ++++++++++++++++++++++++++++------- 4 files changed, 51 insertions(+), 18 deletions(-) (limited to 'web/app') 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); } } -- cgit v1.2.3