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-value>true</param-value>
</context-param>
<context-param>
<param-name>ccm.distribution</param-name>
<param-value>libreccm</param-value>
</context-param>
<!-- No JSESSIONID!!! -->
<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.l10n.GlobalizationHelper;
import org.libreccm.security.PermissionChecker;
import org.libreccm.security.UserManager;
import org.libreccm.security.UserRepository;
import java.util.ResourceBundle;
@ -58,11 +59,6 @@ public class AdminView extends CustomComponent implements View {
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
private ServletContext servletContext;
@ -78,6 +74,12 @@ public class AdminView extends CustomComponent implements View {
@Inject
private GlobalizationHelper globalizationHelper;
@Inject
private UserRepository userRepository;
@Inject
private UserManager userManager;
@Inject
private UsersTableDataProvider usersTableDataProvider;
@ -152,9 +154,27 @@ public class AdminView extends CustomComponent implements View {
header.addComponent(headerInfoLine, 3, 0, 4, 0);
header.setComponentAlignment(headerInfoLine, Alignment.TOP_RIGHT);
final Image logo = new Image(
null,
new ClassResource("/themes/libreccm-default/images/libreccm.png"));
final String logoPath;
switch (servletContext.getInitParameter("ccm.distribution")
.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.addStyleName("libreccm-logo");
header.addComponent(logo, 0, 0);
@ -197,4 +217,12 @@ public class AdminView extends CustomComponent implements View {
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.Query;
import com.vaadin.ui.Button;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.ItemCaptionGenerator;
@ -35,6 +36,8 @@ import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import org.libreccm.core.UnexpectedErrorException;
import org.libreccm.security.User;
import org.libreccm.security.UserManager;
import org.libreccm.security.UserRepository;
import java.util.Arrays;
import java.util.ResourceBundle;
@ -56,6 +59,8 @@ public class UserEditor extends Window {
}
private final User user;
private final UserRepository userRepo;
private final UserManager userManager;
private TextField userName;
private TextField familyName;
@ -64,16 +69,26 @@ public class UserEditor extends Window {
private RadioButtonGroup<PasswordOptions> passwordOptions;
private PasswordField password;
private PasswordField passwordConfirmation;
private CheckBox passwordResetRequired;
private CheckBox banned;
public UserEditor(final UserRepository userRepo,
final UserManager userManager) {
public UserEditor() {
user = null;
this.userRepo = userRepo;
this.userManager = userManager;
addWidgets();
}
public UserEditor(final User user) {
public UserEditor(final User user,
final UserRepository userRepo,
final UserManager userManager) {
this.user = user;
this.userRepo = userRepo;
this.userManager = userManager;
addWidgets();
}
@ -168,6 +183,17 @@ public class UserEditor extends Window {
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();
if (user == null) {
submit.setCaption(bundle.getString(
@ -186,7 +212,9 @@ public class UserEditor extends Window {
emailAddress,
passwordOptions,
password,
passwordConfirmation);
passwordConfirmation,
passwordResetRequired,
banned);
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.security.User;
import java.util.Locale;
import java.util.ResourceBundle;
/**
@ -117,8 +116,10 @@ public class UsersGroupsRoles extends CustomComponent {
usersTable
.addColumn(user -> bundle.getString("ui.admin.users.table.edit"),
new ButtonRenderer<>(event -> {
final UserEditor editor = new UserEditor(event
.getItem());
final UserEditor editor = new UserEditor(
event.getItem(),
view.getUserRepository(),
view.getUserManager());
editor.center();
UI.getCurrent().addWindow(editor);
}))
@ -126,8 +127,10 @@ public class UsersGroupsRoles extends CustomComponent {
usersTable
.addColumn(user -> bundle.getString("ui.admin.users.table.delete"),
new ButtonRenderer<>(event -> {
final UserEditor editor = new UserEditor(event
.getItem());
final UserEditor editor = new UserEditor(
event.getItem(),
view.getUserRepository(),
view.getUserManager());
editor.center();
UI.getCurrent().addWindow(editor);
}))

View File

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