From 01d3464725c583cac22dd33bbb6ee46980c29b75 Mon Sep 17 00:00:00 2001 From: Udo Walter Date: Thu, 13 Aug 2020 20:35:46 +0200 Subject: Move custom logo to the bottom left With the property 'slx-logo-primary: true' in the guacamole.properties file the custom logo will be displayed as the primary logo in the center. (In this case the bwlehrpool logo will displayed in the bottom left instead) --- .../java/de/bwlehrpool/bwlp_guac/BwlpREST.java | 8 ++++---- .../java/de/bwlehrpool/bwlp_guac/SlxConfig.java | 23 +++++++++++++++++++--- src/main/resources/bwlpModule.js | 10 ++++++---- src/main/resources/guac-manifest.json | 2 +- src/main/resources/secondary-logo.html | 3 +++ src/main/resources/styles/login.css | 15 ++++++++++++-- 6 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 src/main/resources/secondary-logo.html diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/BwlpREST.java b/src/main/java/de/bwlehrpool/bwlp_guac/BwlpREST.java index 65258f7..4830d02 100644 --- a/src/main/java/de/bwlehrpool/bwlp_guac/BwlpREST.java +++ b/src/main/java/de/bwlehrpool/bwlp_guac/BwlpREST.java @@ -8,10 +8,10 @@ import javax.ws.rs.core.MediaType; public class BwlpREST { @GET - @Path("logoUrl") - @Produces(MediaType.TEXT_PLAIN) - public String getLogoUrl() { - return SlxConfig.logoUrl(); + @Path("logoConfig") + @Produces(MediaType.APPLICATION_JSON) + public String getLogoConfig() { + return "{ \"url\": \"" + SlxConfig.logoUrl() + "\", \"primary\": " + SlxConfig.logoPrimary() + " }"; } } \ No newline at end of file diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/SlxConfig.java b/src/main/java/de/bwlehrpool/bwlp_guac/SlxConfig.java index f93c965..1fadac0 100644 --- a/src/main/java/de/bwlehrpool/bwlp_guac/SlxConfig.java +++ b/src/main/java/de/bwlehrpool/bwlp_guac/SlxConfig.java @@ -27,6 +27,13 @@ public class SlxConfig { } }; + private static final StringGuacamoleProperty LOGO_PRIMARY = new StringGuacamoleProperty() { + @Override + public String getName() { + return "slx-logo-primary"; + } + }; + static { Environment e; try { @@ -49,10 +56,20 @@ public class SlxConfig { public static String logoUrl() { try { - return ENVIRONMENT.getProperty(LOGO_URL); + String url = ENVIRONMENT.getProperty(LOGO_URL); + if (url == null) return ""; + return url; } catch (GuacamoleException e) { - LOGGER.warn("Cannot get logo url from properties", e); - return null; + return ""; + } + } + + public static boolean logoPrimary() { + try { + String primary = ENVIRONMENT.getProperty(LOGO_PRIMARY); + return primary != null && primary.equals("true"); + } catch (GuacamoleException e) { + return false; } } diff --git a/src/main/resources/bwlpModule.js b/src/main/resources/bwlpModule.js index f0605e3..8e45c74 100644 --- a/src/main/resources/bwlpModule.js +++ b/src/main/resources/bwlpModule.js @@ -5,8 +5,10 @@ angular.module('group', [ angular.module('index').requires.push('group'); // Set custom logo -$http = angular.injector(["ng"]).get("$http"); -$http.get('api/ext/de.bwlehrpool.bwgpul/logoUrl').then(function (response) { - if (!response.data) return - document.documentElement.style.setProperty('--logo', "url('" + response.data + "')") +$http = angular.injector(['ng']).get('$http'); +$http.get('api/ext/de.bwlehrpool.bwgpul/logoConfig').then(function (response) { + if (!response.data || !response.data.url) return; + let cssVar = response.data.primary ? '--primary-logo' : '--secondary-logo'; + document.documentElement.style.setProperty(cssVar, "url('" + response.data.url + "')"); + document.documentElement.style.setProperty('--secondary-logo-display', "block"); }) diff --git a/src/main/resources/guac-manifest.json b/src/main/resources/guac-manifest.json index de2a5cf..565984d 100644 --- a/src/main/resources/guac-manifest.json +++ b/src/main/resources/guac-manifest.json @@ -6,7 +6,7 @@ "largeIcon" : "images/Logo_bwLehrpool_symbol.png", "authProviders": ["de.bwlehrpool.bwlp_guac.BwlpAuthenticationProvider"], "listeners" : ["de.bwlehrpool.bwlp_guac.TunnelListener"], - "html" : [ "login-logo.html", "selection-logo.html" ], + "html" : [ "login-logo.html", "selection-logo.html", "secondary-logo.html" ], "translations" : [ "translations/en.json", "translations/de.json" diff --git a/src/main/resources/secondary-logo.html b/src/main/resources/secondary-logo.html new file mode 100644 index 0000000..9ab3aef --- /dev/null +++ b/src/main/resources/secondary-logo.html @@ -0,0 +1,3 @@ + + + diff --git a/src/main/resources/styles/login.css b/src/main/resources/styles/login.css index 8fe590b..a85c6a8 100644 --- a/src/main/resources/styles/login.css +++ b/src/main/resources/styles/login.css @@ -1,5 +1,16 @@ :root { - --logo: url('app/ext/de.bwlehrpool/images/Logo_bwLehrpool.svg'); + --primary-logo: url('app/ext/de.bwlehrpool/images/Logo_bwLehrpool.svg'); + --secondary-logo: url('app/ext/de.bwlehrpool/images/Logo_bwLehrpool.svg'); + --secondary-logo-display: none; +} + +.secondary-logo { + display: var(--secondary-logo-display); + position: absolute; + left: 20px; + bottom: 20px; + width: 215px; + content: var(--secondary-logo); } .login-ui .login-logo, .login-ui .selection-logo { @@ -7,7 +18,7 @@ display: block; margin-left: auto; margin-right: auto; - content: var(--logo); + content: var(--primary-logo); } .login-ui .selection-logo { -- cgit v1.2.3-55-g7522