aboutsummaryrefslogtreecommitdiff
path: root/web/app/view/state
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-06-21 11:06:00 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-06-21 11:06:00 +1200
commitfd43b679f833f9632889bea91d3a28516a85d2a7 (patch)
treed5f45e708a35826e3d61430303c6310451c68b23 /web/app/view/state
parentd49b79c48f6ff6aab6bf16d3be9b353e674e3fa0 (diff)
downloadtrackermap-server-fd43b679f833f9632889bea91d3a28516a85d2a7.tar.gz
trackermap-server-fd43b679f833f9632889bea91d3a28516a85d2a7.tar.bz2
trackermap-server-fd43b679f833f9632889bea91d3a28516a85d2a7.zip
Implement point selection logic
Diffstat (limited to 'web/app/view/state')
-rw-r--r--web/app/view/state/StateController.js38
1 files changed, 18 insertions, 20 deletions
diff --git a/web/app/view/state/StateController.js b/web/app/view/state/StateController.js
index be1d713f1..15f0639ba 100644
--- a/web/app/view/state/StateController.js
+++ b/web/app/view/state/StateController.js
@@ -45,41 +45,39 @@ Ext.define('Traccar.view.state.StateController', {
'protocol': strings.state_protocol
},
- selectDevice: function(device) {
- var position = {
- "fixTime":"2012-01-02T01:50:00",
- "longitude":130.0,
- "latitude":60.0,
- "valid":true,
- "altitude":0.0,
- "speed":0.0,
- "course":0.0,
- "deviceId":1,
- "other":"<info><status>84-20</status></info>",
- "deviceTime":"2012-01-02T01:50:00",
- "id":29,
- "protocol":"gotop"
- };
+ updatePosition: function(position) {
var store = Ext.getStore('Parameters');
store.removeAll();
- for (var key in position) {
- if (position.hasOwnProperty(key) && this.keys[key] !== undefined) {
+ 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],
- value: position[key]
+ value: position.get(key)
}));
}
}
},
+ selectDevice: function(device) {
+ this.deviceId = device.get('id');
+ var found = Ext.getStore('LiveData').query('deviceId', this.deviceId);
+ if (found.getCount() > 0) {
+ this.updatePosition(found.first());
+ }
+ },
+
add: function(store, data) {
- console.log(data);
+ if (this.deviceId === data[0].get('deviceId')) {
+ this.updatePosition(data[0]);
+ }
},
update: function(store, data) {
- console.log(data);
+ if (this.deviceId === data[0].get('deviceId')) {
+ this.updatePosition(data[0]);
+ }
}
});