1

Merge remote-tracking branch 'origin/master' into entadminisierung

# Conflicts:
#	src/main/java/mops/gruppen2/controller/Gruppen2Controller.java
#	src/main/java/mops/gruppen2/domain/User.java
#	src/main/resources/templates/editMembers.html
This commit is contained in:
Lukas Ettel
2020-03-19 16:14:57 +01:00
10 changed files with 38 additions and 28 deletions

View File

@ -164,6 +164,7 @@ public class Gruppen2Controller {
@PostMapping("/detailsBeitreten") @PostMapping("/detailsBeitreten")
public String joinGroup(KeycloakAuthenticationToken token, Model model, @RequestParam("id") Long groupId) throws EventException { public String joinGroup(KeycloakAuthenticationToken token, Model model, @RequestParam("id") Long groupId) throws EventException {
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token)); model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
Account account = keyCloakService.createAccountFromPrincipal(token); Account account = keyCloakService.createAccountFromPrincipal(token);
User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail()); User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
Group group = userService.getGroupById(groupId); Group group = userService.getGroupById(groupId);

View File

@ -11,8 +11,8 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(exclude = {"givenname", "familyname", "email"}) @EqualsAndHashCode(exclude = {"givenname", "familyname", "email"})
public class User { public class User {
private String id; private String id;
private String givenname; private String givenname;
private String familyname; private String familyname;
private String email; private String email;
} }

View File

@ -1,6 +1,7 @@
package mops.gruppen2.service; package mops.gruppen2.service;
import mops.gruppen2.domain.Group; import mops.gruppen2.domain.Group;
import mops.gruppen2.domain.User;
import mops.gruppen2.domain.dto.EventDTO; import mops.gruppen2.domain.dto.EventDTO;
import mops.gruppen2.domain.event.Event; import mops.gruppen2.domain.event.Event;
import mops.gruppen2.domain.exception.EventException; import mops.gruppen2.domain.exception.EventException;
@ -66,11 +67,11 @@ public class GroupService {
return groups.get(groupId); return groups.get(groupId);
} }
private List<Long> removeUserGroups(List<Long> groupIds, List<Long> userGroups) { private List<Group> removeUserGroups(List<Group> visibleGroups, List<Group> userGroups) {
for (Long groupId : userGroups) { for (Group group : userGroups) {
groupIds.remove(groupId); visibleGroups.remove(group);
} }
return groupIds; return visibleGroups;
} }
/** /**
@ -81,10 +82,18 @@ public class GroupService {
* @throws EventException Projektionsfehler * @throws EventException Projektionsfehler
*/ */
public List<Group> getAllGroupWithVisibilityPublic(String userId) throws EventException { public List<Group> getAllGroupWithVisibilityPublic(String userId) throws EventException {
List<Long> groupIds = removeUserGroups(eventRepository.findGroup_idsWhereVisibility(Boolean.TRUE), eventRepository.findGroup_idsWhereUser_id(userId)); User user = new User(userId,null, null, null);
List<EventDTO> eventDTOS = eventRepository.findAllEventsOfGroups(groupIds); List<Event> eventsVisible = eventService.translateEventDTOs(eventRepository.findAllEventsOfGroups(eventRepository.findGroup_idsWhereVisibility(Boolean.TRUE)));
List<Event> events = eventService.translateEventDTOs(eventDTOS); List<Group> visibleGroups = projectEventList(eventsVisible);
return projectEventList(events); List<Event> eventsUser = getGroupEvents(eventRepository.findGroup_idsWhereUser_id(userId));
List<Group> groups = projectEventList(eventsUser);
List<Group> newGroups = new ArrayList<>();
for (Group group : groups) {
if (group.getMembers().contains(user)) {
newGroups.add(group);
}
}
return removeUserGroups(visibleGroups, newGroups);
} }

View File

@ -34,8 +34,8 @@
<div class="col-10"> <div class="col-10">
<h1>Gruppenerstellung</h1> <h1>Gruppenerstellung</h1>
<form method="post" action="/gruppen2/createGroup"> <form method="post" action="/gruppen2/createGroup">
<div class="shadow p-2" <div class="shadow p-2" style=" border: 10px solid aliceblue; border-radius: 5px; background: aliceblue">
style=" border: 10px solid aliceblue; background: aliceblue">
<div class="form-group"> <div class="form-group">
<label for="titel">Titel</label> <label for="titel">Titel</label>
<input class="form-control" id="titel" required th:name="title" <input class="form-control" id="titel" required th:name="title"

View File

@ -31,8 +31,7 @@
<main th:fragment="bodycontent"> <main th:fragment="bodycontent">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-9 shadow-sm p-4" <div class="col-9 shadow-sm p-4" style="border: 10px solid aliceblue; border-radius: 5px; background: aliceblue">
style="border: 10px solid aliceblue; background: aliceblue">
<h1 style="color: black; font-weight: bold" th:text="${group.getTitle()}"></h1> <h1 style="color: black; font-weight: bold" th:text="${group.getTitle()}"></h1>
<h3> <h3>
<span class="badge badge-pill badge-dark" style="background: darkslategray" <span class="badge badge-pill badge-dark" style="background: darkslategray"

View File

