diff options
author | Rafael Guterres <guterresrafael@gmail.com> | 2015-11-21 02:13:24 -0200 |
---|---|---|
committer | Rafael Guterres <guterresrafael@gmail.com> | 2015-11-21 02:13:24 -0200 |
commit | 77cd23da84ebebcf99a97a8aef88aa9a4884ca40 (patch) | |
tree | f95fa042b4755e925be8d0c8416fcb648ea23aa3 /web/app/controller/Root.js | |
parent | f5a266953e53a7f1785bcb584759582621ec9de3 (diff) | |
parent | 7623704e12a3e60420c86add5cfdc18b14061752 (diff) | |
download | trackermap-server-77cd23da84ebebcf99a97a8aef88aa9a4884ca40.tar.gz trackermap-server-77cd23da84ebebcf99a97a8aef88aa9a4884ca40.tar.bz2 trackermap-server-77cd23da84ebebcf99a97a8aef88aa9a4884ca40.zip |
Merge tananaev/master
Diffstat (limited to 'web/app/controller/Root.js')
-rw-r--r-- | web/app/controller/Root.js | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 79827b8a6..733055cdf 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -40,6 +40,7 @@ Ext.define('Traccar.controller.Root', { onServerReturn: function (options, success, response) { var result; + Ext.get('spinner').remove(); if (Traccar.ErrorManager.check(success, response)) { result = Ext.decode(response.responseText); if (result.success) { @@ -96,19 +97,35 @@ Ext.define('Traccar.controller.Root', { first: first }, callback: Traccar.app.getErrorHandler(this, function (options, success, response) { - var i, store, data, position; + var i, deviceStore, positionStore, data, devices, positions, device, position; if (success) { - store = Ext.getStore('LatestPositions'); + deviceStore = Ext.getStore('Devices'); + positionStore = Ext.getStore('LatestPositions'); data = Ext.decode(response.responseText).data; + devices = data.devices; + positions = data.positions; - for (i = 0; i < data.length; i++) { - position = store.findRecord('deviceId', data[i].deviceId, 0, false, false, true); + for (i = 0; i < devices.length; i++) { + device = deviceStore.findRecord('id', devices[i].id, 0, false, false, true); + if (device) { + device.set({ + status: devices[i].status, + lastUpdate: devices[i].lastUpdate + }, { + dirty: false + }); + } + } + + for (i = 0; i < positions.length; i++) { + position = positionStore.findRecord('deviceId', positions[i].deviceId, 0, false, false, true); if (position) { - position.set(data[i]); + position.set(positions[i]); } else { - store.add(Ext.create('Traccar.model.Position', data[i])); + positionStore.add(Ext.create('Traccar.model.Position', positions[i])); } } + this.asyncUpdate(false); } }) |