aboutsummaryrefslogtreecommitdiff
path: root/web/app/view/ReportController.js
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-06-14 11:34:18 +0500
committerAbyss777 <abyss@fox5.ru>2017-06-15 08:59:37 +0500
commitb22bd25a611304d63f270633b7e83969b6506f15 (patch)
treee143f40a1a974648f1eb1a2c7ec67de01411cab8 /web/app/view/ReportController.js
parenta330ae09293c62aae381cb2c7f36cfa76b86e813 (diff)
downloadtrackermap-web-b22bd25a611304d63f270633b7e83969b6506f15.tar.gz
trackermap-web-b22bd25a611304d63f270633b7e83969b6506f15.tar.bz2
trackermap-web-b22bd25a611304d63f270633b7e83969b6506f15.zip
Implement Stops report
Diffstat (limited to 'web/app/view/ReportController.js')
-rw-r--r--web/app/view/ReportController.js74
1 files changed, 56 insertions, 18 deletions
diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js
index 3daa2957..36eceb0f 100644
--- a/web/app/view/ReportController.js
+++ b/web/app/view/ReportController.js
@@ -42,11 +42,14 @@ Ext.define('Traccar.view.ReportController', {
},
store: {
'#ReportEvents': {
- add: 'loadEvents',
- load: 'loadEvents'
+ add: 'loadRelatedPositions',
+ load: 'loadRelatedPositions'
},
'#ReportRoute': {
load: 'loadRoute'
+ },
+ '#ReportStops': {
+ load: 'loadRelatedPositions'
}
}
}
@@ -173,7 +176,7 @@ Ext.define('Traccar.view.ReportController', {
clearReport: function (reportType) {
this.getGrid().getStore().removeAll();
- if (reportType === 'trips' || reportType === 'events') {
+ if (reportType === 'trips' || reportType === 'events' || reportType === 'stops') {
Ext.getStore('ReportRoute').removeAll();
}
if (reportType === 'chart') {
@@ -189,8 +192,8 @@ Ext.define('Traccar.view.ReportController', {
if (report instanceof Traccar.model.ReportTrip) {
this.selectTrip(report);
}
- if (report instanceof Traccar.model.Event) {
- this.selectEvent(report);
+ if (report instanceof Traccar.model.Event || report instanceof Traccar.model.ReportStop) {
+ this.selectPositionRelated(report);
}
}
},
@@ -202,15 +205,15 @@ Ext.define('Traccar.view.ReportController', {
},
selectReport: function (object, center) {
- var positionEvent, reportType = this.lookupReference('reportTypeField').getValue();
+ var positionRelated, reportType = this.lookupReference('reportTypeField').getValue();
if (object instanceof Traccar.model.Position) {
if (reportType === 'route') {
this.getGrid().getSelectionModel().select([object], false, true);
this.getGrid().getView().focusRow(object);
- } else if (reportType === 'events') {
- positionEvent = this.getGrid().getStore().findRecord('positionId', object.get('id'), 0, false, true, true);
- this.getGrid().getSelectionModel().select([positionEvent], false, true);
- this.getGrid().getView().focusRow(positionEvent);
+ } else if (reportType === 'events' || reportType === 'stops') {
+ positionRelated = this.getGrid().getStore().findRecord('positionId', object.get('id'), 0, false, true, true);
+ this.getGrid().getSelectionModel().select([positionRelated], false, true);
+ this.getGrid().getView().focusRow(positionRelated);
}
}
},
@@ -236,23 +239,23 @@ Ext.define('Traccar.view.ReportController', {
});
},
- selectEvent: function (event) {
+ selectPositionRelated: function (report) {
var position;
- if (event.get('positionId')) {
- position = Ext.getStore('ReportRoute').getById(event.get('positionId'));
+ if (report.get('positionId')) {
+ position = Ext.getStore('ReportRoute').getById(report.get('positionId'));
if (position) {
this.fireEvent('selectreport', position, true);
}
}
},
- loadEvents: function (store, data) {
- var i, eventObject, positionIds = [];
+ loadRelatedPositions: function (store, data) {
+ var i, reportObject, positionIds = [];
Ext.getStore('ReportRoute').removeAll();
for (i = 0; i < data.length; i++) {
- eventObject = data[i];
- if (eventObject.get('positionId')) {
- positionIds.push(eventObject.get('positionId'));
+ reportObject = data[i];
+ if (reportObject.get('positionId')) {
+ positionIds.push(reportObject.get('positionId'));
}
}
if (positionIds.length > 0) {
@@ -390,6 +393,9 @@ Ext.define('Traccar.view.ReportController', {
} else if (newValue === 'trips') {
this.getGrid().reconfigure('ReportTrips', this.tripsColumns);
this.getView().getLayout().setActiveItem('grid');
+ } else if (newValue === 'stops') {
+ this.getGrid().reconfigure('ReportStops', this.stopsColumns);
+ this.getView().getLayout().setActiveItem('grid');
} else if (newValue === 'chart') {
this.getView().getLayout().setActiveItem('chart');
}
@@ -525,5 +531,37 @@ Ext.define('Traccar.view.ReportController', {
text: Strings.reportSpentFuel,
dataIndex: 'spentFuel',
renderer: Traccar.AttributeFormatter.getFormatter('spentFuel')
+ }],
+
+ stopsColumns: [{
+ text: Strings.reportDeviceName,
+ dataIndex: 'deviceId',
+ renderer: Traccar.AttributeFormatter.getFormatter('deviceId')
+ }, {
+ text: Strings.reportStartTime,
+ dataIndex: 'startTime',
+ xtype: 'datecolumn',
+ renderer: Traccar.AttributeFormatter.getFormatter('startTime')
+ }, {
+ text: Strings.positionAddress,
+ dataIndex: 'address',
+ renderer: Traccar.AttributeFormatter.getFormatter('address')
+ }, {
+ text: Strings.reportEndTime,
+ dataIndex: 'endTime',
+ xtype: 'datecolumn',
+ renderer: Traccar.AttributeFormatter.getFormatter('endTime')
+ }, {
+ text: Strings.reportDuration,
+ dataIndex: 'duration',
+ renderer: Traccar.AttributeFormatter.getFormatter('duration')
+ }, {
+ text: Strings.reportEngineHours,
+ dataIndex: 'engineHours',
+ renderer: Traccar.AttributeFormatter.getFormatter('duration')
+ }, {
+ text: Strings.reportSpentFuel,
+ dataIndex: 'spentFuel',
+ renderer: Traccar.AttributeFormatter.getFormatter('spentFuel')
}]
});