diff options
Diffstat (limited to 'web/app/view/DevicesController.js')
-rw-r--r-- | web/app/view/DevicesController.js | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/web/app/view/DevicesController.js b/web/app/view/DevicesController.js index cf31dd7bb..ca3e24661 100644 --- a/web/app/view/DevicesController.js +++ b/web/app/view/DevicesController.js @@ -86,15 +86,16 @@ Ext.define('Traccar.view.DevicesController', { }, onGeofencesClick: function () { - var admin = Traccar.app.getUser().get('admin'); - var device = this.getView().getSelectionModel().getSelection()[0]; + var admin, device; + admin = Traccar.app.getUser().get('admin'); + device = this.getView().getSelectionModel().getSelection()[0]; Ext.create('Traccar.view.BaseWindow', { title: Strings.sharedGeofences, items: { xtype: 'deviceGeofencesView', baseObjectName: 'deviceId', linkObjectName: 'geofenceId', - storeName: (admin) ? 'AllGeofences' : 'Geofences', + storeName: 'Geofences', urlApi: '/api/devices/geofences', baseObject: device.getData().id } @@ -115,19 +116,24 @@ Ext.define('Traccar.view.DevicesController', { }, onFollowClick: function (button, pressed) { + var device; if (pressed) { - var device = this.getView().getSelectionModel().getSelection()[0]; + device = this.getView().getSelectionModel().getSelection()[0]; this.fireEvent('selectDevice', device, true); } }, - onSelectionChange: function (selected) { + updateButtons: function (selected) { var empty = selected.getCount() === 0; this.lookupReference('toolbarEditButton').setDisabled(empty); this.lookupReference('toolbarRemoveButton').setDisabled(empty); this.lookupReference('toolbarGeofencesButton').setDisabled(empty); this.lookupReference('deviceCommandButton').setDisabled(empty || (selected.getLastSelected().get('status') !== 'online')); - if (!empty) { + }, + + onSelectionChange: function (selected) { + this.updateButtons(selected); + if (selected.getCount() > 0) { this.fireEvent('selectDevice', selected.getLastSelected(), true); } }, @@ -143,6 +149,6 @@ Ext.define('Traccar.view.DevicesController', { }, onUpdateDevice: function (store, data) { - this.onSelectionChange(this.getView().getSelectionModel()); + this.updateButtons(this.getView().getSelectionModel()); } }); |