Merge branch 'master' into invite-link-group-id-change
# Conflicts: # src/main/java/mops/gruppen2/controller/Gruppen2Controller.java # src/main/java/mops/gruppen2/service/ControllerService.java
This commit is contained in:
@ -28,7 +28,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.context.annotation.SessionScope;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import java.io.CharConversionException;
|
||||
import java.io.IOException;
|
||||
@ -92,11 +91,15 @@ public class Gruppen2Controller {
|
||||
@RequestParam(value = "visibility", required = false) Boolean visibility,
|
||||
@RequestParam(value = "lecture", required = false) Boolean lecture,
|
||||
@RequestParam("userMaximum") Long userMaximum,
|
||||
@RequestParam(value = "maxInfiniteUsers", required = false) Boolean maxInfiniteUsers,
|
||||
@RequestParam(value = "parent", required = false) String parent,
|
||||
@RequestParam(value = "file", required = false) MultipartFile file) throws IOException, EventException {
|
||||
|
||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||
List<User> userList = new ArrayList<>();
|
||||
if(userMaximum == null){
|
||||
userMaximum = 100000L;
|
||||
}
|
||||
if (!file.isEmpty()) {
|
||||
try {
|
||||
userList = CsvService.read(file.getInputStream());
|
||||
@ -110,10 +113,11 @@ public class Gruppen2Controller {
|
||||
}
|
||||
visibility = visibility == null;
|
||||
lecture = lecture != null;
|
||||
maxInfiniteUsers = maxInfiniteUsers != null;
|
||||
|
||||
UUID parentUUID = controllerService.getUUID(parent);
|
||||
|
||||
controllerService.createOrga(account, title, description, visibility, lecture, userMaximum, parentUUID, userList);
|
||||
controllerService.createOrga(account, title, description, visibility, lecture, maxInfiniteUsers, userMaximum, parentUUID, userList);
|
||||
|
||||
return "redirect:/gruppen2/";
|
||||
}
|
||||
@ -134,26 +138,32 @@ public class Gruppen2Controller {
|
||||
@RequestParam("description") String description,
|
||||
@RequestParam(value = "visibility", required = false) Boolean visibility,
|
||||
@RequestParam("userMaximum") Long userMaximum,
|
||||
@RequestParam(value = "maxInfiniteUsers", required = false) Boolean maxInfiniteUsers,
|
||||
@RequestParam(value = "parent", required = false) String parent) throws EventException {
|
||||
|
||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||
visibility = visibility == null;
|
||||
|
||||
maxInfiniteUsers = maxInfiniteUsers != null;
|
||||
UUID parentUUID = controllerService.getUUID(parent);
|
||||
|
||||
controllerService.createGroup(account, title, description, visibility, userMaximum, parentUUID);
|
||||
controllerService.createGroup(account, title, description, visibility, maxInfiniteUsers, userMaximum, parentUUID);
|
||||
|
||||
return "redirect:/gruppen2/";
|
||||
}
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_actuator)"})
|
||||
@PostMapping("/details/members/addUsersFromCsv")
|
||||
public String addUsersFromCsv(@RequestParam("group_id") String groupId,
|
||||
public String addUsersFromCsv(KeycloakAuthenticationToken token,
|
||||
@RequestParam("group_id") String groupId,
|
||||
@RequestParam(value = "file", required = false) MultipartFile file) throws IOException {
|
||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||
List<User> userList = new ArrayList<>();
|
||||
Group group = userService.getGroupById(UUID.fromString(groupId));
|
||||
if (!file.isEmpty()) {
|
||||
try {
|
||||
userList = CsvService.read(file.getInputStream());
|
||||
if(userList.size()+group.getMembers().size()>group.getUserMaximum()){
|
||||
controllerService.updateMaxUser(account, groupId, Long.valueOf(userList.size()) + group.getMembers().size());
|
||||
}
|
||||
} catch (UnrecognizedPropertyException | CharConversionException ex) {
|
||||
throw new WrongFileException(file.getOriginalFilename());
|
||||
}
|
||||
@ -348,6 +358,16 @@ public class Gruppen2Controller {
|
||||
return "redirect:/gruppen2/details/members/" + groupId;
|
||||
}
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||
@PostMapping("/details/members/changeMaximum")
|
||||
public String changeMaxSize(@RequestParam("maximum") Long maximum,
|
||||
@RequestParam("group_id") Long groupId,
|
||||
KeycloakAuthenticationToken token){
|
||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||
controllerService.updateMaxUser(account, groupId, maximum);
|
||||
return "redirect:/gruppen2/details/members/" + groupId;
|
||||
}
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||
@PostMapping("/details/members/deleteUser")
|
||||
public String deleteUser(@RequestParam("group_id") String groupId,
|
||||
|
@ -23,7 +23,8 @@ import java.util.UUID;
|
||||
@JsonSubTypes.Type(value = UpdateGroupDescriptionEvent.class, name = "UpdateGroupDescriptionEvent"),
|
||||
@JsonSubTypes.Type(value = UpdateGroupTitleEvent.class, name = "UpdateGroupTitleEvent"),
|
||||
@JsonSubTypes.Type(value = UpdateRoleEvent.class, name = "UpdateRoleEvent"),
|
||||
@JsonSubTypes.Type(value = DeleteGroupEvent.class, name = "DeleteGroupEvent")
|
||||
@JsonSubTypes.Type(value = DeleteGroupEvent.class, name = "DeleteGroupEvent"),
|
||||
@JsonSubTypes.Type(value = UpdateUserMaxEvent.class, name = "UpdateUserMaxEvent")
|
||||
})
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
|
@ -0,0 +1,25 @@
|
||||
package mops.gruppen2.domain.event;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.domain.exception.EventException;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UpdateUserMaxEvent extends Event {
|
||||
|
||||
private Long userMaximum;
|
||||
|
||||
public UpdateUserMaxEvent(Long group_id, String user_id, Long userMaximum) {
|
||||
super(group_id,user_id);
|
||||
this.userMaximum = userMaximum;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyEvent(Group group) throws EventException {
|
||||
group.setUserMaximum(this.userMaximum);
|
||||
}
|
||||
}
|
@ -47,7 +47,7 @@ public class ControllerService {
|
||||
* @param title Gruppentitel
|
||||
* @param description Gruppenbeschreibung
|
||||
*/
|
||||
public void createGroup(Account account, String title, String description, Boolean visibility, Long userMaximum, UUID parent) throws EventException {
|
||||
public void createGroup(Account account, String title, String description, Boolean maxInfiniteUsers, Boolean visibility, Long userMaximum, UUID parent) throws EventException {
|
||||
Visibility visibility1;
|
||||
UUID groupId = eventService.checkGroup();
|
||||
|
||||
@ -57,6 +57,10 @@ public class ControllerService {
|
||||
visibility1 = Visibility.PRIVATE;
|
||||
}
|
||||
|
||||
if(maxInfiniteUsers){
|
||||
userMaximum = 100000L;
|
||||
}
|
||||
|
||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(groupId, account.getName(), parent, GroupType.SIMPLE, visibility1, userMaximum);
|
||||
eventService.saveEvent(createGroupEvent);
|
||||
|
||||
@ -66,7 +70,7 @@ public class ControllerService {
|
||||
updateRole(account.getName(), groupId);
|
||||
}
|
||||
|
||||
public void createOrga(Account account, String title, String description, Boolean visibility, Boolean lecture, Long userMaximum, UUID parent, List<User> users) throws EventException {
|
||||
public void createOrga(Account account, String title, String description, Boolean visibility, Boolean lecture, Boolean maxInfiniteUsers, Long userMaximum, UUID parent, List<User> users) throws EventException {
|
||||
Visibility visibility1;
|
||||
UUID groupId = eventService.checkGroup();
|
||||
|
||||
@ -83,6 +87,11 @@ public class ControllerService {
|
||||
groupType = GroupType.SIMPLE;
|
||||
}
|
||||
|
||||
|
||||
if(maxInfiniteUsers){
|
||||
userMaximum = 100000L;
|
||||
}
|
||||
|
||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(groupId, account.getName(), parent, groupType, visibility1, userMaximum);
|
||||
eventService.saveEvent(createGroupEvent);
|
||||
|
||||
@ -121,6 +130,11 @@ public class ControllerService {
|
||||
eventService.saveEvent(updateGroupDescriptionEvent);
|
||||
}
|
||||
|
||||
public void updateMaxUser(Account account, Long groupId, Long userMaximum) {
|
||||
UpdateUserMaxEvent updateUserMaxEvent = new UpdateUserMaxEvent(groupId,account.getName(),userMaximum);
|
||||
eventService.saveEvent(updateUserMaxEvent);
|
||||
}
|
||||
|
||||
public void updateRole(String userId, UUID groupId) throws EventException {
|
||||
UpdateRoleEvent updateRoleEvent;
|
||||
Group group = userService.getGroupById(groupId);
|
||||
|
@ -1,6 +1,8 @@
|
||||
package mops.gruppen2.service;
|
||||
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.domain.GroupType;
|
||||
import mops.gruppen2.domain.Visibility;
|
||||
import mops.gruppen2.domain.dto.EventDTO;
|
||||
import mops.gruppen2.domain.event.Event;
|
||||
import mops.gruppen2.domain.exception.EventException;
|
||||
@ -85,6 +87,7 @@ public class GroupService {
|
||||
return visibleGroups.parallelStream()
|
||||
.filter(group -> group.getType() != null)
|
||||
.filter(group -> !userGroupIds.contains(group.getId()))
|
||||
.filter(group -> group.getVisibility() == Visibility.PUBLIC)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
}
|
||||
@ -96,7 +99,8 @@ public class GroupService {
|
||||
List<Group> visibleGroups = projectEventList(createEvents);
|
||||
|
||||
return visibleGroups.parallelStream()
|
||||
.filter(group -> group.getType() != null)
|
||||
.filter(group -> group.getType() == GroupType.LECTURE)
|
||||
.filter(group -> group.getVisibility() == Visibility.PUBLIC)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
@ -51,9 +51,14 @@
|
||||
<textarea class="form-control" id="description" required
|
||||
rows="3" th:name="description"></textarea>
|
||||
</div>
|
||||
<div class="form-group mt-3">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input class="custom-control-input" id="maxInfiniteUsers" th:name="maxInfiniteUsers"
|
||||
type="checkbox">
|
||||
<label class="custom-control-label" for="maxInfiniteUsers">Anzahl unbegrenzt</label>
|
||||
</div>
|
||||
<div class="form-group mt-3" id="userMaximum">
|
||||
<label for="userMaximum">Teilnehmeranzahl</label>
|
||||
<input class="form-control" id="userMaximum" required th:name="userMaximum"
|
||||
<input class="form-control" th:name="userMaximum"
|
||||
type="number" min="1" max="10000">
|
||||
</div>
|
||||
<div class="custom-control custom-checkbox">
|
||||
@ -111,6 +116,12 @@
|
||||
$('#lectureParent').fadeToggle();
|
||||
});
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#maxInfiniteUsers').change(function () {
|
||||
$('#userMaximum').fadeToggle();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</main>
|
||||
</body>
|
||||
|
@ -6,7 +6,11 @@
|
||||
<meta charset="utf-8">
|
||||
<title>Gruppenerstellung</title>
|
||||
<th:block th:fragment="headcontent">
|
||||
<!-- Links, Skripts, Styles hier einfügen! -->
|
||||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
|
||||
rel="stylesheet">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
|
||||
</th:block>
|
||||
</head>
|
||||
<body>
|
||||
@ -46,10 +50,15 @@
|
||||
<textarea class="form-control" id="description" required
|
||||
rows="3" th:name="description"></textarea>
|
||||
</div>
|
||||
<div class="form-group mt-3">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input class="custom-control-input" id="maxInfiniteUsers" th:name="maxInfiniteUsers"
|
||||
type="checkbox">
|
||||
<label class="custom-control-label" for="maxInfiniteUsers">Anzahl unbegrenzt</label>
|
||||
</div>
|
||||
<div class="form-group mt-3" id="userMaximum">
|
||||
<label for="userMaximum">Teilnehmeranzahl</label>
|
||||
<input class="form-control" id="userMaximum" required th:name="userMaximum"
|
||||
type="number" min="1">
|
||||
<input class="form-control" th:name="userMaximum"
|
||||
type="number" min="1" max="10000">
|
||||
</div>
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input class="custom-control-input" id="visibility" th:name="visibility"
|
||||
@ -76,6 +85,13 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#maxInfiniteUsers').change(function () {
|
||||
$('#userMaximum').fadeToggle();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -30,8 +30,8 @@
|
||||
</header>
|
||||
<main th:fragment="bodycontent">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-9 shadow-sm p-4" style="border: 10px solid aliceblue; border-radius: 5px; background: aliceblue">
|
||||
<div>
|
||||
<div class="shadow-sm p-4 col-8" style="border: 10px solid aliceblue; display: inline-block; border-radius: 5px; background: aliceblue">
|
||||
<h1 style="color: black; font-weight: bold; font-optical-sizing: auto; overflow-wrap: break-word" th:text="${group.getTitle()}"></h1>
|
||||
<h3>
|
||||
<span class="badge badge-pill badge-dark" style="background: darkslategray"
|
||||
@ -67,27 +67,27 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3" style="white-space: nowrap">
|
||||
<div style="display: inline-block; margin: 0">
|
||||
<h2>Mitglieder</h2>
|
||||
<div>
|
||||
<h4>
|
||||
<a th:text="${group.getMembers().size()}"></a>
|
||||
<a>von maximal</a>
|
||||
<a th:text="${group.getUserMaximum()}"></a>
|
||||
<a>Benutzern.</a>
|
||||
</h4>
|
||||
</div>
|
||||
<div th:if="${group.getRoles().get(user.getId()) == admin}">
|
||||
<form method="get"
|
||||
th:action="@{/gruppen2/details/members/{id}(id=${group.getId()})}">
|
||||
<button class="btn btn-secondary" style="background: slategrey; float: left">Mitglieder bearbeiten</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-4" style="white-space: nowrap; float: right; background: white; display: inline-block; margin-bottom: 100px; margin-top: -8px">
|
||||
<h2>Mitglieder</h2>
|
||||
<div th:switch="${group.getUserMaximum() != 100000}">
|
||||
<h4 th:case="${true}">
|
||||
<a th:text="${group.getMembers().size()}"></a>
|
||||
<a>von maximal</a>
|
||||
<a th:text="${group.getUserMaximum()}"></a>
|
||||
<a>Benutzern.</a>
|
||||
</h4>
|
||||
<h4 th:case="${false}"> unbegrenzte Teilnehmeranzahl</h4>
|
||||
</div>
|
||||
<div th:if="${group.getRoles().get(user.getId()) == admin}">
|
||||
<form method="get"
|
||||
th:action="@{/gruppen2/details/members/{id}(id=${group.getId()})}">
|
||||
<button class="btn btn-secondary" style="background: slategrey; float: left">Mitglieder bearbeiten</button>
|
||||
</form>
|
||||
<br>
|
||||
<br>
|
||||
</div>
|
||||
<div>
|
||||
<div style="overflow-y: scroll;
|
||||
height:60vh">
|
||||
<ul class="list-group-flush" style="background: slategrey"
|
||||
th:each="member : ${group.getMembers()}">
|
||||
<li class="list-group-item" style="background: aliceblue">
|
||||
|
@ -36,7 +36,7 @@
|
||||
<h3>
|
||||
<span class="badge badge-pill badge-dark" style="background: darkslategray"
|
||||
th:if='${group.getVisibility() == group.getVisibility().PRIVATE }'>Private Gruppe</span>
|
||||
<span class="badge badge-pill badge-primary"
|
||||
<span class="badge badge-pill badge-primary" style="background: #52a1eb"
|
||||
th:if="${group.getVisibility() == group.getVisibility().PUBLIC}">Öffentliche Gruppe</span>
|
||||
<span class="badge badge-pill badge-success"
|
||||
style="background: lightseagreen"
|
||||
@ -65,13 +65,14 @@
|
||||
<div class="col-3" style="white-space: nowrap">
|
||||
<div style="display: inline-block; margin: 0">
|
||||
<h2>Mitglieder</h2>
|
||||
<div>
|
||||
<h4>
|
||||
<div th:switch="${group.getUserMaximum() != 100000}">
|
||||
<h4 th:case="${true}">
|
||||
<a th:text="${group.getMembers().size()}"></a>
|
||||
<a>von maximal</a>
|
||||
<a th:text="${group.getUserMaximum()}"></a>
|
||||
<a>Benutzern.</a>
|
||||
</h4>
|
||||
<h4 th:case="false">unbegrenzte Teilnehmeranzahl</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -37,37 +37,51 @@
|
||||
<div class="row">
|
||||
<div class="col-10">
|
||||
<h1>Mitglieder bearbeiten</h1>
|
||||
<div>
|
||||
<h5>
|
||||
<div th:switch="${group.getUserMaximum() != 100000}">
|
||||
<h5 th:case="${true}">
|
||||
<a th:text="${group.getMembers().size()}"></a>
|
||||
<a>von maximal</a>
|
||||
<a th:text="${group.getUserMaximum()}"></a>
|
||||
<a>Benutzern.</a>
|
||||
</h5>
|
||||
<h5 th:case="${false}"> unbegrenzte Teilnehmeranzahl</h5>
|
||||
</div>
|
||||
<div class="shadow p-2" style="border: 10px solid aliceblue; background: aliceblue">
|
||||
<div class="form-group pt-4" th:if="${account.getRoles().contains('orga')}">
|
||||
<form action="/gruppen2/details/members/addUsersFromCsv"
|
||||
enctype="multipart/form-data"
|
||||
method="post">
|
||||
<div class="row">
|
||||
<div class="col-10">
|
||||
<div class="custom-file">
|
||||
<input class="custom-file-input" id="file" th:name="file" type="file">
|
||||
<label class="custom-file-label" for="file">CSV Datei von Mitgliedern hochladen</label>
|
||||
</div>
|
||||
<div class="input-group mb-3">
|
||||
<div class="custom-file">
|
||||
<input class="custom-file-input" id="file" th:name="file" type="file">
|
||||
<label class="custom-file-label" for="file">CSV Datei von Mitgliedern hochladen</label>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<button class="btn btn-primary"
|
||||
style="background: #52a1eb; border-style: none; float: right"
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-outline-secondary" style="background: #52a1eb; border-style: none"
|
||||
th:name="group_id" th:value="${group.getId()}"
|
||||
type="submit">
|
||||
Mitglieder hinzufügen
|
||||
<a style="color: white">Hinzufügen</a>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="form-group pt-4">
|
||||
<form action="/gruppen2/details/members/changeMaximum" method="post">
|
||||
<div class="input-group mb-3" id="userMaximum">
|
||||
<input class="form-control" placeholder="Maximale Teilnehmerzahl ändern..." th:name="maximum"
|
||||
type="number" th:min="${group.getMembers().size()}" max="10000">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-outline-secondary" style="background: #52a1eb; border-style: none"
|
||||
th:name="group_id" th:value="${group.getId()}"
|
||||
type="submit">
|
||||
<a style="color: white">Speichern</a>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<table class="table" style="table-layout: fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -92,7 +106,7 @@
|
||||
type="hidden">
|
||||
<button class="btn btn-warning btn-sm" type="submit" style="margin: 5px">Rolle
|
||||
ändern
|
||||
</button><!-- th:if -->
|
||||
</button>
|
||||
</form>
|
||||
<form action="/gruppen2/details/members/deleteUser" method="post">
|
||||
<input th:name="group_id" th:value="${group.getId()}"
|
||||
|
@ -10,7 +10,7 @@
|
||||
<title>Seite nicht gefunden</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="mx-auto" style="vertical-align: border-radius: 5px; center; horiz-align: center; top: 50%; left: 50%;">
|
||||
<div class="mx-auto" style="vertical-align: center; border-radius: 5px; horiz-align: center; top: 50%; left: 50%;">
|
||||
<div class="jumbotron" style="background: aliceblue">
|
||||
<div class="container">
|
||||
<h1 class="display-3">UPSI</h1>
|
||||
@ -26,8 +26,10 @@
|
||||
<p th:text="${message}"></p>
|
||||
</div>
|
||||
</div>
|
||||
<p><a class="btn btn-primary btn-lg" href="#" onclick="window.history.back(-1);return false;" role="button">Zurück</a>
|
||||
</p>
|
||||
|
||||
<button style="color: #52a1eb">
|
||||
<a style="color: white" class="btn btn-primary btn-lg" href="#" onclick="window.history.back(-1);return false;" role="button">Zurück</a>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
Reference in New Issue
Block a user