aboutsummaryrefslogtreecommitdiff
path: root/web/app/controller/Root.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-11-07 21:41:51 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-11-07 21:41:51 +1300
commit7d82aeb8f296a8862e9d64eda029c3184bae089b (patch)
tree90e71661c5befbc47d1e2cd04f0cc0664dfa86e1 /web/app/controller/Root.js
parent477375744b788f4ae63cf6cd3812a80b2065a487 (diff)
downloadtrackermap-server-7d82aeb8f296a8862e9d64eda029c3184bae089b.tar.gz
trackermap-server-7d82aeb8f296a8862e9d64eda029c3184bae089b.tar.bz2
trackermap-server-7d82aeb8f296a8862e9d64eda029c3184bae089b.zip
Start map controller refactoring
Diffstat (limited to 'web/app/controller/Root.js')
-rw-r--r--web/app/controller/Root.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index b4ab06b82..94f3234d1 100644
--- a/web/app/controller/Root.js
+++ b/web/app/controller/Root.js
@@ -85,5 +85,34 @@ Ext.define('Traccar.controller.Root', {
} else {
Ext.create('widget.main');
}
+ this.asyncUpdate(true);
+ },
+
+ asyncUpdate: function (first) {
+ Ext.Ajax.request({
+ scope: this,
+ url: '/api/async',
+ params: {
+ first: first
+ },
+ callback: Traccar.app.getErrorHandler(this, function (options, success, response) {
+ var i, store, deviceStore, data;
+ if (success) {
+ store = Ext.getStore('LatestPositions');
+ deviceStore = Ext.getStore('Devices');
+ data = Ext.decode(response.responseText).data;
+
+ for (i = 0; i < data.length; i++) {
+ var found = store.findRecord('deviceId', data[i].deviceId, 0, false, false, true);
+ if (found) {
+ found.set(data[i]);
+ } else {
+ store.add(Ext.create('Traccar.model.Position', data[i]));
+ }
+ }
+ this.asyncUpdate(false);
+ }
+ })
+ });
}
});