From 048065b76ac3528a8fa802367aa2750c22487f6c Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 24 Jan 2017 18:41:27 +0500 Subject: - Polish permissions - Makeup imports --- web/app/model/User.js | 3 +++ web/app/view/BaseEditDialog.js | 6 ++++++ web/app/view/BaseEditDialogController.js | 1 + web/app/view/DeviceDialog.js | 5 ----- web/app/view/Devices.js | 3 +-- web/app/view/DevicesController.js | 17 ++++++++++++----- web/app/view/GeofenceDialogController.js | 1 + web/app/view/GroupDialog.js | 5 ----- web/app/view/MainMobile.js | 1 + web/app/view/Map.js | 3 ++- web/app/view/NotificationsController.js | 4 ---- web/app/view/SettingsMenu.js | 5 ++++- web/app/view/SettingsMenuController.js | 9 +++++++-- web/app/view/StateController.js | 2 ++ web/app/view/UserDialog.js | 9 ++++++++- web/app/view/UserDialogController.js | 2 +- web/app/view/UsersController.js | 6 ++++++ web/l10n/en.json | 1 + 18 files changed, 56 insertions(+), 27 deletions(-) (limited to 'web') diff --git a/web/app/model/User.js b/web/app/model/User.js index a88b944..df346ee 100644 --- a/web/app/model/User.js +++ b/web/app/model/User.js @@ -74,6 +74,9 @@ Ext.define('Traccar.model.User', { }, { name: 'userLimit', type: 'int' + }, { + name: 'deviceReadonly', + type: 'boolean' }, { name: 'token', type: 'string' diff --git a/web/app/view/BaseEditDialog.js b/web/app/view/BaseEditDialog.js index 7ccaad3..18cfcf5 100644 --- a/web/app/view/BaseEditDialog.js +++ b/web/app/view/BaseEditDialog.js @@ -18,6 +18,12 @@ Ext.define('Traccar.view.BaseEditDialog', { extend: 'Traccar.view.BaseDialog', + requires: [ + 'Traccar.view.BaseEditDialogController' + ], + + controller: 'baseEditDialog', + buttons: [{ text: Strings.sharedAttributes, handler: 'showAttributesView' diff --git a/web/app/view/BaseEditDialogController.js b/web/app/view/BaseEditDialogController.js index 3e38668..8b74fbb 100644 --- a/web/app/view/BaseEditDialogController.js +++ b/web/app/view/BaseEditDialogController.js @@ -20,6 +20,7 @@ Ext.define('Traccar.view.BaseEditDialogController', { alias: 'controller.baseEditDialog', requires: [ + 'Traccar.view.BaseWindow', 'Traccar.view.Attributes' ], diff --git a/web/app/view/DeviceDialog.js b/web/app/view/DeviceDialog.js index d3f964e..960b3f9 100644 --- a/web/app/view/DeviceDialog.js +++ b/web/app/view/DeviceDialog.js @@ -18,11 +18,6 @@ Ext.define('Traccar.view.DeviceDialog', { extend: 'Traccar.view.BaseEditDialog', - requires: [ - 'Traccar.view.BaseEditDialog' - ], - - controller: 'baseEditDialog', title: Strings.sharedDevice, items: { diff --git a/web/app/view/Devices.js b/web/app/view/Devices.js index 519826e..6ca4098 100644 --- a/web/app/view/Devices.js +++ b/web/app/view/Devices.js @@ -21,8 +21,7 @@ Ext.define('Traccar.view.Devices', { requires: [ 'Traccar.view.DevicesController', - 'Traccar.view.EditToolbar', - 'Traccar.view.SettingsMenu' + 'Traccar.view.EditToolbar' ], controller: 'devices', diff --git a/web/app/view/DevicesController.js b/web/app/view/DevicesController.js index 20b90b3..f7e4bb4 100644 --- a/web/app/view/DevicesController.js +++ b/web/app/view/DevicesController.js @@ -48,10 +48,12 @@ Ext.define('Traccar.view.DevicesController', { }, init: function () { - var readonly = Traccar.app.getPreference('readonly', false) && !Traccar.app.getUser().get('admin'); - this.lookupReference('toolbarAddButton').setVisible(!readonly); - this.lookupReference('toolbarEditButton').setVisible(!readonly); - this.lookupReference('toolbarRemoveButton').setVisible(!readonly); + var readonly, deviceReadonly; + deviceReadonly = Traccar.app.getUser().get('deviceReadonly'); + 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('toolbarGeofencesButton').setVisible(!readonly); }, @@ -87,7 +89,12 @@ Ext.define('Traccar.view.DevicesController', { if (btn === 'yes') { store = Ext.getStore('Devices'); store.remove(device); - store.sync(); + store.sync({ + failure: function (batch) { + store.rejectChanges(); + Traccar.app.showError(batch.exceptions[0].getError().response); + } + }); } } }); diff --git a/web/app/view/GeofenceDialogController.js b/web/app/view/GeofenceDialogController.js index be346c4..936c46d 100644 --- a/web/app/view/GeofenceDialogController.js +++ b/web/app/view/GeofenceDialogController.js @@ -20,6 +20,7 @@ Ext.define('Traccar.view.GeofenceDialogController', { alias: 'controller.geofenceDialog', requires: [ + 'Traccar.view.BaseWindow', 'Traccar.view.GeofenceMap' ], diff --git a/web/app/view/GroupDialog.js b/web/app/view/GroupDialog.js index 2dda74f..01fdc85 100644 --- a/web/app/view/GroupDialog.js +++ b/web/app/view/GroupDialog.js @@ -18,11 +18,6 @@ Ext.define('Traccar.view.GroupDialog', { extend: 'Traccar.view.BaseEditDialog', - requires: [ - 'Traccar.view.BaseEditDialogController' - ], - - controller: 'baseEditDialog', title: Strings.groupDialog, items: { diff --git a/web/app/view/MainMobile.js b/web/app/view/MainMobile.js index 2659e2f..347db31 100644 --- a/web/app/view/MainMobile.js +++ b/web/app/view/MainMobile.js @@ -24,6 +24,7 @@ Ext.define('Traccar.view.MainMobile', { requires: [ 'Traccar.view.Devices', 'Traccar.view.State', + 'Traccar.view.Report', 'Traccar.view.Map' ], diff --git a/web/app/view/Map.js b/web/app/view/Map.js index 88bdf8b..ebc6bbb 100644 --- a/web/app/view/Map.js +++ b/web/app/view/Map.js @@ -20,7 +20,8 @@ Ext.define('Traccar.view.Map', { xtype: 'mapView', requires: [ - 'Traccar.view.MapController' + 'Traccar.view.MapController', + 'Traccar.view.SettingsMenu' ], controller: 'map', diff --git a/web/app/view/NotificationsController.js b/web/app/view/NotificationsController.js index 4c83b14..f50e8d8 100644 --- a/web/app/view/NotificationsController.js +++ b/web/app/view/NotificationsController.js @@ -19,10 +19,6 @@ Ext.define('Traccar.view.NotificationsController', { extend: 'Ext.app.ViewController', alias: 'controller.notificationsController', - requires: [ - 'Traccar.store.Notifications' - ], - init: function () { this.getView().getStore().load({ params: { diff --git a/web/app/view/SettingsMenu.js b/web/app/view/SettingsMenu.js index c71c837..423dc42 100644 --- a/web/app/view/SettingsMenu.js +++ b/web/app/view/SettingsMenu.js @@ -31,9 +31,11 @@ Ext.define('Traccar.view.SettingsMenu', { controller: 'settings', items: [{ + hidden: true, text: Strings.settingsUser, glyph: 'xf007@FontAwesome', - handler: 'onUserClick' + handler: 'onUserClick', + reference: 'settingsUserButton' }, { hidden: true, text: Strings.settingsGroups, @@ -59,6 +61,7 @@ Ext.define('Traccar.view.SettingsMenu', { handler: 'onUsersClick', reference: 'settingsUsersButton' }, { + hidden: true, text: Strings.sharedNotifications, glyph: 'xf003@FontAwesome', handler: 'onNotificationsClick', diff --git a/web/app/view/SettingsMenuController.js b/web/app/view/SettingsMenuController.js index 1f5907d..5dcc722 100644 --- a/web/app/view/SettingsMenuController.js +++ b/web/app/view/SettingsMenuController.js @@ -35,10 +35,11 @@ Ext.define('Traccar.view.SettingsMenuController', { ], init: function () { - var admin, manager, readonly; + var admin, manager, readonly, deviceReadonly; admin = Traccar.app.getUser().get('admin'); manager = Traccar.app.getUser().get('userLimit') > 0; readonly = Traccar.app.getPreference('readonly', false); + deviceReadonly = Traccar.app.getUser().get('deviceReadonly'); if (admin) { this.lookupReference('settingsServerButton').setHidden(false); this.lookupReference('settingsStatisticsButton').setHidden(false); @@ -48,11 +49,15 @@ Ext.define('Traccar.view.SettingsMenuController', { this.lookupReference('settingsUsersButton').setHidden(false); } if (admin || !readonly) { + this.lookupReference('settingsUserButton').setHidden(false); this.lookupReference('settingsGroupsButton').setHidden(false); this.lookupReference('settingsGeofencesButton').setHidden(false); - this.lookupReference('settingsAttributeAliasesButton').setHidden(false); + this.lookupReference('settingsNotificationsButton').setHidden(false); this.lookupReference('settingsCalendarsButton').setHidden(false); } + if (admin || (!deviceReadonly && !readonly)) { + this.lookupReference('settingsAttributeAliasesButton').setHidden(false); + } }, onUserClick: function () { diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js index f84caac..0833186 100644 --- a/web/app/view/StateController.js +++ b/web/app/view/StateController.js @@ -55,6 +55,8 @@ Ext.define('Traccar.view.StateController', { }, init: function () { + var visible = !Traccar.app.getUser().get('deviceReadonly') && !Traccar.app.getPreference('readonly', false); + this.lookupReference('aliasEditButton').setVisible(visible); this.aliasesStore = Ext.getStore('AttributeAliases'); }, diff --git a/web/app/view/UserDialog.js b/web/app/view/UserDialog.js index 8ab3f6b..34c3b4a 100644 --- a/web/app/view/UserDialog.js +++ b/web/app/view/UserDialog.js @@ -144,12 +144,19 @@ Ext.define('Traccar.view.UserDialog', { fieldLabel: Strings.userUserLimit, disabled: true, reference: 'userLimitField' + }, { + xtype: 'checkboxfield', + inputValue: true, + uncheckedValue: false, + name: 'deviceReadonly', + fieldLabel: Strings.userDeviceReadonly, + disabled: true, + reference: 'deviceReadonlyField' }, { xtype: 'textfield', name: 'token', reference: 'tokenField', fieldLabel: Strings.userToken, - disabled: true, triggers: { generate: { cls: 'iconCls: x-fa fa-refresh', diff --git a/web/app/view/UserDialogController.js b/web/app/view/UserDialogController.js index 2946a2a..bfb934d 100644 --- a/web/app/view/UserDialogController.js +++ b/web/app/view/UserDialogController.js @@ -30,7 +30,7 @@ Ext.define('Traccar.view.UserDialogController', { this.lookupReference('readonlyField').setHidden(false); this.lookupReference('disabledField').setHidden(false); this.lookupReference('expirationTimeField').setDisabled(false); - this.lookupReference('tokenField').setDisabled(false); + this.lookupReference('deviceReadonlyField').setDisabled(false); } }, diff --git a/web/app/view/UsersController.js b/web/app/view/UsersController.js index 8aaa839..68e49f8 100644 --- a/web/app/view/UsersController.js +++ b/web/app/view/UsersController.js @@ -40,6 +40,12 @@ Ext.define('Traccar.view.UsersController', { onAddClick: function () { var user, dialog; user = Ext.create('Traccar.model.User'); + if (Traccar.app.getUser().get('admin')) { + user.set('deviceLimit', -1); + } + if (Traccar.app.getUser().get('expirationTime')) { + user.set('expirationTime', Traccar.app.getUser().get('expirationTime')); + } dialog = Ext.create('Traccar.view.UserDialog'); dialog.down('form').loadRecord(user); dialog.show(); diff --git a/web/l10n/en.json b/web/l10n/en.json index dc7280e..62f8a22 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -58,6 +58,7 @@ "userExpirationTime": "Expiration", "userDeviceLimit": "Device Limit", "userUserLimit": "User Limit", + "userDeviceReadonly": "Device Readonly", "userToken": "Token", "loginTitle": "Login", "loginLanguage": "Language", -- cgit v1.2.3 From aec5f5b0f0b00492742919358a9aaa03e72e3a5b Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 27 Jan 2017 08:54:29 +0500 Subject: Determine manager correctly --- web/app/view/SettingsMenuController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web') diff --git a/web/app/view/SettingsMenuController.js b/web/app/view/SettingsMenuController.js index 5dcc722..16813fa 100644 --- a/web/app/view/SettingsMenuController.js +++ b/web/app/view/SettingsMenuController.js @@ -37,7 +37,7 @@ Ext.define('Traccar.view.SettingsMenuController', { init: function () { var admin, manager, readonly, deviceReadonly; admin = Traccar.app.getUser().get('admin'); - manager = Traccar.app.getUser().get('userLimit') > 0; + manager = Traccar.app.getUser().get('userLimit') !== 0; readonly = Traccar.app.getPreference('readonly', false); deviceReadonly = Traccar.app.getUser().get('deviceReadonly'); if (admin) { -- cgit v1.2.3