diff --git a/src/main/java/org/traccar/web/client/view/UserDialog.java b/src/main/java/org/traccar/web/client/view/UserDialog.java index 5d21ce05..585edb7e 100644 --- a/src/main/java/org/traccar/web/client/view/UserDialog.java +++ b/src/main/java/org/traccar/web/client/view/UserDialog.java @@ -119,7 +119,6 @@ public interface UserHandler { public UserDialog(User user, UserHandler userHandler) { this.userHandler = userHandler; - // notification types grid IdentityValueProvider identity = new IdentityValueProvider(); final CheckBoxSelectionModel selectionModel = new CheckBoxSelectionModel(identity); @@ -152,15 +151,20 @@ public String getValue(DeviceEventType object) { grid.getSelectionModel().select(deviceEventType, true); } - if (ApplicationContext.getInstance().getUser().getAdmin()) { + if (ApplicationContext.getInstance().getUser().getAdmin() || ApplicationContext.getInstance().getUser().getManager()) { admin.setEnabled(true); - } - - if (ApplicationContext.getInstance().getUser().getAdmin() || - ApplicationContext.getInstance().getUser().getManager()) { manager.setEnabled(true); + readOnly.setEnabled(true); + expirationDate.setEnabled(true); + maxNumOfDevices.setEnabled(true); + } + else { + manager.setEnabled(false); + admin.setEnabled(false); + readOnly.setEnabled(false); + expirationDate.setEnabled(false); + maxNumOfDevices.setEnabled(false); } - email.addValidator(new RegExValidator(".+@.+\\.[a-z]+", i18n.invalidEmail())); driver.initialize(this); diff --git a/src/main/java/org/traccar/web/client/view/UserDialog.ui.xml b/src/main/java/org/traccar/web/client/view/UserDialog.ui.xml index d1c0f3a6..3ad96e8f 100644 --- a/src/main/java/org/traccar/web/client/view/UserDialog.ui.xml +++ b/src/main/java/org/traccar/web/client/view/UserDialog.ui.xml @@ -80,14 +80,14 @@ - + - + @@ -97,7 +97,7 @@ + allowDecimals="false" enabled="false"/> diff --git a/src/main/java/org/traccar/web/server/model/DataServiceImpl.java b/src/main/java/org/traccar/web/server/model/DataServiceImpl.java index bf16464b..e32b3b94 100644 --- a/src/main/java/org/traccar/web/server/model/DataServiceImpl.java +++ b/src/main/java/org/traccar/web/server/model/DataServiceImpl.java @@ -259,17 +259,21 @@ public User updateUser(User user) { currentUser.setPasswordHashMethod(getApplicationSettings().getDefaultHashImplementation()); currentUser.setPassword(currentUser.getPasswordHashMethod().doHash(user.getPassword())); } + if(currentUser.getAdmin() || currentUser.getManager()) + { + currentUser.setMaxNumOfDevices(user.getMaxNumOfDevices()); + currentUser.setExpirationDate(user.getExpirationDate()); + currentUser.setAdmin(user.getAdmin()); + currentUser.setManager(user.getManager()); + } currentUser.setUserSettings(user.getUserSettings()); - currentUser.setAdmin(user.getAdmin()); - currentUser.setManager(user.getManager()); currentUser.setEmail(user.getEmail()); currentUser.setNotificationEvents(user.getTransferNotificationEvents()); currentUser.setCompanyName(user.getCompanyName()); currentUser.setFirstName(user.getFirstName()); currentUser.setLastName(user.getLastName()); currentUser.setPhoneNumber(user.getPhoneNumber()); - currentUser.setMaxNumOfDevices(user.getMaxNumOfDevices()); - currentUser.setExpirationDate(user.getExpirationDate()); + entityManager.merge(currentUser); user = currentUser; } else { @@ -780,14 +784,16 @@ public void saveRoles(List users) { User currentUser = getSessionUser(); for (User _user : users) { User user = entityManager.find(User.class, _user.getId()); - if (currentUser.getAdmin()) { + if (currentUser.getAdmin() || currentUser.getManager()) { user.setAdmin(_user.getAdmin()); + user.setExpirationDate(_user.getExpirationDate()); + user.setBlocked(_user.isBlocked()); + user.setMaxNumOfDevices(_user.getMaxNumOfDevices()); + user.setReadOnly(_user.getReadOnly()); } - user.setManager(_user.getManager()); - user.setReadOnly(_user.getReadOnly()); - user.setExpirationDate(_user.getExpirationDate()); - user.setBlocked(_user.isBlocked()); - user.setMaxNumOfDevices(_user.getMaxNumOfDevices()); + + + } }