@ -92,7 +92,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 {
|
||||
|
||||
@ -111,10 +112,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/";
|
||||
}
|
||||
@ -134,24 +136,32 @@ 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/";
|
||||
}
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_actuator)"})
|
||||
@PostMapping("/details/members/addUsersFromCsv")
|
||||
public String addUsersFromCsv(@RequestParam("group_id") Long groupId,
|
||||
public String addUsersFromCsv(KeycloakAuthenticationToken token,
|
||||
@RequestParam("group_id") Long groupId,
|
||||
@RequestParam(value = "file", required = false) MultipartFile file) throws IOException {
|
||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||
List<User> userList = new ArrayList<>();
|
||||
Group group = userService.getGroupById(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());
|
||||
}
|
||||
@ -325,6 +335,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,
|
||||
|
@ -21,7 +21,8 @@ import mops.gruppen2.domain.exception.GroupIdMismatchException;
|
||||
@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);
|
||||
}
|
||||
}
|
@ -5,13 +5,7 @@ import mops.gruppen2.domain.GroupType;
|
||||
import mops.gruppen2.domain.Role;
|
||||
import mops.gruppen2.domain.User;
|
||||
import mops.gruppen2.domain.Visibility;
|
||||
import mops.gruppen2.domain.event.AddUserEvent;
|
||||
import mops.gruppen2.domain.event.CreateGroupEvent;
|
||||
import mops.gruppen2.domain.event.DeleteGroupEvent;
|
||||
import mops.gruppen2.domain.event.DeleteUserEvent;
|
||||
import mops.gruppen2.domain.event.UpdateGroupDescriptionEvent;
|
||||
import mops.gruppen2.domain.event.UpdateGroupTitleEvent;
|
||||
import mops.gruppen2.domain.event.UpdateRoleEvent;
|
||||
import mops.gruppen2.domain.event.*;
|
||||
import mops.gruppen2.domain.exception.EventException;
|
||||
import mops.gruppen2.domain.exception.UserNotFoundException;
|
||||
import mops.gruppen2.security.Account;
|
||||
@ -49,7 +43,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();
|
||||
|
||||
@ -60,6 +54,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);
|
||||
|
||||
@ -69,7 +67,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();
|
||||
|
||||
@ -86,6 +84,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);
|
||||
|
||||
@ -128,6 +131,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, Long groupId) throws EventException {
|
||||
UpdateRoleEvent updateRoleEvent;
|
||||
Group group = userService.getGroupById(groupId);
|
||||
|
@ -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>
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
type="button">
|
||||
<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" 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()}"
|
||||
|
Reference in New Issue
Block a user