ARTEMIS-3485 Fix web plugin contexts

Support custom web plugin contexts defined with the `url` attribute
of the `app` element in bootstrap.xml.
This commit is contained in:
Domenico Francesco Bruscino 2021-09-16 09:22:51 +02:00 committed by Justin Bertram
parent cbdaee4afa
commit a648805a59
5 changed files with 25 additions and 14 deletions

View File

@ -39,7 +39,7 @@ public class PluginContextListener implements ServletContextListener {
ServletContext context = servletContextEvent.getServletContext(); ServletContext context = servletContextEvent.getServletContext();
plugin = new HawtioPlugin(); plugin = new HawtioPlugin();
plugin.setContext((String)context.getInitParameter("plugin-context")); plugin.setContext(context.getContextPath());
plugin.setName(context.getInitParameter("plugin-name")); plugin.setName(context.getInitParameter("plugin-name"));
plugin.setScripts(context.getInitParameter("plugin-scripts")); plugin.setScripts(context.getInitParameter("plugin-scripts"));
plugin.setDomain(null); plugin.setDomain(null);

View File

@ -82,13 +82,6 @@ svg text {
border-top: 3px solid #B21054; border-top: 3px solid #B21054;
} }
/* Change the background image for Login page and About modal as well as text color etc*/
.pf-c-login, .pf-c-about-modal-box__hero {
background-image: url("/activemq-branding/plugin/img/login-screen-background.png");
background-size: cover;
--pf-c-form__label--Color: white;
}
.pf-c-login__main { .pf-c-login__main {
grid-area: main; grid-area: main;
background-color: transparent; background-color: transparent;

View File

@ -19,6 +19,7 @@
*/ */
var Branding = (function (Branding) { var Branding = (function (Branding) {
/** /**
* The name of this plugin * The name of this plugin
*/ */
@ -33,6 +34,11 @@ var Branding = (function (Branding) {
* The top level path of this plugin on the server * The top level path of this plugin on the server
*/ */
Branding.contextPath = '/activemq-branding'; Branding.contextPath = '/activemq-branding';
$.get("plugin", (data) => {
if (data.hasOwnProperty('activemq-branding')) {
Branding.contextPath = data['activemq-branding'].Context;
}
});
/** /**
* This plugin's AngularJS module instance. * This plugin's AngularJS module instance.
@ -80,6 +86,18 @@ var Branding = (function (Branding) {
// favicon settings // favicon settings
Core.applyBranding(configManager); Core.applyBranding(configManager);
brandingStyle = `
<style type='text/css'>
/* Change the background image for Login page and About modal as well as text color etc */
.pf-c-login, .pf-c-about-modal-box__hero {
background-image: url("${Branding.contextPath}/plugin/img/login-screen-background.png");
background-size: cover;
--pf-c-form__label--Color: white;
}
</style>
`;
$(brandingStyle).appendTo("head");
Branding.log.info(Branding.pluginName, "loaded"); Branding.log.info(Branding.pluginName, "loaded");
} }
initPlugin.$inject = ['configManager', 'aboutService']; initPlugin.$inject = ['configManager', 'aboutService'];

View File

@ -1,10 +1,10 @@
{ {
"branding": { "branding": {
"appName": "Artemis Console", "appName": "Artemis Console",
"appLogoUrl": "/activemq-branding/plugin/img/activemq.png", "appLogoUrl": "",
"companyLogoUrl": "/activemq-branding/plugin/img/activemq.png", "companyLogoUrl": "",
"css": "/activemq-branding/plugin/css/activemq.css", "css": "",
"favicon": "/activemq-branding/plugin/img/favicon.png" "favicon": ""
}, },
"login": { "login": {
"description": "ActiveMQ Artemis Management Console", "description": "ActiveMQ Artemis Management Console",
@ -20,7 +20,7 @@
"productInfo": [], "productInfo": [],
"additionalInfo": "", "additionalInfo": "",
"copyright": "", "copyright": "",
"imgSrc": "/activemq-branding/plugin/img/activemq.png" "imgSrc": ""
}, },
"disabledRoutes": [] "disabledRoutes": []
} }

View File

@ -39,7 +39,7 @@ public class PluginContextListener implements ServletContextListener {
ServletContext context = servletContextEvent.getServletContext(); ServletContext context = servletContextEvent.getServletContext();
plugin = new HawtioPlugin(); plugin = new HawtioPlugin();
plugin.setContext((String)context.getInitParameter("plugin-context")); plugin.setContext(context.getContextPath());
plugin.setName(context.getInitParameter("plugin-name")); plugin.setName(context.getInitParameter("plugin-name"));
plugin.setScripts(context.getInitParameter("plugin-scripts")); plugin.setScripts(context.getInitParameter("plugin-scripts"));
plugin.setDomain(null); plugin.setDomain(null);