1

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

# Conflicts:
#	src/main/resources/templates/editMembers.html
This commit is contained in:
killerber4t
2020-03-19 15:55:59 +01:00
10 changed files with 38 additions and 26 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);
@ -228,12 +229,15 @@ public class Gruppen2Controller {
@PostMapping("/details/members/changeRole") @PostMapping("/details/members/changeRole")
public String changeRole(KeycloakAuthenticationToken token, @RequestParam("group_id") Long groupId, public String changeRole(KeycloakAuthenticationToken token, @RequestParam("group_id") Long groupId,
@RequestParam("user_id") String userId) throws EventException { @RequestParam("user_id") String userId) throws EventException {
Account account = keyCloakService.createAccountFromPrincipal(token);
controllerService.updateRole(userId, groupId); controllerService.updateRole(userId, groupId);
if(userId.equals(account.getName())) return "redirect:/gruppen2/details/" + groupId;
return "redirect:/gruppen2/details/members/" + groupId; return "redirect:/gruppen2/details/members/" + groupId;
} }
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"}) @RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
@PostMapping("/details/members/deleteUser") @PostMapping("/details/members/deleteUser")
public String deleteUser(KeycloakAuthenticationToken token, @RequestParam("group_id") Long groupId, public String deleteUser(KeycloakAuthenticationToken token, @RequestParam("group_id") Long groupId,
@RequestParam("user_id") String userId) throws EventException { @RequestParam("user_id") String userId) throws EventException {
controllerService.deleteUser(userId, groupId); controllerService.deleteUser(userId, groupId);

View File

@ -3,14 +3,16 @@ package mops.gruppen2.domain;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(exclude = {"givenname", "familyname", "email"}) @EqualsAndHashCode(exclude = {"givenname", "familyname", "email"})
public class User { public class User {
private final String id; private String id;
private final String givenname; private String givenname;
private final String familyname; private String familyname;
private final 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

@ -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>
@ -93,7 +92,7 @@
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>

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>

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"