This is an automated email from the ASF dual-hosted git repository.

solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git


The following commit(s) were added to refs/heads/master by this push:
     new 15a4fb1  [OPENMEETINGS-2605] theme support is added
15a4fb1 is described below

commit 15a4fb11dfc0868a285447fb3ffa17475a451e7c
Author: Maxim Solodovnik <solomax...@gmail.com>
AuthorDate: Tue Apr 6 23:24:22 2021 +0700

    [OPENMEETINGS-2605] theme support is added
---
 .../java/org/apache/openmeetings/IApplication.java   |  2 ++
 .../openmeetings/db/dao/basic/ConfigurationDao.java  |  9 +++++++++
 .../openmeetings/installation/ImportInitvalues.java  |  5 +++++
 .../openmeetings/util/OpenmeetingsVariables.java     | 10 ++++++++++
 .../org/apache/openmeetings/web/app/Application.java | 20 +++++++++++++++++++-
 5 files changed, 45 insertions(+), 1 deletion(-)

diff --git 
a/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java 
b/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java
index cc90aa5..45f9f91 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/IApplication.java
@@ -50,4 +50,6 @@ public interface IApplication {
        //WS
        void publishWsTopic(IClusterWsMessage msg);
        Set<String> getWsUrls();
+
+       void updateTheme();
 }
diff --git 
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/basic/ConfigurationDao.java
 
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/basic/ConfigurationDao.java
index 3bcc3a8..71b8a8d 100644
--- 
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/basic/ConfigurationDao.java
+++ 
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/basic/ConfigurationDao.java
@@ -351,6 +351,9 @@ public class ConfigurationDao implements 
IDataProviderDao<Configuration> {
                        case CONFIG_RECORDING_ENABLED:
                                reloadRecordingEnabled();
                                break;
+                       case CONFIG_THEME:
+                               reloadTheme();
+                               break;
                }
                return entity;
        }
@@ -493,6 +496,11 @@ public class ConfigurationDao implements 
IDataProviderDao<Configuration> {
                setRecordingsEnabled(getBool(CONFIG_RECORDING_ENABLED, true));
        }
 
