diff options
author | Abyss777 <abyss@fox5.ru> | 2017-02-27 15:55:01 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-02-27 15:55:01 +0500 |
commit | 9d3fb390252a9d4cef09bf71c7ebaa7b1a024917 (patch) | |
tree | 877971d1cf7a7edf98512f7c7c6f4135f5e0a41c /web/app/view/DevicesController.js | |
parent | 66171b939e4d20ecae0014bb61862e1880e9c6c5 (diff) | |
download | trackermap-web-9d3fb390252a9d4cef09bf71c7ebaa7b1a024917.tar.gz trackermap-web-9d3fb390252a9d4cef09bf71c7ebaa7b1a024917.tar.bz2 trackermap-web-9d3fb390252a9d4cef09bf71c7ebaa7b1a024917.zip |
- Add server "device readonly" flag
- Do not hide buttons in Devices toolbar
Diffstat (limited to 'web/app/view/DevicesController.js')
-rw-r--r-- | web/app/view/DevicesController.js | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/web/app/view/DevicesController.js b/web/app/view/DevicesController.js index 62853919..ad0dd363 100644 --- a/web/app/view/DevicesController.js +++ b/web/app/view/DevicesController.js @@ -53,13 +53,9 @@ Ext.define('Traccar.view.DevicesController', { init: function () { var readonly, deviceReadonly; - deviceReadonly = Traccar.app.getUser().get('deviceReadonly'); + deviceReadonly = Traccar.app.getPreference('deviceReadonly', false) && !Traccar.app.getUser().get('admin'); readonly = Traccar.app.getPreference('readonly', false) && !Traccar.app.getUser().get('admin'); - this.lookupReference('toolbarAddButton').setVisible(!readonly && !deviceReadonly); - this.lookupReference('toolbarEditButton').setVisible(!readonly && !deviceReadonly); - this.lookupReference('toolbarRemoveButton').setVisible(!readonly && !deviceReadonly); - this.lookupReference('deviceCommandButton').setVisible(!readonly && !deviceReadonly); - this.lookupReference('toolbarGeofencesButton').setVisible(!readonly); + this.lookupReference('toolbarAddButton').setDisabled(readonly || deviceReadonly); }, onGeofencesClick: function () { @@ -91,11 +87,15 @@ Ext.define('Traccar.view.DevicesController', { }, 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')); + var readonly, deviceReadonly, empty, online; + deviceReadonly = Traccar.app.getPreference('deviceReadonly', false) && !Traccar.app.getUser().get('admin'); + readonly = Traccar.app.getPreference('readonly', false) && !Traccar.app.getUser().get('admin'); + empty = selected.getCount() === 0; + online = selected.getLastSelected().get('status') === 'online'; + this.lookupReference('toolbarEditButton').setDisabled(empty || readonly || deviceReadonly); + this.lookupReference('toolbarRemoveButton').setDisabled(empty || readonly || deviceReadonly); + this.lookupReference('toolbarGeofencesButton').setDisabled(empty || readonly); + this.lookupReference('deviceCommandButton').setDisabled(empty || readonly || !online); }, onSelectionChange: function (selected) { |