From 72e80e7a45ffdc149bd440c0f864f34492e8e994 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 19 Jun 2015 22:11:45 +1200 Subject: Update live data store --- web/app/view/map/MapController.js | 7 ++++++- web/app/view/state/StateController.js | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'web/app/view') diff --git a/web/app/view/map/MapController.js b/web/app/view/map/MapController.js index 9e009218e..8b9a34b28 100644 --- a/web/app/view/map/MapController.js +++ b/web/app/view/map/MapController.js @@ -48,7 +48,12 @@ 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'); + store.add(Ext.create('Traccar.model.Position', data[i])); + //store.commitChanges(); need for update? + var geometry = new ol.geom.Point(ol.proj.fromLonLat([ data[i].longitude, data[i].latitude diff --git a/web/app/view/state/StateController.js b/web/app/view/state/StateController.js index f85381237..be1d713f1 100644 --- a/web/app/view/state/StateController.js +++ b/web/app/view/state/StateController.js @@ -29,6 +29,9 @@ Ext.define('Traccar.view.state.StateController', { }, init: function() { + var store = Ext.getStore('LiveData'); + store.on('add', this.add); + store.on('update', this.update); }, keys: { @@ -69,6 +72,14 @@ Ext.define('Traccar.view.state.StateController', { })); } } + }, + + add: function(store, data) { + console.log(data); + }, + + update: function(store, data) { + console.log(data); } }); -- cgit v1.2.3