From fd4029af507afac83fa5db4b863b26ac2e205bd3 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 9 Aug 2017 16:04:20 +0500 Subject: Select device on load if there is deviceId url parameter --- web/app/controller/Root.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'web/app/controller/Root.js') diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index d85102a7..902ef215 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -17,6 +17,7 @@ Ext.define('Traccar.controller.Root', { extend: 'Ext.app.Controller', + alias: 'controller.root', requires: [ 'Traccar.view.dialog.Login', @@ -225,7 +226,7 @@ Ext.define('Traccar.controller.Root', { }, updatePositions: function (array, first) { - var i, store, entity; + var i, store, entity, deviceId, device; store = Ext.getStore('LatestPositions'); for (i = 0; i < array.length; i++) { entity = store.findRecord('deviceId', array[i].deviceId, 0, false, false, true); @@ -239,7 +240,16 @@ Ext.define('Traccar.controller.Root', { } } if (first) { - this.zoomToAllDevices(); + deviceId = Ext.Object.fromQueryString(window.location.search).deviceId; + if (deviceId) { + device = Ext.getStore('Devices').getById(deviceId); + if (device) { + this.fireEvent('selectdevice', device, true); + } + } + if (!device) { + this.zoomToAllDevices(); + } } }, -- cgit v1.2.3 From 959797ec42f8ac770531c73101aa716c1a7b08fa Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 9 Aug 2017 16:19:34 +0500 Subject: Select only visible device --- web/app/controller/Root.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/app/controller/Root.js') diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 902ef215..baba68a1 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -242,7 +242,7 @@ Ext.define('Traccar.controller.Root', { if (first) { deviceId = Ext.Object.fromQueryString(window.location.search).deviceId; if (deviceId) { - device = Ext.getStore('Devices').getById(deviceId); + device = Ext.getStore('VisibleDevices').findRecord('id', deviceId, 0, false, true, true); if (device) { this.fireEvent('selectdevice', device, true); } -- cgit v1.2.3