From ef83c679e523a0436c8cef3cb3f81652adf3b772 Mon Sep 17 00:00:00 2001 From: Marcus Fihlon Date: Sun, 15 Sep 2024 18:18:36 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Display=20optional=20image=20below?= =?UTF-8?q?=20the=20event=20agenda=20closes=20#156?= 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 | 5 +++++ frontend/themes/apus/styles.css | 6 ++++++ frontend/themes/apus/views/event-view.css | 9 +++++++++ .../swiss/fihlon/apus/plugin/event/EventConfig.java | 3 ++- .../java/swiss/fihlon/apus/ui/view/EventView.java | 13 +++++++++++++ .../additional-spring-configuration-metadata.json | 5 +++++ src/main/resources/application.properties | 1 + .../fihlon/apus/plugin/event/EventServiceTest.java | 2 +- src/test/resources/application.properties | 1 + 10 files changed, 44 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc240b4..90961e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ For questions and support requests, please use * Add configuration option to adjust event dates * Add configuration option to hide closed event rooms +* Display optional image below the event agenda ### Fixed Bugs diff --git a/README.md b/README.md index 7270dea..ab19831 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,7 @@ To modify the default configuration values, just specify environment variables w | 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_DATE_ADJUST | | Adjust the date of the event in days, ISO-8601 formatted (empty = disabled). | +| EVENT_IMAGE_URL | | The URL of the image to be shown below the event agenda (empty = no image). | | EVENT_NEXT_SESSION_TIMEOUT | 60 | Number of minutes a session is shown before it starts (0 = disabled). | | EVENT_SHOW_CLOSED_ROOMS | true | Show (true) or hide (false) closed event rooms. | | EVENT_SHOW_LEGEND | true | Show (true) or hide (false) the event room legend. | @@ -177,6 +178,10 @@ The following table contains the CSS variables you can modify to change the user | --event-next-session-color | #eeeeee | The color for the background of rooms with sessions starting next. | | --event-closed-room-color | #cccccc | The color for the background of closed rooms. | | --event-room-border | 1px solid #909090 | The border for the event room. | +| --event-image-position-bottom | 10px | The position of the optional event image relative to the bottom. | +| --event-image-position-left | 10px | The position of the optional event image relative to the left. | +| --event-image-width | auto | The width of the optional event image. | +| --event-image-height | auto | The height of the optional event image. | | --social-background-color | #e7eaee | The color for the background of the social wall. | | --social-title-color | #262626 | The color for the title of the social wall. | | --social-text-color | #262626 | The color for the text of the social wall. | diff --git a/frontend/themes/apus/styles.css b/frontend/themes/apus/styles.css index 15ea1d0..93cbcef 100644 --- a/frontend/themes/apus/styles.css +++ b/frontend/themes/apus/styles.css @@ -27,6 +27,12 @@ --event-width: 870px; --event-grid-template-columns: auto auto; + --event-image-border: none; + --event-image-position-bottom: 10px; + --event-image-position-left: 10px; + --event-image-width: auto; + --event-image-height: auto; + --social-background-color: #e7eaee; --social-title-color: #262626; --social-text-color: #262626; diff --git a/frontend/themes/apus/views/event-view.css b/frontend/themes/apus/views/event-view.css index 2378105..a02f79f 100644 --- a/frontend/themes/apus/views/event-view.css +++ b/frontend/themes/apus/views/event-view.css @@ -55,3 +55,12 @@ grid-template-columns: var(--event-grid-template-columns); } +#event-view #event-image { + position: absolute; + border-radius: var(--lumo-border-radius-s); + border: var(--event-image-border); + bottom: var(--event-image-position-bottom); + left: var(--event-image-position-left); + width: var(--event-image-width); + height: var(--event-image-height); +} 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 c7709a1..2e9e6ce 100644 --- a/src/main/java/swiss/fihlon/apus/plugin/event/EventConfig.java +++ b/src/main/java/swiss/fihlon/apus/plugin/event/EventConfig.java @@ -19,4 +19,5 @@ import java.time.Period; -public record EventConfig(Period dateAdjust, int nextSessionTimeout, boolean showClosedRooms, boolean showLegend, int updateFrequency) { } +public record EventConfig(Period dateAdjust, String image, int nextSessionTimeout, boolean showClosedRooms, boolean showLegend, + int updateFrequency) { } 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 c975707..eea6b2e 100644 --- a/src/main/java/swiss/fihlon/apus/ui/view/EventView.java +++ b/src/main/java/swiss/fihlon/apus/ui/view/EventView.java @@ -21,6 +21,7 @@ import com.vaadin.flow.component.dependency.CssImport; import com.vaadin.flow.component.html.Div; import com.vaadin.flow.component.html.H2; +import com.vaadin.flow.component.html.Image; import com.vaadin.flow.component.html.Span; import com.vaadin.flow.component.notification.Notification; import org.jetbrains.annotations.NotNull; @@ -69,6 +70,11 @@ public EventView(@NotNull final EventService eventService, final ScheduledFuture updateScheduler = taskScheduler.scheduleAtFixedRate( this::updateScheduler, Instant.now().plusSeconds(1), UPDATE_FREQUENCY); addDetachListener(event -> updateScheduler.cancel(true)); + + final var imageUrl = configuration.getEvent().image(); + if (imageUrl != null && !imageUrl.isBlank()) { + add(createImage(imageUrl)); + } } private void updateScheduler() { @@ -144,4 +150,11 @@ private RoomView createRoomView(@NotNull final Map.Entry> ro } return roomView; } + + @NotNull + private Component createImage(@NotNull final String imageUrl) { + final var image = new Image(imageUrl, "Event Image"); + image.setId("event-image"); + return image; + } } 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 4d7fa52..8fb55ae 100644 --- a/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -30,6 +30,11 @@ "type": "java.lang.String", "description": "Adjust the date of the event in days (empty = disabled)." }, + { + "name": "apus.event.image", + "type": "java.lang.String", + "description": "The URL of the image to be shown below the event agenda (empty = no image)." + }, { "name": "apus.event.nextSessionTimeout", "type": "java.lang.Integer", diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 310e2f0..f983e1c 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -16,6 +16,7 @@ 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.dateAdjust=${EVENT_DATE_ADJUST:0} +apus.event.image=${EVENT_IMAGE_URL:} apus.event.nextSessionTimeout=${EVENT_NEXT_SESSION_TIMEOUT:60} apus.event.showClosedRooms=${EVENT_SHOW_CLOSED_ROOMS:true} apus.event.showLegend=${EVENT_SHOW_LEGEND: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 64ff807..33f2656 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(null, 60, true, true, 0)); + when(configurationMock.getEvent()).thenReturn(new EventConfig(null, null, 60, true, true, 0)); } @Test diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index c4fc73d..971ef32 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -6,6 +6,7 @@ apus.demo.roomCount=-1 apus.doag.eventApi=file:src/test/resources/DOAG.json?eventId=%d apus.doag.eventId=-1 apus.event.dateAdjust= +apus.event.image= apus.event.nextSessionTimeout=60 apus.event.showClosedRooms=true apus.event.showLegend=true