diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-11-17 15:52:39 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-11-17 15:52:39 +1300 |
commit | b247a05d4cc34cf587fc0b4299692d401124055a (patch) | |
tree | 2865e78e19fae20f4961898c4ad54038d24457e0 /web/app/controller/Root.js | |
parent | 5e56a1fbf80033cf5cc30ec7767d3cd92ab41cde (diff) | |
download | trackermap-server-b247a05d4cc34cf587fc0b4299692d401124055a.tar.gz trackermap-server-b247a05d4cc34cf587fc0b4299692d401124055a.tar.bz2 trackermap-server-b247a05d4cc34cf587fc0b4299692d401124055a.zip |
Show last update in the status table
Diffstat (limited to 'web/app/controller/Root.js')
-rw-r--r-- | web/app/controller/Root.js | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 041e0b902..733055cdf 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -97,19 +97,32 @@ Ext.define('Traccar.controller.Root', { first: first }, callback: Traccar.app.getErrorHandler(this, function (options, success, response) { - var i, store, data, devices, positions, 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 < 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 = store.findRecord('deviceId', positions[i].deviceId, 0, false, false, true); + position = positionStore.findRecord('deviceId', positions[i].deviceId, 0, false, false, true); if (position) { position.set(positions[i]); } else { - store.add(Ext.create('Traccar.model.Position', positions[i])); + positionStore.add(Ext.create('Traccar.model.Position', positions[i])); } } |