From 42574b6700384bd8a45d3410c4f8da644dad112e Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 1 Dec 2016 17:30:50 +0500 Subject: Implement in other way --- web/app/controller/Root.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'web/app/controller') diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 5600d4e8..379a0d8a 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -75,7 +75,7 @@ Ext.define('Traccar.controller.Root', { }, loadApp: function () { - var attribution; + var attribution, eventId; Ext.getStore('Groups').load(); Ext.getStore('Geofences').load(); Ext.getStore('AttributeAliases').load(); @@ -94,6 +94,11 @@ Ext.define('Traccar.controller.Root', { } else { Ext.create('widget.main'); } + eventId = Ext.Object.fromQueryString(window.location.search).eventId; + if (eventId) { + this.application.fireEvent('showSingleEvent', eventId); + //this.removeUrlParameter('eventId'); + } }, beep: function () { @@ -108,6 +113,12 @@ Ext.define('Traccar.controller.Root', { return muteButton && !muteButton.pressed; }, + 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)); + }, + asyncUpdate: function (first) { var protocol, pathname, socket, self = this; protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; -- cgit v1.2.3 From 1aae9dee5ecd797c3c2d2a6e985f605d783620ee Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 1 Dec 2016 18:05:10 +0500 Subject: Improve firing event --- web/app/controller/Root.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/app/controller') diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 379a0d8a..1e83a45f 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -96,7 +96,7 @@ Ext.define('Traccar.controller.Root', { } eventId = Ext.Object.fromQueryString(window.location.search).eventId; if (eventId) { - this.application.fireEvent('showSingleEvent', eventId); + this.fireEvent('showsingleevent', eventId); //this.removeUrlParameter('eventId'); } }, -- cgit v1.2.3 From ea09b2e85e014d438084a454fae7c0cce57d9773 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 2 Dec 2016 09:29:08 +0700 Subject: - Remove single event - Redo ol.extent calculation with less compares - Uncomment url manipulation --- web/app/controller/Root.js | 2 +- web/app/view/MapMarkerController.js | 13 +++++++++---- web/app/view/ReportController.js | 4 +--- 3 files changed, 11 insertions(+), 8 deletions(-) (limited to 'web/app/controller') diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 1e83a45f..87c4cf5e 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -97,7 +97,7 @@ Ext.define('Traccar.controller.Root', { eventId = Ext.Object.fromQueryString(window.location.search).eventId; if (eventId) { this.fireEvent('showsingleevent', eventId); - //this.removeUrlParameter('eventId'); + this.removeUrlParameter('eventId'); } }, diff --git a/web/app/view/MapMarkerController.js b/web/app/view/MapMarkerController.js index a526d912..5fa9f4ca 100644 --- a/web/app/view/MapMarkerController.js +++ b/web/app/view/MapMarkerController.js @@ -229,10 +229,15 @@ 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]; + if (i === 0) { + minx = maxx = point[0]; + miny = maxy = point[1]; + } else { + minx = Math.min(point[0], minx); + miny = Math.min(point[1], miny); + maxx = Math.max(point[0], maxx); + maxy = Math.max(point[1], maxy); + } geometry = new ol.geom.Point(point); marker = new ol.Feature(geometry); marker.set('record', position); diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 2ad2bdda..1f3f3a2a 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -214,8 +214,7 @@ Ext.define('Traccar.view.ReportController', { callback: function (records, operation, success) { if (success) { Ext.getStore('ReportRoute').add(records); - if (this.singleEvent && records.length > 0) { - this.singleEvent = false; + if (records.length === 1) { this.fireEvent('selectreport', records[0], false); } } @@ -225,7 +224,6 @@ Ext.define('Traccar.view.ReportController', { }, showSingleEvent: function (eventId) { - this.singleEvent = true; this.lookupReference('reportTypeField').setValue('events'); Ext.getStore('Events').load({ id: eventId, -- cgit v1.2.3