Merge remote-tracking branch 'origin/master' into EventServiceTests
# Conflicts: # src/test/java/mops/gruppen2/service/EventServiceTest.java
This commit is contained in:
@ -2,22 +2,24 @@ package mops.gruppen2.controller;
|
||||
|
||||
import mops.gruppen2.config.Gruppen2Config;
|
||||
import mops.gruppen2.domain.Exceptions.EventException;
|
||||
import mops.gruppen2.domain.Group;
|
||||
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.UpdateGroupDescriptionEvent;
|
||||
import mops.gruppen2.domain.event.UpdateGroupTitleEvent;
|
||||
import mops.gruppen2.security.Account;
|
||||
import mops.gruppen2.service.*;
|
||||
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/gruppen2")
|
||||
@ -55,6 +57,7 @@ public class Gruppen2Controller {
|
||||
|
||||
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
|
||||
model.addAttribute("gruppen", userService.getUserGroups(user.getUser_id()));
|
||||
model.addAttribute("user",user);
|
||||
return "index";
|
||||
}
|
||||
|
||||
@ -67,20 +70,46 @@ public class Gruppen2Controller {
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||
@GetMapping("/findGroup")
|
||||
public String findGroup(KeycloakAuthenticationToken token, Model model) {
|
||||
public String findGroup(KeycloakAuthenticationToken token, Model model, @RequestParam(value = "suchbegriff", required = false) String suchbegriff) throws EventException {
|
||||
List<Group> groupse = new ArrayList<>();
|
||||
if(suchbegriff!=null) {
|
||||
groupse = groupService.findGroupWith(suchbegriff);
|
||||
}
|
||||
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
|
||||
model.addAttribute("gruppen",groupse);
|
||||
return "search";
|
||||
}
|
||||
|
||||
@PostMapping("/createGroup")
|
||||
public String pCreateGroup(KeycloakAuthenticationToken token,
|
||||
@RequestParam(value = "title") String title,
|
||||
@RequestParam(value = "beschreibung") String beschreibung) {
|
||||
@RequestParam(value = "beschreibung") String beschreibung,
|
||||
@RequestParam(value = "visibility", required = false) Boolean visibility) {
|
||||
|
||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||
controllerService.createGroup(account, title, beschreibung);
|
||||
if (visibility == null) {
|
||||
visibility = true;
|
||||
}else{
|
||||
visibility = false;
|
||||
}
|
||||
controllerService.createGroup(account, title, beschreibung, visibility);
|
||||
|
||||
return "redirect:/gruppen2/";
|
||||
}
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||
@GetMapping("/details")
|
||||
public String showGroupDetails(KeycloakAuthenticationToken token, Model model, @RequestParam (value="id") Long id) throws EventException, ResponseStatusException {
|
||||
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
|
||||
Group group = userService.getGroupById(id);
|
||||
Account account = keyCloakService.createAccountFromPrincipal (token);
|
||||
User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
|
||||
if(group!= null) {
|
||||
model.addAttribute("group", group);
|
||||
model.addAttribute("role", group.getRoles().get(user.getUser_id()));
|
||||
return "detailsMember";
|
||||
}
|
||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Group not found");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3,6 +3,8 @@ package mops.gruppen2.controller;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@Controller
|
||||
public class MopsController {
|
||||
|
||||
@ -10,4 +12,10 @@ public class MopsController {
|
||||
public String redirect(){
|
||||
return "redirect:/gruppen2/";
|
||||
}
|
||||
|
||||
@GetMapping("/logout")
|
||||
public String logout(HttpServletRequest request) throws Exception {
|
||||
request.logout();
|
||||
return "redirect:/gruppen2/";
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,4 +12,5 @@ public class EventDTO {
|
||||
Long group_id;
|
||||
String user_id;
|
||||
String event_payload;
|
||||
boolean visibility;
|
||||
}
|
||||
|
||||
@ -13,4 +13,4 @@ import java.util.List;
|
||||
public class UpdatedGroupRequestMapper {
|
||||
private Long status;
|
||||
private List<Group> groupList;
|
||||
}
|
||||
}
|
||||
@ -30,6 +30,7 @@ public class Event {
|
||||
Long group_id;
|
||||
String user_id;
|
||||
|
||||
|
||||
public Event(Long group_id,String user_id){
|
||||
this.group_id = group_id;
|
||||
this.user_id = user_id;
|
||||
|
||||
@ -17,9 +17,10 @@ public class UpdateRoleEvent extends Event {
|
||||
super(event_id, group_id, user_id);
|
||||
this.newRole = newRole;
|
||||
}
|
||||
|
||||
|
||||
public UpdateRoleEvent(Long group_id, String user_id, Role newRole) {
|
||||
super(group_id, user_id);
|
||||
this.newRole = newRole;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -16,6 +16,12 @@ public interface EventRepository extends CrudRepository<EventDTO, Long> {
|
||||
@Query("select * from event where group_id =:id")
|
||||
List<EventDTO> findEventDTOByGroup_id(@Param("id") Long group_id);
|
||||
|
||||
//@Query("SELECT * FROM event WHERE event_id > ?#{[0]}")
|
||||
//Iterable<EventDTO> findNewEventSinceStatus(@Param("status") Long status);
|
||||
|
||||
@Query("select * from event where visibility =:vis")
|
||||
List<EventDTO> findEventDTOByVisibility(@Param("vis") Boolean visibility);
|
||||
|
||||
@Query("SELECT DISTINCT group_id FROM event WHERE event_id > :status")
|
||||
public List<Long> findNewEventSinceStatus(@Param("status") Long status);
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package mops.gruppen2.service;
|
||||
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.domain.GroupType;
|
||||
import mops.gruppen2.domain.Role;
|
||||
import mops.gruppen2.domain.Visibility;
|
||||
@ -26,15 +27,26 @@ public class ControllerService {
|
||||
* @param title Gruppentitel
|
||||
* @param description Gruppenbeschreibung
|
||||
*/
|
||||
public void createGroup(Account account, String title, String description) {
|
||||
|
||||
public void createGroup(Account account, String title, String description, Boolean visibility) {
|
||||
Visibility visibility1;
|
||||
if (visibility){
|
||||
visibility1 = Visibility.PUBLIC;
|
||||
}else{
|
||||
visibility1 = Visibility.PRIVATE;
|
||||
}
|
||||
List<Event> eventList = new ArrayList<>();
|
||||
Collections.addAll(eventList, new CreateGroupEvent(eventService.checkGroup(), account.getName(), null , GroupType.LECTURE, Visibility.PUBLIC),
|
||||
Collections.addAll(eventList, new CreateGroupEvent(eventService.checkGroup(), account.getName(), null , GroupType.LECTURE, visibility1),
|
||||
new AddUserEvent(eventService.checkGroup(), account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()),
|
||||
new UpdateRoleEvent(eventService.checkGroup(), account.getName(), Role.ADMIN),
|
||||
new UpdateGroupTitleEvent(eventService.checkGroup(), account.getName(), title),
|
||||
new UpdateGroupDescriptionEvent(eventService.checkGroup(), account.getName(), description));
|
||||
new UpdateGroupDescriptionEvent(eventService.checkGroup(), account.getName(), description),
|
||||
new UpdateRoleEvent(eventService.checkGroup(),account.getName(), Role.ADMIN));
|
||||
|
||||
eventService.saveEventList(eventList);
|
||||
}
|
||||
|
||||
public void addUser(Account account, Group group){
|
||||
AddUserEvent addUserEvent = new AddUserEvent(eventService.checkGroup(),group.getId(),account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail());
|
||||
eventService.saveEvent(addUserEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,9 +2,12 @@ package mops.gruppen2.service;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import mops.gruppen2.domain.EventDTO;
|
||||
import mops.gruppen2.domain.Exceptions.EventException;
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.domain.Visibility;
|
||||
import mops.gruppen2.domain.event.CreateGroupEvent;
|
||||
import mops.gruppen2.domain.event.Event;
|
||||
import mops.gruppen2.repository.EventRepository;
|
||||
import org.bouncycastle.jcajce.provider.asymmetric.ec.KeyFactorySpi;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -29,15 +32,25 @@ public class EventService {
|
||||
eventStore.save(eventDTO);
|
||||
}
|
||||
|
||||
/** Erzeugt aus einem Event Objekt ein EventDTO Objekt
|
||||
/** Erzeugt aus einem Event Objekt ein EventDTO Objekt.
|
||||
* Ist die Gruppe öffentlich, dann wird die visibility auf true gesetzt.
|
||||
*
|
||||
* @param event
|
||||
* @return EventDTO
|
||||
*/
|
||||
public EventDTO getDTO(Event event){
|
||||
public EventDTO getDTO(Event event) {
|
||||
EventDTO eventDTO = new EventDTO();
|
||||
eventDTO.setGroup_id(event.getGroup_id());
|
||||
eventDTO.setUser_id(event.getUser_id());
|
||||
if(event instanceof CreateGroupEvent) {
|
||||
if(((CreateGroupEvent) event).getGroupVisibility() == Visibility.PRIVATE) {
|
||||
eventDTO.setVisibility(false);
|
||||
}else {
|
||||
eventDTO.setVisibility(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
eventDTO.setEvent_payload(serializationService.serializeEvent(event));
|
||||
} catch (JsonProcessingException e) {
|
||||
@ -76,7 +89,7 @@ public class EventService {
|
||||
return translateEventDTOs(groupEventDTOS);
|
||||
}
|
||||
|
||||
/** Erzeugt aus der Datenbank eine Liste von Events
|
||||
/** Erzeugt aus einer Liste von eventDTOs eine Liste von Events
|
||||
*
|
||||
* @param eventDTOS
|
||||
* @return Liste von Events
|
||||
@ -87,7 +100,6 @@ public class EventService {
|
||||
for (EventDTO eventDTO : eventDTOS) {
|
||||
try {
|
||||
events.add(serializationService.deserializeEvent(eventDTO.getEvent_payload()));
|
||||
|
||||
}catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@ -23,6 +23,12 @@ public class GroupService {
|
||||
this.eventRepository = eventRepository;
|
||||
}
|
||||
|
||||
/** Sucht in der DB alle Zeilen raus welche eine der Gruppen_ids hat.
|
||||
* Wandelt die Zeilen in Events um und gibt davon eine Liste zurück.
|
||||
*
|
||||
* @param group_ids
|
||||
* @return
|
||||
*/
|
||||
public List<Event> getGroupEvents(List<Long> group_ids) {
|
||||
List<EventDTO> eventDTOS = new ArrayList<>();
|
||||
List<Event> events = new ArrayList<>();
|
||||
@ -32,8 +38,13 @@ public class GroupService {
|
||||
return events = eventService.translateEventDTOs(eventDTOS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Erzeugt eine neue Map wo Gruppen aus den Events erzeugt und den Gruppen_ids zugeordnet werden.
|
||||
* Die Gruppen werden als Liste zurückgegeben
|
||||
*
|
||||
* @param events
|
||||
* @return
|
||||
* @throws EventException
|
||||
*/
|
||||
public List<Group> projectEventList(List<Event> events) throws EventException {
|
||||
Map<Long, Group> groupMap = new HashMap<>();
|
||||
|
||||
@ -44,7 +55,13 @@ public class GroupService {
|
||||
return new ArrayList<>(groupMap.values());
|
||||
}
|
||||
|
||||
//
|
||||
/** guckt in der Map anhand der Id nach ob die Gruppe schon in der Map vorhanden ist, wenn nicht wird eine neue
|
||||
* Gruppe erzeugt
|
||||
*
|
||||
* @param groups
|
||||
* @param group_id
|
||||
* @return
|
||||
*/
|
||||
private Group getOrCreateGroup(Map<Long, Group> groups, long group_id) {
|
||||
if (!groups.containsKey(group_id)) {
|
||||
groups.put(group_id, new Group());
|
||||
@ -52,4 +69,33 @@ public class GroupService {
|
||||
|
||||
return groups.get(group_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* sucht alle Zeilen in der DB wo die Visibility gleich true ist und wandelt diese in
|
||||
* eine Liste von Gruppen
|
||||
* @return
|
||||
* @throws EventException
|
||||
*/
|
||||
public List<Group> getAllGroupWithVisibilityPublic() throws EventException {
|
||||
return projectEventList(eventService.translateEventDTOs(eventRepository.findEventDTOByVisibility(Boolean.TRUE)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filtert alle öffentliche Gruppen nach dem suchbegriff und gibt diese als Liste von Gruppen zurück.
|
||||
* Groß und kleinschreibung wird beachtet.
|
||||
* @param search
|
||||
* @return
|
||||
* @throws EventException
|
||||
*/
|
||||
public List<Group> findGroupWith(String search) throws EventException {
|
||||
List<Group> groups = new ArrayList<>();
|
||||
for (Group group: getAllGroupWithVisibilityPublic()) {
|
||||
if (group.getTitle().contains(search)){
|
||||
groups.add(group);
|
||||
}
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@ public class SerializationService {
|
||||
* @return JSON-Event-Payload als String
|
||||
* @throws JsonProcessingException
|
||||
*/
|
||||
|
||||
public String serializeEvent(Event event) throws JsonProcessingException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
return mapper.writeValueAsString(event);
|
||||
|
||||
@ -6,6 +6,7 @@ import mops.gruppen2.domain.event.Event;
|
||||
import mops.gruppen2.repository.EventRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@ -26,4 +27,11 @@ public class UserService {
|
||||
List<Event> events = groupService.getGroupEvents(group_ids);
|
||||
return groupService.projectEventList(events);
|
||||
}
|
||||
|
||||
public Group getGroupById(Long group_id) throws EventException {
|
||||
List<Long> group_ids = new ArrayList<>();
|
||||
group_ids.add(group_id);
|
||||
List<Event> events = groupService.getGroupEvents(group_ids);
|
||||
return groupService.projectEventList(events).get(0);
|
||||
}
|
||||
}
|
||||
|
||||
14
src/main/resources/application-docker.properties
Normal file
14
src/main/resources/application-docker.properties
Normal file
@ -0,0 +1,14 @@
|
||||
application.name=gruppen2
|
||||
|
||||
logging.pattern.console=[${application.name}],%magenta(%-5level), %d{dd-MM-yyyy HH:mm:ss.SSS}, %highlight(%msg),%thread,%logger.%M%n
|
||||
|
||||
spring.datasource.initialization-mode=always
|
||||
spring.datasource.url=jdbc:mysql://dbmysql:3306/gruppen2
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=geheim
|
||||
|
||||
keycloak.principal-attribute=preferred_username
|
||||
keycloak.auth-server-url=https://keycloak.cs.hhu.de/auth
|
||||
keycloak.realm=MOPS
|
||||
keycloak.resource=demo
|
||||
keycloak.public-client=true
|
||||
@ -7,5 +7,6 @@ CREATE TABLE event
|
||||
event_id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
group_id INT NOT NULL,
|
||||
user_id VARCHAR(50),
|
||||
event_payload VARCHAR(255)
|
||||
event_payload VARCHAR(255),
|
||||
visibility BOOLEAN
|
||||
);
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org"
|
||||
th:replace="~{mopslayout :: html(name='Gruppenbildung', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}">
|
||||
th:replace="~{mopslayout :: html(name='Gruppenbildung', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}"
|
||||
xmlns="http://www.w3.org/1999/html">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Name des Subsystems</title>
|
||||
<title>Gruppenerstellung</title>
|
||||
<th:block th:fragment="headcontent">
|
||||
<!-- Links, Skripts, Styles hier einfügen! -->
|
||||
</th:block>
|
||||
@ -28,16 +29,30 @@
|
||||
<h1>Gruppenerstellung</h1>
|
||||
<div class="container-fluid">
|
||||
<form method="post" action="/gruppen2/createGroup">
|
||||
<div style="border: 10px solid aliceblue; background: aliceblue">
|
||||
<div class="shadow p-2" style=" border: 10px solid aliceblue; background: aliceblue">
|
||||
<div class="form-group">
|
||||
<label for="titel">Name der Gruppe</label>
|
||||
<input type="text" class="form-control" id="titel" th:name="title">
|
||||
<label for="titel">Titel</label>
|
||||
<input type="text" class="form-control" id="titel" th:name="title" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="beschreibung">Beschreibung der Gruppe</label>
|
||||
<textarea th:name="beschreibung" class="form-control" id="beschreibung" rows="3"></textarea>
|
||||
<label for="beschreibung">Beschreibung</label>
|
||||
<textarea th:name="beschreibung" class="form-control" id="beschreibung" rows="3" required></textarea>
|
||||
</div>
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" id="visibility" class="custom-control-input" th:name="visibility">
|
||||
<label class="custom-control-label" for="visibility">Private Gruppe</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="sel1"></label>
|
||||
<select class="form-control" id="sel1">
|
||||
<option selected="true" disabled>--Bitte Veranstaltung auswählen--</option>
|
||||
<option>1</option>
|
||||
<option>2</option>
|
||||
<option>3</option>
|
||||
<option>4</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group pt-4">
|
||||
<button class="btn btn-primary" type="submit" style="background: #52a1eb; border-style: none">Erstellen</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
66
src/main/resources/templates/detailsMember.html
Normal file
66
src/main/resources/templates/detailsMember.html
Normal file
@ -0,0 +1,66 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org"
|
||||
th:replace="~{mopslayout :: html(name='Gruppenbildung', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Gruppendetails</title>
|
||||
<th:block th:fragment="headcontent">
|
||||
<!-- Links, Skripts, Styles hier einfügen! -->
|
||||
</th:block>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navigation navigation-secondary" is="mops-navigation" th:fragment="navigation">
|
||||
<ul>
|
||||
<li class="active">
|
||||
<a th:href="@{/gruppen2}" href="/">Gruppen</a>
|
||||
</li>
|
||||
<li>
|
||||
<a th:href="@{/gruppen2/createGroup}" href="/createGroup">Erstellen</a>
|
||||
</li>
|
||||
<li>
|
||||
<a th:href="@{/gruppen2/findGroup}" href="/findGroup">Suche</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
<main th:fragment="bodycontent">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-9" style="border: 10px solid aliceblue; background: aliceblue">
|
||||
<form action="/" method="get">
|
||||
<h1 style="color: dodgerblue; font-weight: bold" th:text="${group.getTitle()}"></h1>
|
||||
<p style="font-weight: bold">
|
||||
<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" 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>
|
||||
</p>
|
||||
<p th:text="${group.getDescription()}"></p>
|
||||
<div class="form-group">
|
||||
<div class="text-right">
|
||||
<button class="btn btn-danger" type="danger" style="border-style: none;">Gruppe verlassen</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="col-3" style="white-space: nowrap">
|
||||
<div>
|
||||
<h2 style="display: inline-block; margin: 0">Mitglieder</h2>
|
||||
<button class="btn btn-secondary" type="warning" style="background: slategrey; float: right" >Mitglieder bearbeiten</button>
|
||||
<p></p>
|
||||
</div>
|
||||
<div>
|
||||
<ul th:each="member : ${group.getMembers()}" class="list-group-flush" style="background: slategrey">
|
||||
<li class="list-group-item" style="background: aliceblue">
|
||||
<span th:text="${member.getUser_id()}"></span>
|
||||
<span th:if="${role == role.ADMIN}" class="badge badge-success">admin</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
31
src/main/resources/templates/detailsNoMember.html
Normal file
31
src/main/resources/templates/detailsNoMember.html
Normal file
@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org"
|
||||
th:replace="~{mopslayout :: html(name='Gruppenbildung', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Gruppendetails</title>
|
||||
<th:block th:fragment="headcontent">
|
||||
<!-- Links, Skripts, Styles hier einfügen! -->
|
||||
</th:block>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navigation navigation-secondary" is="mops-navigation" th:fragment="navigation">
|
||||
<ul>
|
||||
<li class="active">
|
||||
<a th:href="@{/gruppen2}" href="/">Gruppen</a>
|
||||
</li>
|
||||
<li>
|
||||
<a th:href="@{/gruppen2/createGroup}" href="/createGroup">Erstellen</a>
|
||||
</li>
|
||||
<li>
|
||||
<a th:href="@{/gruppen2/findGroup}" href="/findGroup">Suche</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
<main th:fragment="bodycontent">
|
||||
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@ -3,7 +3,7 @@
|
||||
th:replace="~{mopslayout :: html(name='Gruppenbildung', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Name des Subsystems</title>
|
||||
<title>Eigene Gruppen</title>
|
||||
<th:block th:fragment="headcontent">
|
||||
<!-- Links, Skripts, Styles hier einfügen! -->
|
||||
</th:block>
|
||||
@ -25,19 +25,39 @@
|
||||
</nav>
|
||||
</header>
|
||||
<main th:fragment="bodycontent">
|
||||
<h1>Meine Gruppen</h1>
|
||||
<div class="container-fluid">
|
||||
<form action="/" method="get">
|
||||
<div th:each="gruppe: ${gruppen}">
|
||||
<div style="border: 10px solid aliceblue; background: aliceblue">
|
||||
<h3>
|
||||
<a href="url" style="color: dodgerblue; font-weight: bold" th:text="${gruppe.getTitle()}"></a>
|
||||
</h3>
|
||||
<p th:text="${gruppe.getDescription()}"></p>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row" >
|
||||
<div class="col-10">
|
||||
<h1>Meine Gruppen</h1>
|
||||
<form action="/" method="get">
|
||||
<div th:each="gruppe: ${gruppen}">
|
||||
<div style="border: 10px solid aliceblue; background: aliceblue">
|
||||
<h3>
|
||||
<a th:href="@{/gruppen2/details(id=${gruppe.getId()})}" style="color: dodgerblue; font-weight: bold" th:text="${gruppe.getTitle()}"></a>
|
||||
</h3>
|
||||
<p th:text="${gruppe.getDescription()}"></p>
|
||||
</div>
|
||||
<br>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</form>
|
||||
<div class="col-2" >
|
||||
<div class="card" style="background: lightgrey">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title" th:text="${user.getUser_id()}" style="text-align: center">user_id</h2>
|
||||
<h3 class="card-text">
|
||||
<span th:text="${user.getGivenname()}">username</span>
|
||||
<span th:text="${user.getFamilyname()}">usersurname</span>
|
||||
</h3>
|
||||
<p class="card-text" th:text="${user.getEmail()}">usermail</p>
|
||||
<p>
|
||||
<small class="card-text">In Gruppen:</small>
|
||||
<small class="card-text" th:text="${gruppen.size()}"></small>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
th:replace="~{mopslayout :: html(name='Gruppenbildung', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Name des Subsystems</title>
|
||||
<title>Suche</title>
|
||||
<th:block th:fragment="headcontent">
|
||||
<!-- Links, Skripts, Styles hier einfügen! -->
|
||||
</th:block>
|
||||
@ -29,19 +29,19 @@
|
||||
<div class="row">
|
||||
<h1>Gruppensuche</h1>
|
||||
<div class="container-fluid">
|
||||
<form action="/findGroup" method="get">
|
||||
<form action="/gruppen2/findGroup" method="get">
|
||||
<div style="border: 10px solid aliceblue; background: aliceblue">
|
||||
<div class="form-group">
|
||||
<label>Suchbegriff:</label>
|
||||
<input class="form-control" type="text" value="" name="suchbegriff" placeholder="z.B. Programmieren, Lerngruppe, ...">
|
||||
<label for="suchleiste">Suchbegriff:</label>
|
||||
<input id="suchleiste" class="form-control" placeholder="z.B. Programmieren, Lerngruppe, ..." th:name="suchbegriff" type="text">
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary" style="background: #52a1eb; border-style: none">Suchen</button>
|
||||
<button type="submit" class="btn btn-primary" style="background: #52a1eb; border-style: none">Suchen</button>
|
||||
</div>
|
||||
</form>
|
||||
<br>
|
||||
<table class="table">
|
||||
<!-- Erscheint dann, wenn man "Suchen" Button klickt und Ergebnisse angezeigt werden, aber so solls aussehen -->
|
||||
<thead>
|
||||
<thead th:if="${!gruppen.isEmpty()}">
|
||||
<tr>
|
||||
<th scope="col">Gruppenname</th>
|
||||
<th scope="col">Beschreibung</th>
|
||||
@ -49,18 +49,12 @@
|
||||
<th scope="col">Mitgliederanzahl</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody th:each="gruppe : ${gruppen}">
|
||||
<tr>
|
||||
<th scope="row">LA1 Kursgruppe</th>
|
||||
<td>Gruppe für den Kurs LA1</td>
|
||||
<td>Öffentlich</td>
|
||||
<td>318</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Lerngruppe LA1</th>
|
||||
<td>Lerngruppe zur Bearbeitung von Übungszetteln</td>
|
||||
<td>Privat</td>
|
||||
<td>6</td>
|
||||
<th scope="row" th:text="${gruppe.title}">Gruppenname</th>
|
||||
<td th:text="${gruppe.getDescription()}">Beschreibung</td>
|
||||
<td th:text="${gruppe.getVisibility()}">Öffentlich</td>
|
||||
<td th:text="${gruppe.getMembers().size()}">Mitgliederanzahl</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@ -6,6 +6,10 @@ import mops.gruppen2.domain.Visibility;
|
||||
import mops.gruppen2.domain.event.AddUserEvent;
|
||||
import mops.gruppen2.domain.event.CreateGroupEvent;
|
||||
import mops.gruppen2.domain.event.Event;
|
||||
import mops.gruppen2.domain.GroupType;
|
||||
import mops.gruppen2.domain.Visibility;
|
||||
import mops.gruppen2.domain.event.AddUserEvent;
|
||||
import mops.gruppen2.domain.event.CreateGroupEvent;
|
||||
import mops.gruppen2.repository.EventRepository;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -105,4 +109,19 @@ class EventServiceTest {
|
||||
|
||||
assertEquals(eventService.checkGroup(), 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getDTOOffentlichTest(){
|
||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(eventService.checkGroup(), "test", null , GroupType.LECTURE, Visibility.PUBLIC);
|
||||
EventDTO eventDTO = eventService.getDTO(createGroupEvent);
|
||||
assertEquals(eventDTO.isVisibility(), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getDTOPrivatTest(){
|
||||
AddUserEvent addUserEvent = new AddUserEvent(eventService.checkGroup(), "test","franz","mueller","a@a");
|
||||
EventDTO eventDTO = eventService.getDTO(addUserEvent);
|
||||
assertEquals(eventDTO.isVisibility(), false);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user