diff --git a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/service/WebUiCloudServicesConfiguration.java b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/service/WebUiCloudServicesConfiguration.java index 8991f47d0..39d8969c9 100644 --- a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/service/WebUiCloudServicesConfiguration.java +++ b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/service/WebUiCloudServicesConfiguration.java @@ -4,6 +4,7 @@ */ package org.geoserver.cloud.web.service; +import org.geoserver.cloud.web.ui.GeoServerCloudHomePageContentProvider; import org.geoserver.cloud.web.ui.ServiceRegistryPage; import org.geoserver.web.Category; import org.geoserver.web.ComponentAuthorizer; @@ -55,4 +56,8 @@ public class WebUiCloudServicesConfiguration { menu.setAuthorizer(ComponentAuthorizer.ADMIN); return menu; } + + public @Bean GeoServerCloudHomePageContentProvider geoServerCloudHomePageContentProvider() { + return new GeoServerCloudHomePageContentProvider(); + } } diff --git a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/ui/GeoServerCloudHomePageContentProvider.java b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/ui/GeoServerCloudHomePageContentProvider.java new file mode 100644 index 000000000..8124c499e --- /dev/null +++ b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/ui/GeoServerCloudHomePageContentProvider.java @@ -0,0 +1,32 @@ +/* + * (c) 2022 Open Source Geospatial Foundation - all rights reserved This code is licensed under the + * GPL 2.0 license, available at the root application directory. + */ +package org.geoserver.cloud.web.ui; + +import org.apache.wicket.Component; +import org.apache.wicket.markup.html.WebMarkupContainer; +import org.geoserver.security.GeoServerSecurityManager; +import org.geoserver.web.GeoServerHomePageContentProvider; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.info.BuildProperties; + +/** + * Adds gs-cloud version info to the home page from spring-boot's {@link BuildProperties} + * + * @since 1.0 + */ +public class GeoServerCloudHomePageContentProvider implements GeoServerHomePageContentProvider { + + private @Autowired GeoServerSecurityManager secManager; + + private @Autowired BuildProperties buildProperties; + + @Override + public Component getPageBodyComponent(String id) { + if (secManager.checkAuthenticationForAdminRole()) { + return new GeoServerCloudStatusPanel(id, buildProperties); + } + return new WebMarkupContainer(id); // Placeholder + } +} diff --git a/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/ui/GeoServerCloudStatusPanel.java b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/ui/GeoServerCloudStatusPanel.java new file mode 100644 index 000000000..fd3f0d164 --- /dev/null +++ b/src/apps/geoserver/webui/src/main/java/org/geoserver/cloud/web/ui/GeoServerCloudStatusPanel.java @@ -0,0 +1,21 @@ +/* + * (c) 2022 Open Source Geospatial Foundation - all rights reserved This code is licensed under the + * GPL 2.0 license, available at the root application directory. + */ +package org.geoserver.cloud.web.ui; + +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.panel.Panel; +import org.springframework.boot.info.BuildProperties; + +/** + * @since 1.0 + */ +public class GeoServerCloudStatusPanel extends Panel { + private static final long serialVersionUID = 1L; + + public GeoServerCloudStatusPanel(String id, BuildProperties buildInfo) { + super(id); + this.add(new Label("gsCloudVersion", buildInfo.getVersion())); + } +} diff --git a/src/apps/geoserver/webui/src/main/resources/org/geoserver/cloud/web/ui/GeoServerCloudStatusPanel.html b/src/apps/geoserver/webui/src/main/resources/org/geoserver/cloud/web/ui/GeoServerCloudStatusPanel.html new file mode 100644 index 000000000..28a3af4b1 --- /dev/null +++ b/src/apps/geoserver/webui/src/main/resources/org/geoserver/cloud/web/ui/GeoServerCloudStatusPanel.html @@ -0,0 +1,9 @@ + +
++ GeoServer-Cloud version N/A +
+