1

Merge branch 'master' into killertester

# Conflicts:
#	src/test/java/mops/gruppen2/service/EventServiceTest.java
This commit is contained in:
tomvahl
2020-03-24 13:08:58 +01:00
18 changed files with 294 additions and 136 deletions

2
.gitignore vendored
View File

@ -32,3 +32,5 @@ out/
.vscode/
.floo
.flooignore
/mysql/*

View File

@ -5,6 +5,7 @@ import mops.gruppen2.config.Gruppen2Config;
import mops.gruppen2.domain.Group;
import mops.gruppen2.domain.Role;
import mops.gruppen2.domain.User;
import mops.gruppen2.domain.Visibility;
import mops.gruppen2.domain.exception.EventException;
import mops.gruppen2.domain.exception.GroupNotFoundException;
import mops.gruppen2.domain.exception.WrongFileException;
@ -32,6 +33,7 @@ import java.io.CharConversionException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
@Controller
@SessionScope
@ -44,6 +46,7 @@ public class Gruppen2Controller {
private final ControllerService controllerService;
private final InviteLinkRepositoryService inviteLinkRepositoryService;
private final Gruppen2Config gruppen2Config;
private final Logger logger;
public Gruppen2Controller(KeyCloakService keyCloakService, GroupService groupService, UserService userService, ControllerService controllerService, InviteLinkRepositoryService inviteLinkRepositoryService, Gruppen2Config gruppen2Config) {
this.keyCloakService = keyCloakService;
@ -51,6 +54,7 @@ public class Gruppen2Controller {
this.userService = userService;
this.controllerService = controllerService;
this.inviteLinkRepositoryService = inviteLinkRepositoryService;
logger = Logger.getLogger("Gruppen2ControllerLogger");
this.gruppen2Config = gruppen2Config;
}
@ -88,12 +92,16 @@ 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 {
Account account = keyCloakService.createAccountFromPrincipal(token);
List<User> userList = new ArrayList<>();
if(userMaximum == null){
userMaximum = 100000L;
}
if (!file.isEmpty()) {
try {
userList = CsvService.read(file.getInputStream());
@ -101,15 +109,17 @@ public class Gruppen2Controller {
userMaximum = Long.valueOf(userList.size()) + userMaximum;
}
} catch (UnrecognizedPropertyException | CharConversionException ex) {
logger.warning("File konnte nicht gelesen werden");
throw new WrongFileException(file.getOriginalFilename());
}
}
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,24 +139,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());
}
@ -180,6 +198,18 @@ public class Gruppen2Controller {
if(group.getTitle() == null){
throw new GroupNotFoundException(this.getClass().toString());
}
if (!group.getMembers().contains(user)){
if (group.getVisibility() == Visibility.PRIVATE){
return "privateGroupNoMember";
}
if (group != null) {
model.addAttribute("group", group);
model.addAttribute("parentId", parentId);
model.addAttribute("parent", parent);
return "detailsNoMember";
}
return "detailsNoMember";
}
if (parentId != null) {
parent = userService.getGroupById(parentId);
}
@ -274,14 +304,19 @@ public class Gruppen2Controller {
public String editMembers(Model model, KeycloakAuthenticationToken token, @PathVariable("id") Long groupId) throws EventException {
Account account = keyCloakService.createAccountFromPrincipal(token);
Group group = userService.getGroupById(groupId);
if (group.getRoles().get(account.getName()) == Role.ADMIN) {
model.addAttribute("account", account);
model.addAttribute("members", group.getMembers());
model.addAttribute("group", group);
model.addAttribute("admin", Role.ADMIN);
return "editMembers";
} else {
return "redirect:/details/";
User user = new User(account.getName(),"", "", "");
if (group.getMembers().contains(user)) {
if (group.getRoles().get(account.getName()) == Role.ADMIN) {
model.addAttribute("account", account);
model.addAttribute("members", group.getMembers());
model.addAttribute("group", group);
model.addAttribute("admin", Role.ADMIN);
return "editMembers";
} else {
return "redirect:/details/";
}
}else {
return "privateGroupNoMember";
}
}
@ -303,6 +338,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

@ -14,6 +14,6 @@ public class EventDTO {
Long event_id;
Long group_id;
String user_id;
String event_type;
String event_payload;
boolean visibility;
}

View File

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

View File

@ -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);
}
}

View File

@ -20,9 +20,6 @@ public interface EventRepository extends CrudRepository<EventDTO, Long> {
//@Query("SELECT * FROM event WHERE event_id > ?#{[0]}")
//Iterable<EventDTO> findNewEventSinceStatus(@Param("status") Long status);
@Query("select distinct group_id from event where visibility =:vis")
List<Long> findGroup_idsWhereVisibility(@Param("vis") Boolean visibility);
@Query("SELECT DISTINCT group_id FROM event WHERE event_id > :status")
List<Long> findNewEventSinceStatus(@Param("status") Long status);
@ -34,4 +31,7 @@ public interface EventRepository extends CrudRepository<EventDTO, Long> {
@Query("SELECT MAX(group_id) FROM event")
Long getMaxGroupID();
@Query("SELECT * FROM event WHERE event_type = :type")
List<EventDTO> findAllEventsByType(@Param("type") String type);
}

View File

@ -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;
@ -20,6 +14,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.logging.Logger;
import static mops.gruppen2.domain.Role.ADMIN;
@ -30,11 +25,13 @@ public class ControllerService {
private final EventService eventService;
private final UserService userService;
private final InviteLinkRepositoryService inviteLinkRepositoryService;
private final Logger logger;
public ControllerService(EventService eventService, UserService userService, InviteLinkRepositoryService inviteLinkRepositoryService) {
this.eventService = eventService;
this.userService = userService;
this.inviteLinkRepositoryService = inviteLinkRepositoryService;
this.logger = Logger.getLogger("controllerServiceLogger");
}
/**
@ -46,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();
@ -57,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);
@ -66,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();
@ -83,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);
@ -105,8 +111,13 @@ public class ControllerService {
public void addUserList(List<User> users, Long groupId) {
for (User user : users) {
AddUserEvent addUserEvent = new AddUserEvent(groupId, user.getId(), user.getGivenname(), user.getFamilyname(), user.getEmail());
eventService.saveEvent(addUserEvent);
Group group = userService.getGroupById(groupId);
if (group.getMembers().contains(user)) {
logger.info("Benutzer " + user.getId() + " ist bereits in Gruppe");
} else {
AddUserEvent addUserEvent = new AddUserEvent(groupId, user.getId(), user.getGivenname(), user.getFamilyname(), user.getEmail());
eventService.saveEvent(addUserEvent);
}
}
}
@ -120,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);

View File

@ -1,9 +1,7 @@
package mops.gruppen2.service;
import com.fasterxml.jackson.core.JsonProcessingException;
import mops.gruppen2.domain.Visibility;
import mops.gruppen2.domain.dto.EventDTO;
import mops.gruppen2.domain.event.CreateGroupEvent;
import mops.gruppen2.domain.event.Event;
import mops.gruppen2.repository.EventRepository;
import org.springframework.stereotype.Service;
@ -40,11 +38,6 @@ public class EventService {
* @return EventDTO Neues DTO
*/
public EventDTO getDTO(Event event) {
boolean visibility = false;
if (event instanceof CreateGroupEvent) {
visibility = ((CreateGroupEvent) event).getGroupVisibility() == Visibility.PUBLIC;
}
String payload = "";
try {
payload = jsonService.serializeEvent(event);
@ -52,7 +45,13 @@ public class EventService {
e.printStackTrace();
}
return new EventDTO(null, event.getGroupId(), event.getUserId(), payload, visibility);
return new EventDTO(null, event.getGroupId(), event.getUserId(), getEventType(event), payload);
}
private String getEventType(Event event) {
int lastDot = event.getClass().getName().lastIndexOf('.');
return event.getClass().getName().substring(lastDot + 1);
}
/**

View File

@ -2,7 +2,7 @@ package mops.gruppen2.service;
import mops.gruppen2.domain.Group;
import mops.gruppen2.domain.GroupType;
import mops.gruppen2.domain.User;
import mops.gruppen2.domain.Visibility;
import mops.gruppen2.domain.dto.EventDTO;
import mops.gruppen2.domain.event.Event;
import mops.gruppen2.domain.exception.EventException;
@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class GroupService {
@ -52,10 +53,8 @@ public class GroupService {
public List<Group> projectEventList(List<Event> events) throws EventException {
Map<Long, Group> groupMap = new HashMap<>();
for (Event event : events) {
Group group = getOrCreateGroup(groupMap, event.getGroupId());
event.apply(group);
}
events.parallelStream()
.forEachOrdered(event -> event.apply(getOrCreateGroup(groupMap, event.getGroupId())));
return new ArrayList<>(groupMap.values());
}
@ -68,13 +67,6 @@ public class GroupService {
return groups.get(groupId);
}
private List<Group> removeUserGroups(List<Group> visibleGroups, List<Group> userGroups) {
for (Group group : userGroups) {
visibleGroups.remove(group);
}
return visibleGroups;
}
/**
* Sucht alle Zeilen in der DB mit visibility=true.
* Erstellt eine Liste aus öffentlichen Gruppen (ohen bereits beigetretenen Gruppen).
@ -83,33 +75,32 @@ public class GroupService {
* @throws EventException Projektionsfehler
*/
public List<Group> getAllGroupWithVisibilityPublic(String userId) throws EventException {
User user = new User(userId,null, null, null);
List<Event> eventsVisible = eventService.translateEventDTOs(eventRepository.findAllEventsOfGroups(eventRepository.findGroup_idsWhereVisibility(Boolean.TRUE)));
List<Group> visibleGroups = projectEventList(eventsVisible);
List<Event> eventsUser = getGroupEvents(eventRepository.findGroup_idsWhereUser_id(userId));
List<Group> groups = projectEventList(eventsUser);
List<Group> newGroups = new ArrayList<>();
for (Group group : visibleGroups) {
if (group.getMembers().contains(user)) {
newGroups.add(group);
}
}
return removeUserGroups(visibleGroups, newGroups);
List<Event> createEvents = eventService.translateEventDTOs(eventRepository.findAllEventsByType("CreateGroupEvent"));
createEvents.addAll(eventService.translateEventDTOs(eventRepository.findAllEventsByType("UpdateGroupDescriptionEvent")));
createEvents.addAll(eventService.translateEventDTOs(eventRepository.findAllEventsByType("UpdateGroupTitleEvent")));
createEvents.addAll(eventService.translateEventDTOs(eventRepository.findAllEventsByType("DeleteGroupEvent")));
List<Group> visibleGroups = projectEventList(createEvents);
List<Long> userGroupIds = eventRepository.findGroup_idsWhereUser_id(userId);
return visibleGroups.parallelStream()
.filter(group -> group.getType() != null)
.filter(group -> !userGroupIds.contains(group.getId()))
.filter(group -> group.getVisibility() == Visibility.PUBLIC)
.collect(Collectors.toList());
}
public List<Group> getAllLecturesWithVisibilityPublic() throws EventException {
List<Event> eventsVisible = eventService.translateEventDTOs(eventRepository.findAllEventsOfGroups(eventRepository.findGroup_idsWhereVisibility(Boolean.TRUE)));
List<Group> visibleGroups = projectEventList(eventsVisible);
List<Group> visibleLectures = new ArrayList<>();
for (Group group : visibleGroups) {
if(group.getType() == null){
continue;
}
if (group.getType().equals(GroupType.LECTURE)) {
visibleLectures.add(group);
}
}
return visibleLectures;
List<Event> createEvents = eventService.translateEventDTOs(eventRepository.findAllEventsByType("CreateGroupEvent"));
createEvents.addAll(eventService.translateEventDTOs(eventRepository.findAllEventsByType("UpdateGroupTitleEvent")));
List<Group> visibleGroups = projectEventList(createEvents);
return visibleGroups.parallelStream()
.filter(group -> group.getType() == GroupType.LECTURE)
.filter(group -> group.getVisibility() == Visibility.PUBLIC)
.collect(Collectors.toList());
}
@ -122,16 +113,12 @@ public class GroupService {
* @throws EventException Projektionsfehler
*/
public List<Group> findGroupWith(String search, Account account) throws EventException {
List<Group> groups = new ArrayList<>();
for (Group group : getAllGroupWithVisibilityPublic(account.getName())) {
if(group.getType() == null){
continue;
}
if (group.getTitle().toLowerCase().contains(search.toLowerCase()) || group.getDescription().toLowerCase().contains(search.toLowerCase())) {
groups.add(group);
}
}
return groups;
return getAllGroupWithVisibilityPublic(account.getName())
.parallelStream()
.filter(group ->
group.getTitle().toLowerCase().contains(search.toLowerCase()) ||
group.getDescription().toLowerCase().contains(search.toLowerCase()))
.collect(Collectors.toList());
}
}

View File

@ -1,6 +1,6 @@
insert into event values
(1,1,'orga','{"type":"CreateGroupEvent","groupId":1,"userId":"orga","groupVisibility":"PUBLIC","groupParent":null,"groupType":"SIMPLE","groupUserMaximum":2}', TRUE),
(2,1,'orga','{"type":"AddUserEvent","groupId":1,"userId":"orga","givenname":"orga","familyname":"orga","email":"blorga@orga.org"}', FALSE),
(3,1,'orga','{"type":"UpdateGroupTitleEvent","groupId":1,"userId":"orga","newGroupTitle":"sdsad"}', FALSE),
(4,1,'orga','{"type":"UpdateGroupDescriptionEvent","groupId":1,"userId":"orga","newGroupDescription":"sadsad"}', FALSE),
(5,1,'orga','{"type":"UpdateRoleEvent","groupId":1,"userId":"orga","newRole":"ADMIN"}', FALSE);
(1,1,'orga','CreateGroupEvent','{"type":"CreateGroupEvent","groupId":1,"userId":"orga","groupVisibility":"PUBLIC","groupParent":null,"groupType":"SIMPLE","groupUserMaximum":2}'),
(2,1,'orga','AddUserEvent','{"type":"AddUserEvent","groupId":1,"userId":"orga","givenname":"orga","familyname":"orga","email":"blorga@orga.org"}'),
(3,1,'orga','UpdateGroupTitleEvent','{"type":"UpdateGroupTitleEvent","groupId":1,"userId":"orga","newGroupTitle":"sdsad"}'),
(4,1,'orga','UpdateGroupDescriptionEvent','{"type":"UpdateGroupDescriptionEvent","groupId":1,"userId":"orga","newGroupDescription":"sadsad"}'),
(5,1,'orga','UpdateRoleEvent','{"type":"UpdateRoleEvent","groupId":1,"userId":"orga","newRole":"ADMIN"}');

View File

@ -9,8 +9,8 @@ CREATE TABLE event
event_id INT PRIMARY KEY AUTO_INCREMENT,
group_id INT NOT NULL,
user_id VARCHAR(50),
event_payload VARCHAR(2500),
visibility BOOLEAN
event_type VARCHAR(50),
event_payload VARCHAR(2500)
);
DROP TABLE IF EXISTS invite;

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