@ -31,8 +31,7 @@
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-9"> <div class="col-9">
<div class="shadow-sm p-4" <div class="shadow-sm p-4" style="border: 10px solid aliceblue; border-radius: 5px; background: aliceblue">
style="border: 10px solid aliceblue; background: aliceblue">
<h1 style="color: black; font-weight: bold" th:text="${group.getTitle()}"></h1> <h1 style="color: black; font-weight: bold" th:text="${group.getTitle()}"></h1>
<h3> <h3>
<span class="badge badge-pill badge-dark" style="background: darkslategray" <span class="badge badge-pill badge-dark" style="background: darkslategray"

View File

@ -36,7 +36,7 @@
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-9"> <div class="col-9">
<div class="shadow p-2" style="border: 10px solid aliceblue; background: aliceblue"> <div class="shadow p-2" style="border: 10px solid aliceblue; border-radius: 5px; background: aliceblue">
<!-- absichern im controller nicht vergessen --> <!-- absichern im controller nicht vergessen -->
<div class="form-group pt-4" th:if="${account.getRoles().contains('orga')}"> <div class="form-group pt-4" th:if="${account.getRoles().contains('orga')}">
<form action="/gruppen2/details/members/addUsersFromCsv" <form action="/gruppen2/details/members/addUsersFromCsv"
@ -67,11 +67,10 @@
<tr> <tr>
<th scope="col">Mitglied</th> <th scope="col">Mitglied</th>
<th scope="col" style="width: 180px">Rolle</th> <th scope="col" style="width: 180px">Rolle</th>
<th scope="col" style="width: 270px">Optionen</th> <th scope="col" >Optionen</th>
</tr> </tr>
</thead> </thead>
<tbody class="table-striped"> <tbody class="table-striped">
<tr th:each="member : ${group.getMembers()}"> <tr th:each="member : ${group.getMembers()}">
<th th:text="${member.getId()}"></th> <th th:text="${member.getId()}"></th>
<td> <td>
@ -84,15 +83,16 @@
type="hidden"> type="hidden">
<input th:name="user_id" th:value="${member.getId()}" <input th:name="user_id" th:value="${member.getId()}"
type="hidden"> type="hidden">
<button class="btn btn-warning btn-sm" type="submit">Rolle ändern</button> <button class="btn btn-warning btn-sm" type="submit">Rolle
<!-- th:if --> ändern
</button><!-- th:if -->
</form> </form>
<form action="/gruppen2/details/members/deleteUser" method="post"> <form action="/gruppen2/details/members/deleteUser" method="post">
<input th:name="group_id" th:value="${group.getId()}" <input th:name="group_id" th:value="${group.getId()}"
type="hidden"> type="hidden">
<input th:name="user_id" th:value="${member.getId()}" <input th:name="user_id" th:value="${member.getId()}"
type="hidden"> type="hidden">
<button class="btn btn-danger btn-sm">Mitglied entfernen <button th:if='${member.getId() != account.getName()}' class="btn btn-danger btn-sm">Mitglied entfernen
</button> </button>
</form> </form>
</td> </td>
@ -103,6 +103,8 @@
type="button"> type="button">
<a th:href="@{/gruppen2/details(id=${group.getId()})}" style="color: white">Fertig</a> <a th:href="@{/gruppen2/details(id=${group.getId()})}" style="color: white">Fertig</a>
</button> </button>
<br>
<br>
</div> </div>
</div> </div>
</div> </div>

View File

@ -10,7 +10,7 @@
<title>Seite nicht gefunden</title> <title>Seite nicht gefunden</title>
</head> </head>
<body> <body>
<div class="mx-auto" style="vertical-align: center; horiz-align: center; top: 50%; left: 50%;"> <div class="mx-auto" style="vertical-align: border-radius: 5px; center; horiz-align: center; top: 50%; left: 50%;">
<div class="jumbotron" style="background: aliceblue"> <div class="jumbotron" style="background: aliceblue">
<div class="container"> <div class="container">
<h1 class="display-3">UPSI</h1> <h1 class="display-3">UPSI</h1>
@ -31,4 +31,4 @@
</div> </div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -45,7 +45,7 @@
</h3> </h3>
<br> <br>
<div th:each="gruppe: ${gruppen}"> <div th:each="gruppe: ${gruppen}">
<div class="shadow-sm p-4" style="border: none; background: aliceblue"> <div class="shadow-sm p-4" style="border: none; border-radius: 5px; background: aliceblue">
<h3 style="color: dodgerblue; font-weight: bold;"> <h3 style="color: dodgerblue; font-weight: bold;">
<a th:href="@{/gruppen2/details/{id}(id=${gruppe.getId()})}" <a th:href="@{/gruppen2/details/{id}(id=${gruppe.getId()})}"
th:text="${gruppe.getTitle()}"></a> th:text="${gruppe.getTitle()}"></a>

View File

@ -33,7 +33,7 @@
<div class="col-10"> <div class="col-10">
<h1>Gruppensuche</h1> <h1>Gruppensuche</h1>
<form action="/gruppen2/findGroup" method="get"> <form action="/gruppen2/findGroup" method="get">
<div class="shadow" style="border: 10px solid aliceblue; background: aliceblue"> <div class="shadow" style="border: 10px solid aliceblue; border-radius: 5px; background: aliceblue">
<div class="form-group"> <div class="form-group">
<label for="suchleiste">Suchbegriff:</label> <label for="suchleiste">Suchbegriff:</label>
<input class="form-control" id="suchleiste" <input class="form-control" id="suchleiste"