Skip to content

Commit

Permalink
Add GeoServer cloud version to webui home page
Browse files Browse the repository at this point in the history
  • Loading branch information
groldan committed Dec 27, 2022
1 parent 24ae69c commit 1afaad6
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -55,4 +56,8 @@ public class WebUiCloudServicesConfiguration {
menu.setAuthorizer(ComponentAuthorizer.ADMIN);
return menu;
}

public @Bean GeoServerCloudHomePageContentProvider geoServerCloudHomePageContentProvider() {
return new GeoServerCloudHomePageContentProvider();
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
@@ -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()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html xmlns:wicket="http://wicket.apache.org/">
<body>
<wicket:panel>
<p class="info-link">
<span>GeoServer-Cloud version</span> <span wicket:id="gsCloudVersion">N/A</span>
</p>
</wicket:panel>
</body>
</html>

0 comments on commit 1afaad6

Please sign in to comment.