Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible solution for issue #215 #252

Merged
merged 3 commits into from
Sep 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/main/java/org/traccar/web/client/view/UserDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ public interface UserHandler {

public UserDialog(User user, UserHandler userHandler) {
this.userHandler = userHandler;

// notification types grid
IdentityValueProvider<DeviceEventType> identity = new IdentityValueProvider<DeviceEventType>();
final CheckBoxSelectionModel<DeviceEventType> selectionModel = new CheckBoxSelectionModel<DeviceEventType>(identity);
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/traccar/web/client/view/UserDialog.ui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@
<container:child layoutData="{verticalLayoutData}">
<form:FieldLabel text="{i18n.readOnly}" labelWidth="160">
<form:widget>
<form:CheckBox ui:field="readOnly" />
<form:CheckBox ui:field="readOnly" enabled="false"/>
</form:widget>
</form:FieldLabel>
</container:child>
<container:child layoutData="{verticalLayoutData}">
<form:FieldLabel text="{i18n.expirationDate}" labelWidth="160">
<form:widget>
<form:DateField ui:field="expirationDate" />
<form:DateField ui:field="expirationDate" enabled="false"/>
</form:widget>
</form:FieldLabel>
</container:child>
Expand All @@ -97,7 +97,7 @@
<form:NumberField editor="{integerPropertyEditor}"
ui:field="maxNumOfDevices"
allowNegative="false"
allowDecimals="false" />
allowDecimals="false" enabled="false"/>
</form:widget>
</form:FieldLabel>
</container:child>
Expand Down
26 changes: 16 additions & 10 deletions src/main/java/org/traccar/web/server/model/DataServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -780,14 +784,16 @@ public void saveRoles(List<User> 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());



}
}

Expand Down