mirror of
https://github.com/traccar/traccar.git
synced 2026-02-05 13:13:55 -05:00
Display state info from reports
This commit is contained in:
@@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user