diff --git a/.settings/com.vaadin.integration.eclipse.prefs b/.settings/com.vaadin.integration.eclipse.prefs index 0e24091..9b7d93b 100644 --- a/.settings/com.vaadin.integration.eclipse.prefs +++ b/.settings/com.vaadin.integration.eclipse.prefs @@ -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.useLatestNightly=false com.vaadin.integration.eclipse.widgetsetDirty=true diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedinMenuitemState.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedinMenuitemState.java index 102e740..970eaba 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedinMenuitemState.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/menu/LoggedinMenuitemState.java @@ -21,6 +21,7 @@ import com.vaadin.ui.Window; import de.kreth.googleconnectors.calendar.CalendarAdapter; import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness; 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.ui.commands.ClubCommand; import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.commands.CreateMeldungCommand; @@ -63,6 +64,8 @@ class LoggedinMenuitemState extends LoggedOffState { private MenuItem sendEmailsMenuItem; + private MenuItem systeminfoItem; + public LoggedinMenuitemState(ApplicationContext context, UI ui, Supplier startProvider, Supplier endProvider, BiConsumer printConsumer) { super(context, startProvider, endProvider, printConsumer); @@ -70,6 +73,8 @@ class LoggedinMenuitemState extends LoggedOffState { this.context = context; this.navigator = context.getBean(ClubhelperNavigation.class); this.eventBusiness = context.getBean(EventBusiness.class); + this.securityVerifier = context.getBean(SecurityVerifier.class); + navigator.add(ev -> setSelectedMenuItem(ev.getNewView())); View current = navigator.getNavigator().getCurrentView(); @@ -116,6 +121,15 @@ class LoggedinMenuitemState extends LoggedOffState { new SwitchViewCommand(context, "Veranstaltung Detail", null, ClubhelperViews.EventDetails)); eventDetailItem = detailViewCommand.addTo(viewMenu); 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) { diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/ClubhelperNavigation.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/ClubhelperNavigation.java index 6b01b59..9bf60f6 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/ClubhelperNavigation.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/ClubhelperNavigation.java @@ -63,6 +63,8 @@ public class ClubhelperNavigation implements ApplicationContextAware { private PersonEditView personEdit; + private SysteminfoView systemInfo; + public void configure(UI mainUI) { // Create and register the views @@ -72,6 +74,7 @@ public class ClubhelperNavigation implements ApplicationContextAware { ViewFactory factory = new ViewFactory(page); mainView = factory.createMain(); personEdit = factory.createPersonEdit(); + systemInfo = factory.createSystemInfo(); MenuItemStateFactory menuItemFactory = context.getBean(MenuItemStateFactory.class); setupMenuItemStateFactory(menuItemFactory); @@ -88,6 +91,7 @@ public class ClubhelperNavigation implements ApplicationContextAware { navi.addView(ClubhelperViews.EventDetails.name(), new EventDetails(context)); navi.addView(ClubhelperViews.SendEmails.name(), new SendEmails(context, true)); navi.addView(ClubhelperViews.ExportEmails.name(), new ExportEmails(context)); + navi.addView(ClubhelperViews.Systeminfo.name(), systemInfo); page.addBrowserWindowResizeListener(ev -> { int width = ev.getWidth(); @@ -121,9 +125,13 @@ public class ClubhelperNavigation implements ApplicationContextAware { this.page = page; } + public SysteminfoView createSystemInfo() { + return new SysteminfoView(isMobileSize()); + } + public MainView createMain() { - if (page.getBrowserWindowWidth() < WIDTH_LIMIT_FOR_MOBILE) { + if (isMobileSize()) { return new MainViewMobile(context, personBusiness, groupDao, eventBusiness, securityGroupVerifier); } else { @@ -131,9 +139,12 @@ public class ClubhelperNavigation implements ApplicationContextAware { } } + private boolean isMobileSize() { + return page.getBrowserWindowWidth() < WIDTH_LIMIT_FOR_MOBILE; + } + public PersonEditView createPersonEdit() { - PersonEditView personEditView = new PersonEditView(groupDao, personBusiness, - (page.getBrowserWindowWidth() >= WIDTH_LIMIT_FOR_MOBILE)); + PersonEditView personEditView = new PersonEditView(groupDao, personBusiness, isMobileSize()); return personEditView; } } diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/ClubhelperViews.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/ClubhelperViews.java index 3a9948f..246c08c 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/ClubhelperViews.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/ClubhelperViews.java @@ -11,6 +11,7 @@ public enum ClubhelperViews { PersonEditView, ExportEmails, LoginUI, + Systeminfo, SendEmails; public static ClubhelperViews byState(String state) { diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/SysteminfoView.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/SysteminfoView.java new file mode 100644 index 0000000..89c8221 --- /dev/null +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/SysteminfoView.java @@ -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> valueGrid; + + private ListDataProvider> entryDataProvider; + + public SysteminfoView(boolean mobile) { + valueGrid = new Grid<>(); + valueGrid.addColumn(Entry::getKey) + .setCaption("Schlüssel") + .setSortable(true) + .setResizable(true); + valueGrid.addColumn(Entry::getValue) + .setCaption("Wert") + .setSortable(false) + .setResizable(true); + + valueGrid.setSelectionMode(SelectionMode.NONE); + valueGrid.setSizeFull(); + + entryDataProvider = DataProvider.ofCollection(new ArrayList>()); + valueGrid.setDataProvider(entryDataProvider); + Label title = new Label("

Systeminformationen

", ContentMode.HTML); + addComponent(title); + addComponent(valueGrid); + } + + @Override + public void enter(ViewChangeEvent event) { + + Collection> items = entryDataProvider.getItems(); + items.clear(); + Locale locale = Locale.getDefault(); + items.add(new SimpleEntry<>("Sprache", locale.toLanguageTag())); + + Map environment = System.getenv(); + items.addAll(environment.entrySet()); + + Properties systemProperties = System.getProperties(); + items.addAll(systemProperties.entrySet().stream().map(this::mapEntry).collect(Collectors.toList())); + } + + private Entry mapEntry(Entry item) { + return new SimpleEntry<>(item.getKey().toString(), item.getValue().toString()); + } +}