Skip to content

Commit

Permalink
For #175 - added new columns to 'Users' screen
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalidze committed Jun 24, 2015
1 parent 201edbc commit f667715
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/main/java/org/traccar/web/client/i18n/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,4 +386,6 @@ String defaultNotificationTemplate(@Select DeviceEventType type,
String expirationDate();

String maxNumOfDevices();

String blocked();
}
50 changes: 44 additions & 6 deletions src/main/java/org/traccar/web/client/view/UsersDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,23 @@
*/
package org.traccar.web.client.view;

import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import com.google.gwt.cell.client.TextInputCell;
import com.sencha.gxt.cell.core.client.NumberCell;
import com.sencha.gxt.cell.core.client.form.CheckBoxCell;
import com.sencha.gxt.data.shared.Store;
import com.sencha.gxt.cell.core.client.form.DateCell;
import com.sencha.gxt.widget.core.client.form.NumberField;
import com.sencha.gxt.widget.core.client.form.NumberPropertyEditor;
import com.sencha.gxt.widget.core.client.form.TextField;
import com.sencha.gxt.widget.core.client.grid.editing.GridEditing;
import com.sencha.gxt.widget.core.client.grid.editing.GridInlineEditing;
import org.traccar.web.client.ApplicationContext;
import org.traccar.web.client.i18n.Messages;
import org.traccar.web.client.model.UserProperties;
import org.traccar.web.shared.model.Device;
import org.traccar.web.shared.model.Maintenance;
import org.traccar.web.shared.model.User;

import com.google.gwt.core.client.GWT;
Expand Down Expand Up @@ -92,25 +99,56 @@ public UsersDialog(ListStore<User> userStore, UserHandler userHandler) {
columnConfigList.add(new ColumnConfig<User, String>(userProperties.login(), 25, i18n.name()));

if (ApplicationContext.getInstance().getUser().getAdmin()) {
ColumnConfig<User, Boolean> colAdmin = new ColumnConfig<User, Boolean>(userProperties.admin(), 25, i18n.administrator());
ColumnConfig<User, Boolean> colAdmin = new ColumnConfig<User, Boolean>(userProperties.admin(), 100, i18n.administrator());
colAdmin.setCell(new CheckBoxCell());
colAdmin.setFixed(true);
colAdmin.setResizable(false);
columnConfigList.add(colAdmin);
}

ColumnConfig<User, Boolean> colManager = new ColumnConfig<User, Boolean>(userProperties.manager(), 25, i18n.manager());
ColumnConfig<User, Boolean> colManager = new ColumnConfig<User, Boolean>(userProperties.manager(), 70, i18n.manager());
colManager.setCell(new CheckBoxCell());
colManager.setFixed(true);
colManager.setResizable(false);
columnConfigList.add(colManager);

ColumnConfig<User, Boolean> colReadOnly = new ColumnConfig<User, Boolean>(userProperties.readOnly(), 25, i18n.readOnly());
ColumnConfig<User, Boolean> colReadOnly = new ColumnConfig<User, Boolean>(userProperties.readOnly(), 90, i18n.readOnly());
colReadOnly.setCell(new CheckBoxCell());
colReadOnly.setFixed(true);
colReadOnly.setResizable(false);
columnConfigList.add(colReadOnly);

ColumnConfig<User, Boolean> colBlocked = new ColumnConfig<User, Boolean>(userProperties.blocked(), 50, i18n.blocked());
colBlocked.setCell(new CheckBoxCell());
colBlocked.setFixed(true);
colBlocked.setResizable(false);
columnConfigList.add(colBlocked);

ColumnConfig<User, Date> colExpirationDate = new ColumnConfig<User, Date>(userProperties.expirationDate(), 156, i18n.expirationDate());
colExpirationDate.setCell(new DateCell());
colExpirationDate.setFixed(true);
colExpirationDate.setResizable(false);
columnConfigList.add(colExpirationDate);

ColumnConfig<User, Integer> colMaxNumOfDevices = new ColumnConfig<User, Integer>(userProperties.maxNumOfDevices(), 156, i18n.maxNumOfDevices());
colMaxNumOfDevices.setCell(new NumberCell<Integer>());
colMaxNumOfDevices.setFixed(true);
colMaxNumOfDevices.setResizable(false);
columnConfigList.add(colMaxNumOfDevices);

columnModel = new ColumnModel<User>(columnConfigList);

uiBinder.createAndBindUi(this);

grid.getSelectionModel().addSelectionChangedHandler(this);
grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);

GridEditing<User> editing = new GridInlineEditing<User>(grid);
NumberField<Integer> maxNumOfDevicesEditor = new NumberField<Integer>(new NumberPropertyEditor.IntegerPropertyEditor());
maxNumOfDevicesEditor.setAllowDecimals(false);
maxNumOfDevicesEditor.setAllowBlank(true);
maxNumOfDevicesEditor.setAllowNegative(false);
editing.addEditor(colMaxNumOfDevices, maxNumOfDevicesEditor);
}

public void show() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<ui:with field='i18n' type='org.traccar.web.client.i18n.Messages' />

<gxt:Window ui:field="window" pixelSize="640, 480" modal="true" headingText="{i18n.users}">
<gxt:Window ui:field="window" pixelSize="800, 480" modal="true" headingText="{i18n.users}">
<container:VerticalLayoutContainer>
<container:child layoutData="{layoutData}">
<gxt:ContentPanel ui:field="contentPanel" headerVisible="false">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ public User updateUser(User user) {
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
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ lastName = Last name
companyName = Company name
expirationDate = Expiration date
maxNumOfDevices = Maximum number of devices
blocked = Blocked
# users dialog
confirmUserRemoval = Are you sure you want remove user?
readOnly = Read only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ lastName = Фамилия
companyName = Компания
expirationDate = Действительна до
maxNumOfDevices = Макс. количество устройств
blocked = Заблок.
# users dialog
confirmUserRemoval = Вы действительно хотите удалить пользователя?
readOnly = Только чтение
Expand Down

0 comments on commit f667715

Please sign in to comment.