@ -30,13 +30,13 @@
</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"
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"
th:if='${group.getType() == group.getType().LECTURE}'>Veranstaltung</span>
@ -50,7 +50,7 @@
<br>
<div class="text-right btn-toolbar" role="toolbar" style="float: right">
<button class="btn btn-primary"
style="background: dodgerblue; border: none; margin: 5px">
style="background: #52a1eb; border: none; margin: 5px">
<a style="color: white" th:href="@{/gruppen2}">Zurück</a>
</button>
<form action="/gruppen2/leaveGroup" method="post">
@ -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">

View File

@ -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"
@ -52,7 +52,7 @@
<div class="text-right">
<form method="post" action="/gruppen2/detailsBeitreten">
<button class="btn btn-primary"
style="border-style: none;"
style="background: #52a1eb; border-style: none;"
th:href="@{/gruppen2/detailsBeitreten(id=${group.getId()})}"
th:name="id" th:value="${group.id}"
type="submit">Gruppe beitreten
@ -62,6 +62,20 @@
</div>
</div>
</div>
<div class="col-3" style="white-space: nowrap">
<div style="display: inline-block; margin: 0">
<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>
</div>
</div>
</div>
</main>

View File

@ -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()}"

View File

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

View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
<link crossorigin="anonymous" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" rel="stylesheet">
<meta charset="UTF-8">
<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="jumbotron" style="background: aliceblue">
<div class="container">
<h1 class="display-3">Kein Zugriff auf die Gruppe</h1>
<p class="lead">Sorry, du hast keine Berechtigung auf diese Funktionen der Gruppe zuzugreifen</p><br>
</div>
</div>
<div class="container">
<p><a class="btn btn-primary btn-lg" href="#" onclick="window.history.back(-1);return false;" role="button">Zurück</a>
</p>
</div>
</div>
</body>
</html>