From a648805a594e7562c2e8e3c2cfa4b87158df8999 Mon Sep 17 00:00:00 2001 From: Domenico Francesco Bruscino Date: Thu, 16 Sep 2021 09:22:51 +0200 Subject: [PATCH] ARTEMIS-3485 Fix web plugin contexts Support custom web plugin contexts defined with the `url` attribute of the `app` element in bootstrap.xml. --- .../hawtio/branding/PluginContextListener.java | 2 +- .../src/main/webapp/plugin/css/activemq.css | 7 ------- .../main/webapp/plugin/js/brandingPlugin.js | 18 ++++++++++++++++++ .../src/main/webapp/hawtconfig.json | 10 +++++----- .../hawtio/plugin/PluginContextListener.java | 2 +- 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/artemis-hawtio/activemq-branding/src/main/java/org/apache/activemq/hawtio/branding/PluginContextListener.java b/artemis-hawtio/activemq-branding/src/main/java/org/apache/activemq/hawtio/branding/PluginContextListener.java index a95fbab31d..59b1dd791a 100644 --- a/artemis-hawtio/activemq-branding/src/main/java/org/apache/activemq/hawtio/branding/PluginContextListener.java +++ b/artemis-hawtio/activemq-branding/src/main/java/org/apache/activemq/hawtio/branding/PluginContextListener.java @@ -39,7 +39,7 @@ public class PluginContextListener implements ServletContextListener { ServletContext context = servletContextEvent.getServletContext(); plugin = new HawtioPlugin(); - plugin.setContext((String)context.getInitParameter("plugin-context")); + plugin.setContext(context.getContextPath()); plugin.setName(context.getInitParameter("plugin-name")); plugin.setScripts(context.getInitParameter("plugin-scripts")); plugin.setDomain(null); diff --git a/artemis-hawtio/activemq-branding/src/main/webapp/plugin/css/activemq.css b/artemis-hawtio/activemq-branding/src/main/webapp/plugin/css/activemq.css index ee50d694ef..6c93ca7eb1 100644 --- a/artemis-hawtio/activemq-branding/src/main/webapp/plugin/css/activemq.css +++ b/artemis-hawtio/activemq-branding/src/main/webapp/plugin/css/activemq.css @@ -82,13 +82,6 @@ svg text { 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 { grid-area: main; background-color: transparent; diff --git a/artemis-hawtio/activemq-branding/src/main/webapp/plugin/js/brandingPlugin.js b/artemis-hawtio/activemq-branding/src/main/webapp/plugin/js/brandingPlugin.js index cc33a843fb..70c15054a7 100644 --- a/artemis-hawtio/activemq-branding/src/main/webapp/plugin/js/brandingPlugin.js +++ b/artemis-hawtio/activemq-branding/src/main/webapp/plugin/js/brandingPlugin.js @@ -19,6 +19,7 @@ */ var Branding = (function (Branding) { + /** * The name of this plugin */ @@ -33,6 +34,11 @@ var Branding = (function (Branding) { * The top level path of this plugin on the server */ Branding.contextPath = '/activemq-branding'; + $.get("plugin", (data) => { + if (data.hasOwnProperty('activemq-branding')) { + Branding.contextPath = data['activemq-branding'].Context; + } + }); /** * This plugin's AngularJS module instance. @@ -80,6 +86,18 @@ var Branding = (function (Branding) { // favicon settings Core.applyBranding(configManager); + brandingStyle = ` + + `; + $(brandingStyle).appendTo("head"); + Branding.log.info(Branding.pluginName, "loaded"); } initPlugin.$inject = ['configManager', 'aboutService']; diff --git a/artemis-hawtio/artemis-console/src/main/webapp/hawtconfig.json b/artemis-hawtio/artemis-console/src/main/webapp/hawtconfig.json index 84fe7796a2..940ba41cea 100644 --- a/artemis-hawtio/artemis-console/src/main/webapp/hawtconfig.json +++ b/artemis-hawtio/artemis-console/src/main/webapp/hawtconfig.json @@ -1,10 +1,10 @@ { "branding": { "appName": "Artemis Console", - "appLogoUrl": "/activemq-branding/plugin/img/activemq.png", - "companyLogoUrl": "/activemq-branding/plugin/img/activemq.png", - "css": "/activemq-branding/plugin/css/activemq.css", - "favicon": "/activemq-branding/plugin/img/favicon.png" + "appLogoUrl": "", + "companyLogoUrl": "", + "css": "", + "favicon": "" }, "login": { "description": "ActiveMQ Artemis Management Console", @@ -20,7 +20,7 @@ "productInfo": [], "additionalInfo": "", "copyright": "", - "imgSrc": "/activemq-branding/plugin/img/activemq.png" + "imgSrc": "" }, "disabledRoutes": [] } \ No newline at end of file diff --git a/artemis-hawtio/artemis-plugin/src/main/java/org/apache/activemq/hawtio/plugin/PluginContextListener.java b/artemis-hawtio/artemis-plugin/src/main/java/org/apache/activemq/hawtio/plugin/PluginContextListener.java index 75fa7064b7..a49b716fad 100644 --- a/artemis-hawtio/artemis-plugin/src/main/java/org/apache/activemq/hawtio/plugin/PluginContextListener.java +++ b/artemis-hawtio/artemis-plugin/src/main/java/org/apache/activemq/hawtio/plugin/PluginContextListener.java @@ -39,7 +39,7 @@ public class PluginContextListener implements ServletContextListener { ServletContext context = servletContextEvent.getServletContext(); plugin = new HawtioPlugin(); - plugin.setContext((String)context.getInitParameter("plugin-context")); + plugin.setContext(context.getContextPath()); plugin.setName(context.getInitParameter("plugin-name")); plugin.setScripts(context.getInitParameter("plugin-scripts")); plugin.setDomain(null);