CCM NG/ccm-core: More work on the Vaadin prototype

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4714 8810af33-2d31-482b-a856-94f89814c4df
jensp 2017-05-08 18:04:57 +00:00
parent bd1ff6d18a
commit a82c10c751
6 changed files with 116 additions and 27 deletions

View File

@ -11,6 +11,10 @@
<param-name>ccm.develmode</param-name> <param-name>ccm.develmode</param-name>
<param-value>true</param-value> <param-value>true</param-value>
</context-param> </context-param>
<context-param>
<param-name>ccm.distribution</param-name>
<param-value>libreccm</param-value>
</context-param>
<!-- No JSESSIONID!!! --> <!-- No JSESSIONID!!! -->
<session-config> <session-config>

View File

@ -38,6 +38,7 @@ import org.libreccm.admin.ui.usersgroupsroles.UsersGroupsRoles;
import org.libreccm.admin.ui.usersgroupsroles.UsersTableDataProvider; import org.libreccm.admin.ui.usersgroupsroles.UsersTableDataProvider;
import org.libreccm.l10n.GlobalizationHelper; import org.libreccm.l10n.GlobalizationHelper;
import org.libreccm.security.PermissionChecker; import org.libreccm.security.PermissionChecker;
import org.libreccm.security.UserManager;
import org.libreccm.security.UserRepository; import org.libreccm.security.UserRepository;
import java.util.ResourceBundle; import java.util.ResourceBundle;
@ -58,11 +59,6 @@ public class AdminView extends CustomComponent implements View {
public static final String VIEWNAME = "admin"; public static final String VIEWNAME = "admin";
// private static final String COL_USER_NAME = "username";
// private static final String COL_GIVEN_NAME = "given_name";
// private static final String COL_FAMILY_NAME = "family_name";
// private static final String COL_EMAIL = "email";
// private static final String COL_BANNED = "banned";
@Inject @Inject
private ServletContext servletContext; private ServletContext servletContext;
@ -78,6 +74,12 @@ public class AdminView extends CustomComponent implements View {
@Inject @Inject
private GlobalizationHelper globalizationHelper; private GlobalizationHelper globalizationHelper;
@Inject
private UserRepository userRepository;
@Inject
private UserManager userManager;
@Inject @Inject
private UsersTableDataProvider usersTableDataProvider; private UsersTableDataProvider usersTableDataProvider;
@ -152,9 +154,27 @@ public class AdminView extends CustomComponent implements View {
header.addComponent(headerInfoLine, 3, 0, 4, 0); header.addComponent(headerInfoLine, 3, 0, 4, 0);
header.setComponentAlignment(headerInfoLine, Alignment.TOP_RIGHT); header.setComponentAlignment(headerInfoLine, Alignment.TOP_RIGHT);
final Image logo = new Image( final String logoPath;
null, switch (servletContext.getInitParameter("ccm.distribution")
new ClassResource("/themes/libreccm-default/images/libreccm.png")); .toLowerCase()) {
case "libreccm":
logoPath = "/themes/libreccm-default/images/libreccm.png";
break;
case "librecms":
logoPath = "/themes/libreccm-default/images/librecms.png";
break;
case "aplaws":
logoPath = "/themes/libreccm-default/images/aplaws.png";
break;
case "scientificcms":
logoPath = "/themes/libreccm-default/images/scientificcms.png";
break;
default:
logoPath = "/themes/libreccm-default/images/libreccm.png";
break;
}
final Image logo = new Image(null, new ClassResource(logoPath));
logo.setId("libreccm-logo"); logo.setId("libreccm-logo");
logo.addStyleName("libreccm-logo"); logo.addStyleName("libreccm-logo");
header.addComponent(logo, 0, 0); header.addComponent(logo, 0, 0);
@ -197,4 +217,12 @@ public class AdminView extends CustomComponent implements View {
return jpqlConsoleController; return jpqlConsoleController;
} }
public UserRepository getUserRepository() {
return userRepo;
}
public UserManager getUserManager() {
return userManager;
}
} }

View File

