diff options
Diffstat (limited to 'web/app/view/ReportController.js')
-rw-r--r-- | web/app/view/ReportController.js | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 8e1aa711..fefa88a8 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -22,6 +22,8 @@ Ext.define('Traccar.view.ReportController', { requires: [ 'Traccar.AttributeFormatter', + 'Traccar.model.Position', + 'Traccar.model.ReportTrip', 'Traccar.view.ReportConfigDialog', 'Traccar.store.ReportEventTypes' ], @@ -112,7 +114,15 @@ Ext.define('Traccar.view.ReportController', { }, onClearClick: function () { + var reportType = this.lookupReference('reportTypeField').getValue(); + this.clearReport(reportType); + }, + + clearReport: function (reportType) { this.getView().getStore().removeAll(); + if (reportType === 'trips') { + Ext.getStore('ReportRoute').removeAll(); + } }, onSelectionChange: function (selected) { @@ -130,9 +140,24 @@ Ext.define('Traccar.view.ReportController', { selectReport: function (position, center) { if (position instanceof Traccar.model.Position) { this.getView().getSelectionModel().select([position], false, true); + } else if (position instanceof Traccar.model.ReportTrip) { + this.selectTrip(position); } }, + selectTrip: function (trip) { + var from, to; + from = new Date(trip.get('startTime')); + to = new Date(trip.get('endTime')); + Ext.getStore('ReportRoute').load({ + params: { + deviceId: trip.get('deviceId'), + from: from.toISOString(), + to: to.toISOString() + } + }); + }, + downloadCsv: function (requestUrl, requestParams) { Ext.Ajax.request({ url: requestUrl, @@ -170,7 +195,7 @@ Ext.define('Traccar.view.ReportController', { onTypeChange: function (combobox, newValue, oldValue) { if (oldValue !== null) { - this.onClearClick(); + this.clearReport(oldValue); } if (newValue === 'route') { |