diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-11-30 19:25:46 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-30 19:25:46 +1300 |
commit | 1ffe251cbc09e2199c936d68f5c1f82363436da1 (patch) | |
tree | 0a1962ef178fa3c051c28e95b9a0101ed1d12e19 /web/app/view/ReportController.js | |
parent | d10d51eb9def4e9ce77d053503ba3eccd3ad23aa (diff) | |
parent | 60fe1537206e2286423a7bc1ed5591b1f9c7a1d7 (diff) | |
download | trackermap-web-1ffe251cbc09e2199c936d68f5c1f82363436da1.tar.gz trackermap-web-1ffe251cbc09e2199c936d68f5c1f82363436da1.tar.bz2 trackermap-web-1ffe251cbc09e2199c936d68f5c1f82363436da1.zip |
Merge pull request #345 from Abyss777/show_events
Show events on map
Diffstat (limited to 'web/app/view/ReportController.js')
-rw-r--r-- | web/app/view/ReportController.js | 57 |
1 files changed, 52 insertions, 5 deletions
diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 8f8cf741..f8a01bc6 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -37,6 +37,11 @@ Ext.define('Traccar.view.ReportController', { 'map': { selectreport: 'selectReport' } + }, + store: { + '#ReportEvents': { + load: 'loadEvents' + } } } }, @@ -126,7 +131,7 @@ Ext.define('Traccar.view.ReportController', { clearReport: function (reportType) { this.getView().getStore().removeAll(); - if (reportType === 'trips') { + if (reportType === 'trips' || reportType === 'events') { Ext.getStore('ReportRoute').removeAll(); } }, @@ -139,6 +144,9 @@ Ext.define('Traccar.view.ReportController', { if (report instanceof Traccar.model.ReportTrip) { this.selectTrip(report); } + if (report instanceof Traccar.model.Event) { + this.selectEvent(report); + } } }, @@ -149,10 +157,16 @@ Ext.define('Traccar.view.ReportController', { }, selectReport: function (object, center) { - var reportType = this.lookupReference('reportTypeField').getValue(); - if (object instanceof Traccar.model.Position && reportType === 'route') { - this.getView().getSelectionModel().select([object], false, true); - this.getView().getView().focusRow(object); + var positionEvent, reportType = this.lookupReference('reportTypeField').getValue(); + if (object instanceof Traccar.model.Position) { + if (reportType === 'route') { + this.getView().getSelectionModel().select([object], false, true); + this.getView().getView().focusRow(object); + } else if (reportType === 'events') { + positionEvent = this.getView().getStore().findRecord('positionId', object.get('id'), 0, false, true, true); + this.getView().getSelectionModel().select([positionEvent], false, true); + this.getView().getView().focusRow(positionEvent); + } } }, @@ -170,6 +184,39 @@ Ext.define('Traccar.view.ReportController', { }); }, + selectEvent: function (event) { + var position; + if (event.get('positionId')) { + position = Ext.getStore('ReportRoute').getById(event.get('positionId')); + if (position) { + this.fireEvent('selectreport', position, true); + } + } + }, + + loadEvents: function (store, data) { + var i, eventObject, positionIds = []; + Ext.getStore('ReportRoute').removeAll(); + for (i = 0; i < data.length; i++) { + eventObject = data[i]; + if (eventObject.get('positionId')) { + positionIds.push(eventObject.get('positionId')); + } + } + if (positionIds.length > 0) { + Ext.getStore('Positions').load({ + params: { + id: positionIds + }, + callback: function (records, operation, success) { + if (success) { + Ext.getStore('ReportRoute').add(records); + } + } + }); + } + }, + downloadFile: function (requestUrl, requestParams) { Ext.Ajax.request({ url: requestUrl, |