Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,7 @@ public String eventManagerPortal(
val currentRoomVisitorCount = roomVisitService.getVisitorCount(room);
val isRoomOvercrowded = room.getMaxCapacity() <= currentRoomVisitorCount;

// why is this here?
// val redirectURI = URLEncoder.encode("/r/" + roomId + "/event-manager-portal?visitorEmail=" + encodedVisitorEmail, "UTF-8");

val roomData = new Room.Data(room);
model.addAttribute("roomData", roomData);
model.addAttribute("roomData", new Room.Data(room));
model.addAttribute("currentRoomVisitorCount", currentRoomVisitorCount);
model.addAttribute("isRoomOvercrowded", isRoomOvercrowded);
model.addAttribute("visitorEmail", visitorEmail);
Expand Down Expand Up @@ -311,22 +307,17 @@ public String executeRoomReset(

return new RestResponse(true);
} catch (Exception e) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage());
return new RestResponse(false);
}
}

public static class RestResponse {
public String message;
public boolean success;

public RestResponse(boolean success) {
this.success = success;
}

public RestResponse(boolean success, String message) {
this(success);
this.message = message;
}
}

@RequestMapping("/roomFull/{roomId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.List;

import de.hs_mannheim.informatik.ct.model.Visit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

Expand All @@ -35,7 +36,7 @@ public class ContactTracingService {
private List<VisitService<?>> visitServices;

@NonNull
public List<Contact<?>> getVisitorContacts(@NonNull Visitor visitor) {
public List<Contact<? extends Visit>> getVisitorContacts(@NonNull Visitor visitor) {
val contacts = new ArrayList<Contact<?>>();
for (val service : visitServices) {
contacts.addAll(service.getVisitorContacts(visitor));
Expand Down
9 changes: 9 additions & 0 deletions src/main/resources/static/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -369,3 +369,12 @@ footer {
color: #22376F;
cursor: pointer;
}

#alert-message {
flex-direction: column;
align-items: stretch;
border: 1px solid #000;
padding: 10px 20px;
background: #D4EDDA;
border-radius: 2px;
}
25 changes: 20 additions & 5 deletions src/main/resources/static/veranstaltungsleitenden-portal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const csrfHeader = document.querySelector("head meta[name='_csrf_header']")?.content
const csrfToken = document.querySelector("head meta[name='_csrf']")?.content
const roomPin = document.querySelector("head meta[name='room-pin']")?.content
const alertMessage = document.querySelector("#alert-message")
const checkedInAmount = document.querySelector("#checked-in-amount strong")

const requestRoomReset = async () => {
const formData = new FormData();
Expand All @@ -16,17 +18,30 @@ const requestRoomReset = async () => {
return success
}

const resetCheckedInAmount = () => {
checkedInAmount.innerText = 0
}

const showMessage = (message) => {
alertMessage.style.display = "flex"
alertMessage.innerText = message
setTimeout(() => {
alertMessage.style.display = "none"
alertMessage.innerText = ""
}, 3000)
}

document.getElementById("reset-room").onclick = async () => {
try{
if(!csrfHeader) throw new Error('csrf header not found')
if(!csrfToken) throw new Error('csrf token not found')
if(!roomPin) throw new Error('roomPin not found')
if(confirm("Wollen Sie wirklich den Raum zurücksetzen?")){
if(await requestRoomReset()) {
location.reload();
}
if(confirm("Wollen Sie den Raum wirklich zurücksetzen?")){
if(!await requestRoomReset()) throw new Error('internal server error')
resetCheckedInAmount();
showMessage("Der Raum wurde erfolgreich zurückgesetzt");
}
}catch(err){
console.err(err)
alert("Beim Zurücksetzen des Raumes ist ein Fehler aufgetreten.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<body>
<div layout:fragment="content">

<div id="alert-message" style="display: none;"></div>

<h3 class="text-center">Portal für Veranstaltungsleitende</h3>

<h4 class="text-center">
Expand All @@ -32,7 +34,7 @@ <h5 class="text-center">Raumgröße</h5>

<div class="card flex-1">
<h5 class="text-center">eingecheckte Personen</h5>
<p id="checked-in-amount" class="text-center"><strong th:attr="style=${(@environment.getProperty('warning_for_full_room') && isRoomOvercrowded) ? 'color: red;' : ''}" th:text="${currentRoomVisitorCount+' '}"></strong>Personen</p>
<p id="checked-in-amount" class="text-center"><strong th:attr="style=${(@environment.getProperty('warning_for_full_room') && isRoomOvercrowded) ? 'color: red;' : ''}" th:text="${currentRoomVisitorCount}"></strong> Personen</p>
</div>

</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ public void asyncRoomReset() throws Exception {
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.param("roomPin", TEST_ROOM_PIN)
)
.andExpect(status().is(200));
.andExpect(status().is(200))
.andExpect(content().json("{\"success\": true}"));
}

@Test
Expand All @@ -283,7 +284,8 @@ public void asyncRoomResetWithInvalidPin() throws Exception {
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.param("roomPin", TEST_ROOM_PIN_INVALID)
)
.andExpect(status().is(400));
.andExpect(status().isOk())
.andExpect(content().json("{\"success\": false}"));
}

@Test
Expand Down