aboutsummaryrefslogtreecommitdiff
path: root/web/app
diff options
context:
space:
mode:
Diffstat (limited to 'web/app')
-rw-r--r--web/app/view/MapController.js9
-rw-r--r--web/app/view/ReportController.js33
-rw-r--r--web/app/view/StateController.js9
3 files changed, 43 insertions, 8 deletions
diff --git a/web/app/view/MapController.js b/web/app/view/MapController.js
index ac2188e..59fd285 100644
--- a/web/app/view/MapController.js
+++ b/web/app/view/MapController.js
@@ -19,6 +19,11 @@ Ext.define('Traccar.view.MapController', {
extend: 'Ext.app.ViewController',
alias: 'controller.map',
+ requires: [
+ 'Traccar.model.Position',
+ 'Traccar.model.Device'
+ ],
+
config: {
listen: {
controller: {
@@ -294,7 +299,9 @@ Ext.define('Traccar.view.MapController', {
},
selectReport: function (position, center) {
- this.selectMarker(this.reportMarkers[position.get('id')], center);
+ if (position instanceof Traccar.model.Position) {
+ this.selectMarker(this.reportMarkers[position.get('id')], center);
+ }
},
selectFeature: function (feature) {
diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js
index 8e1aa71..ff5d32f 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') {
diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js
index 8a19494..b018808 100644
--- a/web/app/view/StateController.js
+++ b/web/app/view/StateController.js
@@ -23,6 +23,7 @@ Ext.define('Traccar.view.StateController', {
'Traccar.AttributeFormatter',
'Traccar.model.Attribute',
'Traccar.model.AttributeAlias',
+ 'Traccar.model.Position',
'Traccar.view.AttributeAliasDialog'
],
@@ -149,9 +150,11 @@ Ext.define('Traccar.view.StateController', {
},
selectReport: function (position) {
- this.deviceId = null;
- this.position = position;
- this.updatePosition();
+ if (position instanceof Traccar.model.Position) {
+ this.deviceId = null;
+ this.position = position;
+ this.updatePosition();
+ }
},
clearReport: function (store) {