aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-11-08 13:31:04 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-11-08 13:31:04 +1300
commitea38e23c5c19f953d5db5107a56d697d31deef95 (patch)
tree1d1efb325ef009e805e6051932e3160f0f484eaa /web
parentd2f8ca9cb1dae87591de1b5e6037c78c15d23d2a (diff)
downloadtrackermap-server-ea38e23c5c19f953d5db5107a56d697d31deef95.tar.gz
trackermap-server-ea38e23c5c19f953d5db5107a56d697d31deef95.tar.bz2
trackermap-server-ea38e23c5c19f953d5db5107a56d697d31deef95.zip
Display state info from reports
Diffstat (limited to 'web')
-rw-r--r--web/app/view/StateController.js42
1 files changed, 25 insertions, 17 deletions
diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js
index e2b80643d..01df6645d 100644
--- a/web/app/view/StateController.js
+++ b/web/app/view/StateController.js
@@ -28,8 +28,11 @@ Ext.define('Traccar.view.StateController', {
},
store: {
'#LatestPositions': {
- add: 'update',
- update: 'update'
+ add: 'updateLatest',
+ update: 'updateLatest'
+ },
+ '#Positions': {
+ clear: 'clearReport'
}
}
}
@@ -50,6 +53,18 @@ Ext.define('Traccar.view.StateController', {
return result;
}()),
+ updateLatest: function (store, data) {
+ var i;
+ if (!Ext.isArray(data)) {
+ data = [data];
+ }
+ for (i = 0; i < data.length; i++) {
+ if (this.deviceId === data[i].get('deviceId')) {
+ this.updatePosition(data[i]);
+ }
+ }
+ },
+
formatValue: function (value) {
if (typeof (id) === 'number') {
return Number(value.toFixed(2));
@@ -90,29 +105,22 @@ Ext.define('Traccar.view.StateController', {
},
selectDevice: function (device) {
- var found;
+ var position;
this.deviceId = device.get('id');
- found = Ext.getStore('LatestPositions').findRecord('deviceId', this.deviceId, 0, false, false, true);
- if (found) {
- this.updatePosition(found);
+ position = Ext.getStore('LatestPositions').findRecord('deviceId', this.deviceId, 0, false, false, true);
+ if (position) {
+ this.updatePosition(position);
} else {
Ext.getStore('Attributes').removeAll();
}
},
selectReport: function (position) {
- console.log(position);
+ this.deviceId = null;
+ this.updatePosition(position);
},
- update: function (store, data) {
- var i;
- if (!Ext.isArray(data)) {
- data = [data];
- }
- for (i = 0; i < data.length; i++) {
- if (this.deviceId === data[i].get('deviceId')) {
- this.updatePosition(data[0]);
- }
- }
+ clearReport: function (store) {
+ Ext.getStore('Attributes').removeAll();
}
});