@ -23,6 +23,7 @@ import com.arsdigita.ui.admin.AdminUiConstants;
import com.vaadin.data.provider.AbstractDataProvider; import com.vaadin.data.provider.AbstractDataProvider;
import com.vaadin.data.provider.Query; import com.vaadin.data.provider.Query;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.FormLayout; import com.vaadin.ui.FormLayout;
import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.ItemCaptionGenerator; import com.vaadin.ui.ItemCaptionGenerator;
@ -35,6 +36,8 @@ import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window; import com.vaadin.ui.Window;
import org.libreccm.core.UnexpectedErrorException; import org.libreccm.core.UnexpectedErrorException;
import org.libreccm.security.User; import org.libreccm.security.User;
import org.libreccm.security.UserManager;
import org.libreccm.security.UserRepository;
import java.util.Arrays; import java.util.Arrays;
import java.util.ResourceBundle; import java.util.ResourceBundle;
@ -56,6 +59,8 @@ public class UserEditor extends Window {
} }
private final User user; private final User user;
private final UserRepository userRepo;
private final UserManager userManager;
private TextField userName; private TextField userName;
private TextField familyName; private TextField familyName;
@ -64,16 +69,26 @@ public class UserEditor extends Window {
private RadioButtonGroup<PasswordOptions> passwordOptions; private RadioButtonGroup<PasswordOptions> passwordOptions;
private PasswordField password; private PasswordField password;
private PasswordField passwordConfirmation; private PasswordField passwordConfirmation;
private CheckBox passwordResetRequired;
private CheckBox banned;
public UserEditor(final UserRepository userRepo,
final UserManager userManager) {
public UserEditor() {
user = null; user = null;
this.userRepo = userRepo;
this.userManager = userManager;
addWidgets(); addWidgets();
} }
public UserEditor(final User user) { public UserEditor(final User user,
final UserRepository userRepo,
final UserManager userManager) {
this.user = user; this.user = user;
this.userRepo = userRepo;
this.userManager = userManager;
addWidgets(); addWidgets();
} }
@ -168,6 +183,17 @@ public class UserEditor extends Window {
passwordOptions.setValue(PasswordOptions.GENERATE_AND_SEND); passwordOptions.setValue(PasswordOptions.GENERATE_AND_SEND);
passwordResetRequired = new CheckBox(bundle
.getString("ui.admin.user_edit.password_reset_required.label"));
banned = new CheckBox(bundle
.getString("ui.admin.user_edit.banned.label"));
if (user == null) {
banned.setVisible(false);
banned.setEnabled(false);
}
final Button submit = new Button(); final Button submit = new Button();
if (user == null) { if (user == null) {
submit.setCaption(bundle.getString( submit.setCaption(bundle.getString(
@ -186,7 +212,9 @@ public class UserEditor extends Window {
emailAddress, emailAddress,
passwordOptions, passwordOptions,
password, password,
passwordConfirmation); passwordConfirmation,
passwordResetRequired,
banned);
final VerticalLayout layout = new VerticalLayout(formLayout, buttons); final VerticalLayout layout = new VerticalLayout(formLayout, buttons);

View File

@ -34,7 +34,6 @@ import com.vaadin.ui.themes.ValoTheme;
import org.libreccm.admin.ui.AdminView; import org.libreccm.admin.ui.AdminView;
import org.libreccm.security.User; import org.libreccm.security.User;
import java.util.Locale;
import java.util.ResourceBundle; import java.util.ResourceBundle;
/** /**
@ -51,7 +50,7 @@ public class UsersGroupsRoles extends CustomComponent {
private static final String COL_EMAIL = "email"; private static final String COL_EMAIL = "email";
private static final String COL_BANNED = "banned"; private static final String COL_BANNED = "banned";
private static final String COL_PASSWORD_RESET_REQUIRED private static final String COL_PASSWORD_RESET_REQUIRED
= "password_reset_required"; = "password_reset_required";
private static final String COL_EDIT = "edit"; private static final String COL_EDIT = "edit";
private static final String COL_DELETE = "delete"; private static final String COL_DELETE = "delete";
@ -117,8 +116,10 @@ public class UsersGroupsRoles extends CustomComponent {
usersTable usersTable
.addColumn(user -> bundle.getString("ui.admin.users.table.edit"), .addColumn(user -> bundle.getString("ui.admin.users.table.edit"),
new ButtonRenderer<>(event -> { new ButtonRenderer<>(event -> {
final UserEditor editor = new UserEditor(event final UserEditor editor = new UserEditor(
.getItem()); event.getItem(),
view.getUserRepository(),
view.getUserManager());
editor.center(); editor.center();
UI.getCurrent().addWindow(editor); UI.getCurrent().addWindow(editor);
})) }))
@ -126,8 +127,10 @@ public class UsersGroupsRoles extends CustomComponent {
usersTable usersTable
.addColumn(user -> bundle.getString("ui.admin.users.table.delete"), .addColumn(user -> bundle.getString("ui.admin.users.table.delete"),
new ButtonRenderer<>(event -> { new ButtonRenderer<>(event -> {
final UserEditor editor = new UserEditor(event final UserEditor editor = new UserEditor(
.getItem()); event.getItem(),
view.getUserRepository(),
view.getUserManager());
editor.center(); editor.center();
UI.getCurrent().addWindow(editor); UI.getCurrent().addWindow(editor);
})) }))

View File

@ -7,11 +7,25 @@
@include valo; @include valo;
.libreccm-header { .libreccm-header {
border-bottom: 5px solid #0f0;
.libreccm-logo { .libreccm-logo {
max-height: 100px; max-height: 100px;
} }
} }
.libreccm {
background-color: #71ac52;
}
.librecms {
background-color: #54ac9c;
}
.aplaws {
background-color: #5462ad;
}
.scientificcms {
background-color: #ad5353;
}
} }

View File

@ -12502,10 +12502,22 @@ h1.no-margin, .v-label-h1.no-margin, h2.no-margin, .v-label-h2.no-margin, h3.no-
overflow: hidden; overflow: hidden;
} }
.libreccm-header {
border-bottom: 5px solid #0f0;
}
.libreccm-header .libreccm-logo { .libreccm-header .libreccm-logo {
max-height: 100px; max-height: 100px;
} }
.libreccm {
background-color: #71ac52;
}
.librecms {
background-color: #54ac9c;
}
.aplaws {
background-color: #5462ad;
}
.scientificcms {
background-color: #ad5353;
}