+       private void reloadTheme() {
+               setTheme(getString(CONFIG_THEME, ""));
+               app.updateTheme();
+       }
+
        public void reinit() {
                reloadMaxUpload();
                reloadCrypt();
@@ -520,6 +528,7 @@ public class ConfigurationDao implements 
IDataProviderDao<Configuration> {
                reloadMailSettings();
                reloadAppointmentSettings();
                reloadRecordingEnabled();
+               reloadTheme();
 
                updateCsp();
        }
diff --git 
a/openmeetings-install/src/main/java/org/apache/openmeetings/installation/ImportInitvalues.java
 
b/openmeetings-install/src/main/java/org/apache/openmeetings/installation/ImportInitvalues.java
index e44bbe4..507b4c4 100644
--- 
a/openmeetings-install/src/main/java/org/apache/openmeetings/installation/ImportInitvalues.java
+++ 
b/openmeetings-install/src/main/java/org/apache/openmeetings/installation/ImportInitvalues.java
@@ -105,6 +105,7 @@ import static 
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_SMTP_TIM
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_SMTP_TIMEOUT_CON;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_SMTP_TLS;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_SMTP_USER;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_THEME;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.DEFAULT_APP_NAME;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.DEFAULT_CSP_DATA;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.DEFAULT_CSP_FONT;
@@ -118,6 +119,7 @@ import static 
org.apache.openmeetings.util.OpenmeetingsVariables.getAudioBitrate
 import static org.apache.openmeetings.util.OpenmeetingsVariables.getAudioRate;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.getDefaultGroup;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.getExtProcessTtl;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getTheme;
 import static org.apache.wicket.csp.CSPDirectiveSrcValue.SELF;
 import static org.apache.wicket.csp.CSPDirectiveSrcValue.STRICT_DYNAMIC;
 
@@ -396,6 +398,9 @@ public class ImportInitvalues {
                addCfg(list, CONFIG_APPOINTMENT_PRE_START_MINUTES, 
String.valueOf(getAppointmentPreStartMinutes()), Configuration.Type.NUMBER
                                , "How many minutes before the start the room 
should be open (default: " + getAppointmentPreStartMinutes() + ")", VER_5_0_1);
                addCfg(list, CONFIG_RECORDING_ENABLED, String.valueOf(true), 
Configuration.Type.BOOL, "Whether or not recording functionality is enabled", 
"6.0.0");
+               addCfg(list, CONFIG_THEME, getTheme(), 
Configuration.Type.STRING, "UI theme, possible values are Cerulean, Cosmo, 
Cyborg, Darkly, Flatly, "
+                               + "Journal, Litera, Lumen, Lux, Materia, Minty, 
Pulse, Sandstone, Simplex, Sketchy, Slate, Solar, Spacelab, Superhero, "
+                               + "United, Yeti", "6.1.0");
                return list;
        }
        public void loadConfiguration(InstallationConfig cfg) {
diff --git 
a/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
 
b/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
index 83c3ad6..20b7e48 100644
--- 
a/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
+++ 
b/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
@@ -113,6 +113,7 @@ public class OpenmeetingsVariables {
        public static final String CONFIG_CSP_STYLE = "header.csp.style";
        public static final String CONFIG_CSP_ENABLED = "header.csp.enabled";
        public static final String CONFIG_RECORDING_ENABLED = 
"recording.enabled";
+       public static final String CONFIG_THEME = "ui.theme";
 
        public static final int RECENT_ROOMS_COUNT = 5;
        public static final int USER_LOGIN_MINIMUM_LENGTH = 4;
@@ -179,6 +180,7 @@ public class OpenmeetingsVariables {
        private static int appointmentReminderMinutes = 15;
        private static int appointmentPreStartMinutes = 5;
        private static boolean recordingsEnabled = true;
+       private static String theme = "Sandstone";
 
        private OpenmeetingsVariables() {}
 
@@ -610,4 +612,12 @@ public class OpenmeetingsVariables {
        public static void setRecordingsEnabled(boolean enabled) {
                recordingsEnabled = enabled;
        }
+
+       public static String getTheme() {
+               return theme;
+       }
+
+       public static void setTheme(String inTheme) {
+               theme = inTheme;
+       }
 }
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
index 9c0849e..a173df2 100644
--- 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
+++ 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
@@ -22,6 +22,7 @@ import static 
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_EXT_PROC
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.getApplicationName;
 import static org.apache.openmeetings.util.OpenmeetingsVariables.getBaseUrl;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.getExtProcessTtl;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getTheme;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.getWicketApplicationName;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.isInitComplete;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.setExtProcessTtl;
@@ -40,6 +41,7 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.CompletableFuture;
+import java.util.stream.Stream;
 
 import javax.websocket.WebSocketContainer;
 
@@ -150,6 +152,7 @@ import com.hazelcast.topic.ITopic;
 import de.agilecoders.wicket.core.Bootstrap;
 import de.agilecoders.wicket.core.settings.BootstrapSettings;
 import de.agilecoders.wicket.core.settings.IBootstrapSettings;
+import de.agilecoders.wicket.core.settings.NoopThemeProvider;
 import de.agilecoders.wicket.themes.markup.html.bootswatch.BootswatchTheme;
 import 
de.agilecoders.wicket.themes.markup.html.bootswatch.BootswatchThemeProvider;
 
@@ -298,7 +301,6 @@ public class Application extends 
AuthenticatedWebApplication implements IApplica
                getHeaderResponseDecorators().add(FilteringHeaderResponse::new);
                super.init();
                final IBootstrapSettings settings = new BootstrapSettings();
-               settings.setThemeProvider(new 
BootswatchThemeProvider(BootswatchTheme.Sandstone));
                
Bootstrap.builder().withBootstrapSettings(settings).install(this);
                WysiwygLibrarySettings.get().setBootstrapCssReference(null);
                
WysiwygLibrarySettings.get().setBootstrapDropDownJavaScriptReference(null);
@@ -654,6 +656,22 @@ public class Application extends 
AuthenticatedWebApplication implements IApplica
                return Set.copyOf(wsUrls);
        }
 
+       @Override
+       public void updateTheme() {
+               BootswatchTheme theme = Stream.of(BootswatchTheme.values())
+                               .filter(v -> 
v.name().equalsIgnoreCase(getTheme()))
+                               .findFirst()
+                               .orElse(null);
+               IBootstrapSettings settings = Bootstrap.getSettings(this);
+               settings.setThemeProvider(theme == null ? new 
NoopThemeProvider()
+                               : new BootswatchThemeProvider(theme));
+               if (WebSession.exists()) {
+                       settings.getActiveThemeProvider().setActiveTheme(theme 
== null
+                                       ? 
settings.getThemeProvider().defaultTheme()
+                                       : 
settings.getThemeProvider().byName(theme.name()));
+               }
+       }
+
        // package private for testing
        static String getWsUrl(Url reqUrl) {
                if (!reqUrl.isFull()) {

Reply via email to