From 46ee19038c42af81a0f07f101f1979046fa5f3b3 Mon Sep 17 00:00:00 2001 From: Marcus Fihlon Date: Tue, 16 Jul 2024 11:30:57 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20add=20config=20option=20to=20sho?= =?UTF-8?q?w/hide=20event=20room=20legend=20closes=20#165?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcus Fihlon --- CHANGELOG.md | 1 + README.md | 1 + .../fihlon/apus/plugin/event/EventConfig.java | 2 +- .../swiss/fihlon/apus/ui/view/EventView.java | 15 ++- .../fihlon/apus/ui/view/SocialWallView.java | 2 +- ...itional-spring-configuration-metadata.json | 103 +++++++++--------- src/main/resources/application.properties | 1 + .../apus/plugin/event/EventServiceTest.java | 2 +- src/test/resources/application.properties | 1 + 9 files changed, 73 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b47f4b6..0e47391 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ For questions and support requests, please use * Add support for session tracks with default icons and custom SVG images * Theming: all colors are now configurable * Create hashed passwords for admin access on the command line +* New config option to show/hide event room legend ### Bugfixes diff --git a/README.md b/README.md index f03c910..75aa5d6 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ To modify the default configuration values, just specify environment variables w | DEMO_ROOM_COUNT | 0 | Number of rooms for the event demo plugin (0 = disabled). | | DOAG_EVENT_API | [1] | The URL of the DOAG event API to read the conference agenda. | | DOAG_EVENT_ID | 0 | The ID of the DOAG event to read the conference agenda (0 = disabled). | +| EVENT_SHOW_LEGEND | true | Show (true) or hide (false) the event room legend. | | EVENT_UPDATE_FREQUENCY | 5 | How often (in minutes) to update event data (0 = disabled). | | FILTER_LENGTH | 500 | Hide social media posts which exceed this length (0 = disabled). | | FILTER_REPLIES | true | Hide social media posts which are replies. | diff --git a/src/main/java/swiss/fihlon/apus/plugin/event/EventConfig.java b/src/main/java/swiss/fihlon/apus/plugin/event/EventConfig.java index 9d5ded1..24bcabc 100644 --- a/src/main/java/swiss/fihlon/apus/plugin/event/EventConfig.java +++ b/src/main/java/swiss/fihlon/apus/plugin/event/EventConfig.java @@ -17,5 +17,5 @@ */ package swiss.fihlon.apus.plugin.event; -public record EventConfig(int updateFrequency) { +public record EventConfig(int updateFrequency, boolean showLegend) { } diff --git a/src/main/java/swiss/fihlon/apus/ui/view/EventView.java b/src/main/java/swiss/fihlon/apus/ui/view/EventView.java index daa6d5e..9f839d7 100644 --- a/src/main/java/swiss/fihlon/apus/ui/view/EventView.java +++ b/src/main/java/swiss/fihlon/apus/ui/view/EventView.java @@ -25,6 +25,7 @@ import com.vaadin.flow.component.notification.Notification; import org.jetbrains.annotations.NotNull; import org.springframework.scheduling.TaskScheduler; +import swiss.fihlon.apus.configuration.Configuration; import swiss.fihlon.apus.event.Room; import swiss.fihlon.apus.event.RoomStyle; import swiss.fihlon.apus.event.Session; @@ -53,12 +54,18 @@ public final class EventView extends Div { private final Div roomContainer = new Div(); private final Span legend = new Span(); + private final boolean showLegend; + public EventView(@NotNull final EventService eventService, - @NotNull final TaskScheduler taskScheduler) { + @NotNull final TaskScheduler taskScheduler, + @NotNull final Configuration configuration) { this.eventService = eventService; + this.showLegend = configuration.getEvent().showLegend(); setId("event-view"); add(createTitle()); - add(createLegend()); + if (showLegend) { + add(createLegend()); + } add(roomContainer); roomContainer.addClassName("room-container"); final ScheduledFuture updateScheduler = taskScheduler.scheduleAtFixedRate( @@ -88,7 +95,9 @@ private void updateConferenceSessions() { roomStylesInUse.add(roomView.getRoomStyle()); roomContainer.add(roomView); } - updateLegend(roomStylesInUse); + if (showLegend) { + updateLegend(roomStylesInUse); + } } @NotNull diff --git a/src/main/java/swiss/fihlon/apus/ui/view/SocialWallView.java b/src/main/java/swiss/fihlon/apus/ui/view/SocialWallView.java index d3cc30a..109a1de 100644 --- a/src/main/java/swiss/fihlon/apus/ui/view/SocialWallView.java +++ b/src/main/java/swiss/fihlon/apus/ui/view/SocialWallView.java @@ -59,7 +59,7 @@ public SocialWallView(@NotNull final EventService eventService, }); } setId("social-wall-view"); - add(new EventView(eventService, taskScheduler)); + add(new EventView(eventService, taskScheduler, configuration)); add(new SocialView(socialService, taskScheduler, configuration)); } } diff --git a/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 5b939ca..165abb2 100644 --- a/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -1,14 +1,14 @@ { - "properties": [ + "properties" : [ { - "name": "apus.admin.password", - "type": "java.lang.String", - "description": "The password to get admin access (empty = disabled)." + "name" : "apus.admin.password", + "type" : "java.lang.String", + "description" : "The password to get admin access (empty = disabled)." }, { - "name": "apus.custom.styles", - "type": "java.lang.String", - "description": "Inject custom styles into the user interface." + "name" : "apus.custom.styles", + "type" : "java.lang.String", + "description" : "Inject custom styles into the user interface." }, { "name" : "apus.demo.roomCount", @@ -16,74 +16,79 @@ "description" : "Number of rooms for the event demo plugin." }, { - "name": "apus.doag.eventApi", - "type": "java.lang.String", - "description": "The URL of the DOAG event API to read the conference agenda." + "name" : "apus.doag.eventApi", + "type" : "java.lang.String", + "description" : "The URL of the DOAG event API to read the conference agenda." }, { - "name": "apus.doag.eventId", - "type": "java.lang.Integer", - "description": "The ID of the DOAG event to read the conference agenda." + "name" : "apus.doag.eventId", + "type" : "java.lang.Integer", + "description" : "The ID of the DOAG event to read the conference agenda." + }, + { + "name" : "apus.event.showLegend", + "type" : "java.lang.Boolean", + "description" : "Show (true) or hide (false) the event room legend." }, { - "name": "apus.event.updateFrequency", - "type": "java.lang.Integer", - "description": "How often (in minutes) to update event data." + "name" : "apus.event.updateFrequency", + "type" : "java.lang.Integer", + "description" : "How often (in minutes) to update event data." }, { - "name": "apus.filter.length", - "type": "java.lang.Integer", - "description": "Hide social media messages which exceed this length." + "name" : "apus.filter.length", + "type" : "java.lang.Integer", + "description" : "Hide social media messages which exceed this length." }, { - "name": "apus.filter.replies", - "type": "java.lang.Boolean", - "description": "Hide social media messages which are replies." + "name" : "apus.filter.replies", + "type" : "java.lang.Boolean", + "description" : "Hide social media messages which are replies." }, { - "name": "apus.filter.sensitive", - "type": "java.lang.Boolean", - "description": "Hide social media messages which contain sensitive information." + "name" : "apus.filter.sensitive", + "type" : "java.lang.Boolean", + "description" : "Hide social media messages which contain sensitive information." }, { - "name": "apus.filter.words", - "type": "java.lang.String", - "description": "Hide social media messages which contain these words." + "name" : "apus.filter.words", + "type" : "java.lang.String", + "description" : "Hide social media messages which contain these words." }, { - "name": "apus.jfs.dbUrl", - "type": "java.lang.String", - "description": "The URL of the database file for Java Forum Stuttgart." + "name" : "apus.jfs.dbUrl", + "type" : "java.lang.String", + "description" : "The URL of the database file for Java Forum Stuttgart." }, { - "name": "apus.mastodon.hashtag", - "type": "java.lang.String", - "description": "The hashtag for the Mastodon wall." + "name" : "apus.mastodon.hashtag", + "type" : "java.lang.String", + "description" : "The hashtag for the Mastodon wall." }, { - "name": "apus.mastodon.imageLimit", - "type": "java.lang.Integer", - "description": "Limit number of images per post." + "name" : "apus.mastodon.imageLimit", + "type" : "java.lang.Integer", + "description" : "Limit number of images per post." }, { - "name": "apus.mastodon.imagesEnabled", - "type": "java.lang.Boolean", - "description": "Enable or disable images in mastodon posts." + "name" : "apus.mastodon.imagesEnabled", + "type" : "java.lang.Boolean", + "description" : "Enable or disable images in mastodon posts." }, { - "name": "apus.mastodon.instance", - "type": "java.lang.String", - "description": "The Mastodon instance used to read the posts from." + "name" : "apus.mastodon.instance", + "type" : "java.lang.String", + "description" : "The Mastodon instance used to read the posts from." }, { - "name": "apus.sessionize.eventId", - "type": "java.lang.String", - "description": "The ID of the Sessionize event to read the conference agenda." + "name" : "apus.sessionize.eventId", + "type" : "java.lang.String", + "description" : "The ID of the Sessionize event to read the conference agenda." }, { - "name": "apus.sessionize.eventApi", - "type": "java.lang.String", - "description": "The URL of the Sessionize event API to read the conference agenda." + "name" : "apus.sessionize.eventApi", + "type" : "java.lang.String", + "description" : "The URL of the Sessionize event API to read the conference agenda." } ] } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 6c1d37a..86a207f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,6 +15,7 @@ apus.custom.styles=${CUSTOM_STYLES:} apus.demo.roomCount=${DEMO_ROOM_COUNT:0} apus.doag.eventApi=${DOAG_EVENT_API:https://meine.doag.org/api/event/action.getCPEventAgenda/eventId.%d/} apus.doag.eventId=${DOAG_EVENT_ID:0} +apus.event.showLegend=${EVENT_SHOW_LEGEND:true} apus.event.updateFrequency=${EVENT_UPDATE_FREQUENCY:5} apus.filter.length=${FILTER_LENGTH:500} apus.filter.replies=${FILTER_REPLIES:true} diff --git a/src/test/java/swiss/fihlon/apus/plugin/event/EventServiceTest.java b/src/test/java/swiss/fihlon/apus/plugin/event/EventServiceTest.java index 3117982..5d80c69 100644 --- a/src/test/java/swiss/fihlon/apus/plugin/event/EventServiceTest.java +++ b/src/test/java/swiss/fihlon/apus/plugin/event/EventServiceTest.java @@ -51,7 +51,7 @@ class EventServiceTest { @BeforeAll static void mockConfiguration() { configurationMock = mock(Configuration.class); - when(configurationMock.getEvent()).thenReturn(new EventConfig(0)); + when(configurationMock.getEvent()).thenReturn(new EventConfig(0, true)); } @Test diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 145faed..4b08588 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -5,6 +5,7 @@ apus.custom.styles= apus.demo.roomCount=-1 apus.doag.eventApi=file:src/test/resources/DOAG.json?eventId=%d apus.doag.eventId=-1 +apus.event.showLegend=true apus.event.updateFrequency=5 apus.filter.length=500 apus.filter.replies=false