1

add change_maximum size

Co-Authored-By: xxnitram <xxnitram@users.noreply.github.com>
This commit is contained in:
tomvahl
2020-03-23 14:57:33 +01:00
parent 4d77e2905f
commit 7bae5e1184
6 changed files with 87 additions and 17 deletions

View File

@ -88,7 +88,8 @@ public class Gruppen2Controller {
@RequestParam("description") String description,
@RequestParam(value = "visibility", required = false) Boolean visibility,
@RequestParam(value = "lecture", required = false) Boolean lecture,
@RequestParam("userMaximum") Long userMaximum,
@RequestParam(value = "userMaximum", required = false) Long userMaximum,
@RequestParam(value = "maxInfiniteUsers", required = false) Boolean maxInfiniteUsers,
@RequestParam(value = "parent", required = false) Long parent,
@RequestParam(value = "file", required = false) MultipartFile file) throws IOException, EventException {
@ -106,10 +107,11 @@ public class Gruppen2Controller {
}
visibility = visibility == null;
lecture = lecture != null;
maxInfiniteUsers = maxInfiniteUsers != null;
if (lecture) parent = null;
controllerService.createOrga(account, title, description, visibility, lecture, userMaximum, parent, userList);
controllerService.createOrga(account, title, description, visibility, lecture, maxInfiniteUsers, userMaximum, parent, userList);
return "redirect:/gruppen2/";
}
@ -129,12 +131,14 @@ public class Gruppen2Controller {
@RequestParam("title") String title,
@RequestParam("description") String description,
@RequestParam(value = "visibility", required = false) Boolean visibility,
@RequestParam("userMaximum") Long userMaximum,
@RequestParam(value = "userMaximum", required = false) Long userMaximum,
@RequestParam(value = "maxInfiniteUsers", required = false) Boolean maxInfiniteUsers,
@RequestParam(value = "parent", required = false) Long parent) throws EventException {
Account account = keyCloakService.createAccountFromPrincipal(token);
visibility = visibility == null;
controllerService.createGroup(account, title, description, visibility, userMaximum, parent);
maxInfiniteUsers = maxInfiniteUsers != null;
controllerService.createGroup(account, title, description, visibility, maxInfiniteUsers, userMaximum, parent);
return "redirect:/gruppen2/";
}
@ -309,6 +313,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") Long groupId,

View File

@ -40,7 +40,7 @@ public class ControllerService {
* @param title Gruppentitel
* @param description Gruppenbeschreibung
*/
public void createGroup(Account account, String title, String description, Boolean visibility, Long userMaximum, Long parent) throws EventException {
public void createGroup(Account account, String title, String description, Boolean visibility, Boolean maxInfiniteUsers, Long userMaximum, Long parent) throws EventException {
Visibility visibility1;
Long groupId = eventService.checkGroup();
@ -51,6 +51,10 @@ public class ControllerService {
createInviteLink(groupId);
}
if(maxInfiniteUsers){
userMaximum = 100000L;
}
CreateGroupEvent createGroupEvent = new CreateGroupEvent(groupId, account.getName(), parent, GroupType.SIMPLE, visibility1, userMaximum);
eventService.saveEvent(createGroupEvent);
@ -60,7 +64,7 @@ public class ControllerService {
updateRole(account.getName(), groupId);
}
public void createOrga(Account account, String title, String description, Boolean visibility, Boolean lecture, Long userMaximum, Long parent, List<User> users) throws EventException {
public void createOrga(Account account, String title, String description, Boolean visibility, Boolean lecture, Boolean maxInfiniteUsers, Long userMaximum, Long parent, List<User> users) throws EventException {
Visibility visibility1;
Long groupId = eventService.checkGroup();
@ -77,6 +81,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);

View File

@ -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>

View File

@ -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>

View File

@ -70,13 +70,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 th:if="${group.getRoles().get(user.getId()) == admin}">
<form method="get"

View File

@ -37,13 +37,14 @@
<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')}">
@ -68,6 +69,24 @@
</div>
</form>
</div>
<div class="form-group pt-4">
<form action="/gruppen2/details/members/changeMaximum" method="post">
<div class="row">
<div class="col-10">
<label for="maximum">maximale Teilnehmer ändern</label>
<input class="form-control" id="maximum" required th:name="maximum"
type="number" th:min="${group.getMembers().size()}" max="10000">
</div>
<div class="col-2">
<button class="btn btn-primary"
style="background: #52a1eb; border-style: none"
th:name="group_id" th:value="${group.getId()}"
type="submit">Erstellen
</button>
</div>
</div>
</form>
</div>
<table class="table" style="table-layout: fixed">
<thead>
<tr>
@ -92,7 +111,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()}"