Skip to content

Commit

Permalink
🔊 show message when the conference agenda is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
McPringle committed Mar 31, 2024
1 parent d8609b3 commit d87ffe7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@ public final class ConferenceAPI {
public static final Logger LOGGER = LoggerFactory.getLogger(ConferenceAPI.class);
public static final String CONFERENCE_API_LOCATION = "https://meine.doag.org/api/event/action.getCPEventAgenda/eventId.%d/";

private final String location;
private final int eventId;

public ConferenceAPI(@NotNull final Configuration configuration) {
this.location = String.format(CONFERENCE_API_LOCATION, configuration.getDoag().eventId());
this.eventId = configuration.getDoag().eventId();
}

public List<Session> getSessions() {
if (eventId == 0) {
return List.of();
}

final ArrayList<Session> sessions = new ArrayList<>();
int lastSlotId = 0;
try {
Expand Down Expand Up @@ -148,6 +152,7 @@ private Duration parseDuration(@NotNull final String duration) {
}

private String getJSON() throws IOException, URISyntaxException {
final var location = String.format(CONFERENCE_API_LOCATION, eventId);
try (InputStream in = new URI(location).toURL().openStream()) {
return new String(in.readAllBytes(), StandardCharsets.UTF_8);
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/swiss/fihlon/apus/ui/view/ConferenceView.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ private void updateConferenceSessions() {
final var today = LocalDate.now();
final var roomCounter = new AtomicInteger(0);
final var roomsWithSessions = conferenceService.getRoomsWithSessions().entrySet();
if (roomsWithSessions.isEmpty()) {
Notification.show(getTranslation("conference.error.nosessions"));
}
for (final Map.Entry<Room, List<Session>> roomWithSession : roomsWithSessions) {
if (roomCounter.get() >= MAX_ROOMS_IN_VIEW) {
Notification.show(String.format(getTranslation("conference.error.rooms"), roomsWithSessions.size()));
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/vaadin-i18n/translations.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ conference.session.countdown.singular=%d minute left
conference.session.countdown.plural=%d minutes left
conference.session.closed=closed
conference.error.rooms=Too many rooms (%d) to display, no more space left on screen!
conference.error.nosessions=The agenda for today is empty!
social.heading=Posts with #%s on Mastodon
1 change: 1 addition & 0 deletions src/main/resources/vaadin-i18n/translations_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ conference.session.countdown.singular=noch %d Minute
conference.session.countdown.plural=noch %d Minuten
conference.session.closed=geschlossen
conference.error.rooms=Zu viele Räume (%d), kein Platz mehr auf dem Bildschirm!
conference.error.nosessions=Die Agenda für heute ist leer!
social.heading=Schreibe einen Beitrag mit #%s auf Mastodon

0 comments on commit d87ffe7

Please sign in to comment.