Systeminformation for admin users

master
Markus Kreth 6 years ago
parent f91dc8ea78
commit ef52a90bda
  1. 2
      .settings/com.vaadin.integration.eclipse.prefs
  2. 14
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedinMenuitemState.java
  3. 17
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/ClubhelperNavigation.java
  4. 1
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/ClubhelperViews.java
  5. 67
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/SysteminfoView.java

@ -1,4 +1,4 @@
com.vaadin.integration.eclipse.mavenLatestVersionsUpgrade=["8.6.4","8.9.2"] com.vaadin.integration.eclipse.mavenLatestVersionsUpgrade=["8.6.4","8.9.4"]
com.vaadin.integration.eclipse.previousCompileAction=both com.vaadin.integration.eclipse.previousCompileAction=both
com.vaadin.integration.eclipse.useLatestNightly=false com.vaadin.integration.eclipse.useLatestNightly=false
com.vaadin.integration.eclipse.widgetsetDirty=true com.vaadin.integration.eclipse.widgetsetDirty=true

@ -21,6 +21,7 @@ import com.vaadin.ui.Window;
import de.kreth.googleconnectors.calendar.CalendarAdapter; import de.kreth.googleconnectors.calendar.CalendarAdapter;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness; import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityGroups;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier; import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.commands.ClubCommand; import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.commands.ClubCommand;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.commands.CreateMeldungCommand; import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.commands.CreateMeldungCommand;
@ -63,6 +64,8 @@ class LoggedinMenuitemState extends LoggedOffState {
private MenuItem sendEmailsMenuItem; private MenuItem sendEmailsMenuItem;
private MenuItem systeminfoItem;
public LoggedinMenuitemState(ApplicationContext context, UI ui, Supplier<ZonedDateTime> startProvider, public LoggedinMenuitemState(ApplicationContext context, UI ui, Supplier<ZonedDateTime> startProvider,
Supplier<ZonedDateTime> endProvider, BiConsumer<String, JasperPrint> printConsumer) { Supplier<ZonedDateTime> endProvider, BiConsumer<String, JasperPrint> printConsumer) {
super(context, startProvider, endProvider, printConsumer); super(context, startProvider, endProvider, printConsumer);
@ -70,6 +73,8 @@ class LoggedinMenuitemState extends LoggedOffState {
this.context = context; this.context = context;
this.navigator = context.getBean(ClubhelperNavigation.class); this.navigator = context.getBean(ClubhelperNavigation.class);
this.eventBusiness = context.getBean(EventBusiness.class); this.eventBusiness = context.getBean(EventBusiness.class);
this.securityVerifier = context.getBean(SecurityVerifier.class);
navigator.add(ev -> setSelectedMenuItem(ev.getNewView())); navigator.add(ev -> setSelectedMenuItem(ev.getNewView()));
View current = navigator.getNavigator().getCurrentView(); View current = navigator.getNavigator().getCurrentView();
@ -116,6 +121,15 @@ class LoggedinMenuitemState extends LoggedOffState {
new SwitchViewCommand(context, "Veranstaltung Detail", null, ClubhelperViews.EventDetails)); new SwitchViewCommand(context, "Veranstaltung Detail", null, ClubhelperViews.EventDetails));
eventDetailItem = detailViewCommand.addTo(viewMenu); eventDetailItem = detailViewCommand.addTo(viewMenu);
eventDetailItem.setCheckable(true); eventDetailItem.setCheckable(true);
if (securityVerifier.isPermitted(SecurityGroups.ADMIN)) {
CommandWrapper systeminfoViewCommand = new CommandWrapper(
new SwitchViewCommand(context, "Systeminformation", null, ClubhelperViews.Systeminfo));
systeminfoItem = systeminfoViewCommand.addTo(viewMenu);
systeminfoItem.setCheckable(true);
}
} }
private void prepareEditMenu(ClubhelperMenuBar menuBar) { private void prepareEditMenu(ClubhelperMenuBar menuBar) {

@ -63,6 +63,8 @@ public class ClubhelperNavigation implements ApplicationContextAware {
private PersonEditView personEdit; private PersonEditView personEdit;
private SysteminfoView systemInfo;
public void configure(UI mainUI) { public void configure(UI mainUI) {
// Create and register the views // Create and register the views
@ -72,6 +74,7 @@ public class ClubhelperNavigation implements ApplicationContextAware {
ViewFactory factory = new ViewFactory(page); ViewFactory factory = new ViewFactory(page);
mainView = factory.createMain(); mainView = factory.createMain();
personEdit = factory.createPersonEdit(); personEdit = factory.createPersonEdit();
systemInfo = factory.createSystemInfo();
MenuItemStateFactory menuItemFactory = context.getBean(MenuItemStateFactory.class); MenuItemStateFactory menuItemFactory = context.getBean(MenuItemStateFactory.class);
setupMenuItemStateFactory(menuItemFactory); setupMenuItemStateFactory(menuItemFactory);
@ -88,6 +91,7 @@ public class ClubhelperNavigation implements ApplicationContextAware {
navi.addView(ClubhelperViews.EventDetails.name(), new EventDetails(context)); navi.addView(ClubhelperViews.EventDetails.name(), new EventDetails(context));
navi.addView(ClubhelperViews.SendEmails.name(), new SendEmails(context, true)); navi.addView(ClubhelperViews.SendEmails.name(), new SendEmails(context, true));
navi.addView(ClubhelperViews.ExportEmails.name(), new ExportEmails(context)); navi.addView(ClubhelperViews.ExportEmails.name(), new ExportEmails(context));
navi.addView(ClubhelperViews.Systeminfo.name(), systemInfo);
page.addBrowserWindowResizeListener(ev -> { page.addBrowserWindowResizeListener(ev -> {
int width = ev.getWidth(); int width = ev.getWidth();
@ -121,9 +125,13 @@ public class ClubhelperNavigation implements ApplicationContextAware {
this.page = page; this.page = page;
} }
public SysteminfoView createSystemInfo() {
return new SysteminfoView(isMobileSize());
}
public MainView createMain() { public MainView createMain() {
if (page.getBrowserWindowWidth() < WIDTH_LIMIT_FOR_MOBILE) { if (isMobileSize()) {
return new MainViewMobile(context, personBusiness, groupDao, eventBusiness, securityGroupVerifier); return new MainViewMobile(context, personBusiness, groupDao, eventBusiness, securityGroupVerifier);
} }
else { else {
@ -131,9 +139,12 @@ public class ClubhelperNavigation implements ApplicationContextAware {
} }
} }
private boolean isMobileSize() {
return page.getBrowserWindowWidth() < WIDTH_LIMIT_FOR_MOBILE;
}
public PersonEditView createPersonEdit() { public PersonEditView createPersonEdit() {
PersonEditView personEditView = new PersonEditView(groupDao, personBusiness, PersonEditView personEditView = new PersonEditView(groupDao, personBusiness, isMobileSize());
(page.getBrowserWindowWidth() >= WIDTH_LIMIT_FOR_MOBILE));
return personEditView; return personEditView;
} }
} }

@ -11,6 +11,7 @@ public enum ClubhelperViews {
PersonEditView, PersonEditView,
ExportEmails, ExportEmails,
LoginUI, LoginUI,
Systeminfo,
SendEmails; SendEmails;
public static ClubhelperViews byState(String state) { public static ClubhelperViews byState(String state) {

@ -0,0 +1,67 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation;
import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.stream.Collectors;
import com.vaadin.data.provider.DataProvider;
import com.vaadin.data.provider.ListDataProvider;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.shared.ui.ContentMode;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Grid.SelectionMode;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
public class SysteminfoView extends VerticalLayout implements View {
private final Grid<Entry<String, String>> valueGrid;
private ListDataProvider<Entry<String, String>> entryDataProvider;
public SysteminfoView(boolean mobile) {
valueGrid = new Grid<>();
valueGrid.addColumn(Entry<String, String>::getKey)
.setCaption("Schlüssel")
.setSortable(true)
.setResizable(true);
valueGrid.addColumn(Entry<String, String>::getValue)
.setCaption("Wert")
.setSortable(false)
.setResizable(true);
valueGrid.setSelectionMode(SelectionMode.NONE);
valueGrid.setSizeFull();
entryDataProvider = DataProvider.ofCollection(new ArrayList<Entry<String, String>>());
valueGrid.setDataProvider(entryDataProvider);
Label title = new Label("<h1>Systeminformationen</h1>", ContentMode.HTML);
addComponent(title);
addComponent(valueGrid);
}
@Override
public void enter(ViewChangeEvent event) {
Collection<Entry<String, String>> items = entryDataProvider.getItems();
items.clear();
Locale locale = Locale.getDefault();
items.add(new SimpleEntry<>("Sprache", locale.toLanguageTag()));
Map<String, String> environment = System.getenv();
items.addAll(environment.entrySet());
Properties systemProperties = System.getProperties();
items.addAll(systemProperties.entrySet().stream().map(this::mapEntry).collect(Collectors.toList()));
}
private Entry<String, String> mapEntry(Entry<Object, Object> item) {
return new SimpleEntry<>(item.getKey().toString(), item.getValue().toString());
}
}
Loading…
Cancel
Save