diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-10-08 01:03:16 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-08 01:03:16 +1300 |
commit | 4b5f8366b4f5a41591dd1b4627a97c9211c02fb8 (patch) | |
tree | 9bcb019563d7bf511e4186b46f8b11f810b68e41 /web/app/view/ReportController.js | |
parent | a47bf8f3eb6807c4fc9094f6e1e6b62185354b2c (diff) | |
parent | 55a2a72f1260e4a1ca394c31498762d2fb32ec1c (diff) | |
download | trackermap-web-4b5f8366b4f5a41591dd1b4627a97c9211c02fb8.tar.gz trackermap-web-4b5f8366b4f5a41591dd1b4627a97c9211c02fb8.tar.bz2 trackermap-web-4b5f8366b4f5a41591dd1b4627a97c9211c02fb8.zip |
Merge pull request #292 from Abyss777/trip_draw
Draw trip route on click
Diffstat (limited to 'web/app/view/ReportController.js')
-rw-r--r-- | web/app/view/ReportController.js | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 8e1aa711..ff5d32f8 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) { @@ -127,12 +137,27 @@ Ext.define('Traccar.view.ReportController', { } }, - selectReport: function (position, center) { - if (position instanceof Traccar.model.Position) { - this.getView().getSelectionModel().select([position], false, true); + selectReport: function (object, center) { + if (object instanceof Traccar.model.Position) { + this.getView().getSelectionModel().select([object], false, true); + } else if (object instanceof Traccar.model.ReportTrip) { + this.selectTrip(object); } }, + 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') { |