aboutsummaryrefslogtreecommitdiff
path: root/web/app
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-06-21 17:35:25 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-06-21 17:35:25 +1200
commite36f444cac7abef61dd63a7104f17e6b8de1637c (patch)
tree801f93bca1e18d441a19d43bf1a427ab52c8bfde /web/app
parent4a4b947cbbff599100e937400384b913b9152909 (diff)
downloadtraccar-server-e36f444cac7abef61dd63a7104f17e6b8de1637c.tar.gz
traccar-server-e36f444cac7abef61dd63a7104f17e6b8de1637c.tar.bz2
traccar-server-e36f444cac7abef61dd63a7104f17e6b8de1637c.zip
Implement parameters ordering
Diffstat (limited to 'web/app')
-rw-r--r--web/app/model/Parameter.js1
-rw-r--r--web/app/store/Parameters.js6
-rw-r--r--web/app/view/map/MapController.js7
-rw-r--r--web/app/view/state/StateController.js55
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);
}
}