aboutsummaryrefslogtreecommitdiff
path: root/web/app
diff options
context:
space:
mode:
Diffstat (limited to 'web/app')
-rw-r--r--web/app/Application.js10
-rw-r--r--web/app/view/MapMarkerController.js15
-rw-r--r--web/app/view/ReportController.js29
3 files changed, 52 insertions, 2 deletions
diff --git a/web/app/Application.js b/web/app/Application.js
index 8619ba96..bae3896e 100644
--- a/web/app/Application.js
+++ b/web/app/Application.js
@@ -141,5 +141,13 @@ Ext.define('Traccar.Application', {
} else {
Ext.Msg.alert(Strings.errorTitle, Strings.errorConnection);
}
- }
+ },
+
+ removeUrlParameter: function (param) {
+ var params = Ext.Object.fromQueryString(window.location.search);
+ delete params[param];
+ window.history.pushState(null, null, window.location.pathname + '?' + Ext.Object.toQueryString(params));
+ },
+
+ hasEventId: false
});
diff --git a/web/app/view/MapMarkerController.js b/web/app/view/MapMarkerController.js
index 97e75925..9b699c04 100644
--- a/web/app/view/MapMarkerController.js
+++ b/web/app/view/MapMarkerController.js
@@ -225,7 +225,7 @@ Ext.define('Traccar.view.MapMarkerController', {
},
addReportMarkers: function (store, data) {
- var i, position, point, geometry, marker, style;
+ var i, position, point, geometry, marker, style, minx, miny, maxx, maxy;
this.clearReport();
for (i = 0; i < data.length; i++) {
position = data[i];
@@ -233,6 +233,10 @@ Ext.define('Traccar.view.MapMarkerController', {
position.get('longitude'),
position.get('latitude')
]);
+ minx = minx ? Math.min(point[0], minx) : point[0];
+ miny = miny ? Math.min(point[1], miny) : point[1];
+ maxx = maxx ? Math.max(point[0], maxx) : point[0];
+ maxy = maxy ? Math.max(point[1], maxy) : point[1];
geometry = new ol.geom.Point(point);
marker = new ol.Feature(geometry);
marker.set('record', position);
@@ -243,6 +247,15 @@ Ext.define('Traccar.view.MapMarkerController', {
this.reportMarkers[position.get('id')] = marker;
this.getView().getReportSource().addFeature(marker);
}
+ if (minx !== maxx || miny !== maxy) {
+ this.getView().getMapView().fit([minx, miny, maxx, maxy], this.getView().getMap().getSize());
+ } else if (geometry) {
+ this.getView().getMapView().fit(geometry, this.getView().getMap().getSize());
+ }
+ if (Traccar.app.hasEventId) {
+ this.fireEvent('selectreport', data[0], false);
+ Traccar.app.hasEventId = false;
+ }
},
clearReport: function () {
diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js
index f8a01bc6..32a44df5 100644
--- a/web/app/view/ReportController.js
+++ b/web/app/view/ReportController.js
@@ -40,12 +40,32 @@ Ext.define('Traccar.view.ReportController', {
},
store: {
'#ReportEvents': {
+ add: 'loadEvents',
load: 'loadEvents'
}
}
}
},
+ init: function () {
+ var eventId = Ext.Object.fromQueryString(window.location.search).eventId;
+ if (eventId) {
+ this.lookupReference('reportTypeField').setValue('events');
+ Ext.getStore('Events').load({
+ params: {
+ id: eventId
+ },
+ callback: function (records, operation, success) {
+ if (success) {
+ Ext.getStore('ReportEvents').add(records);
+ }
+ }
+ });
+ Traccar.app.hasEventId = true;
+ Traccar.app.removeUrlParameter('eventId');
+ }
+ },
+
hideReports: function () {
Traccar.app.showReports(false);
},
@@ -214,6 +234,15 @@ Ext.define('Traccar.view.ReportController', {
}
}
});
+ } else if (Traccar.app.hasEventId && data.length > 0) {
+ this.getView().getSelectionModel().select([data[0]], false, true);
+ this.getView().getView().focusRow(data[0]);
+ if (Traccar.app.isMobile()) {
+ Traccar.app.showReports(true);
+ } else {
+ this.getView().expand();
+ }
+ Traccar.app.hasEventId = false;
}
},