@ -2,22 +2,21 @@ package mops.gruppen2.controller;
|
|||||||
|
|
||||||
import mops.gruppen2.config.Gruppen2Config;
|
import mops.gruppen2.config.Gruppen2Config;
|
||||||
import mops.gruppen2.domain.Exceptions.EventException;
|
import mops.gruppen2.domain.Exceptions.EventException;
|
||||||
import mops.gruppen2.domain.GroupType;
|
import mops.gruppen2.domain.Group;
|
||||||
|
import mops.gruppen2.domain.Role;
|
||||||
import mops.gruppen2.domain.User;
|
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.security.Account;
|
||||||
import mops.gruppen2.service.*;
|
import mops.gruppen2.service.*;
|
||||||
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
|
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.server.ResponseStatusException;
|
||||||
|
|
||||||
import javax.annotation.security.RolesAllowed;
|
import javax.annotation.security.RolesAllowed;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/gruppen2")
|
@RequestMapping("/gruppen2")
|
||||||
@ -83,4 +82,20 @@ public class Gruppen2Controller {
|
|||||||
return "redirect:/gruppen2/";
|
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());
|
||||||
|
Role role = group.getRoles().get(user);
|
||||||
|
if(group!= null) {
|
||||||
|
model.addAttribute("group", group);
|
||||||
|
model.addAttribute("role",role);
|
||||||
|
return "detailsMember";
|
||||||
|
}
|
||||||
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Group not found");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,4 +13,4 @@ import java.util.List;
|
|||||||
public class UpdatedGroupRequestMapper {
|
public class UpdatedGroupRequestMapper {
|
||||||
private Long status;
|
private Long status;
|
||||||
private List<Group> groupList;
|
private List<Group> groupList;
|
||||||
}
|
}
|
||||||
@ -17,9 +17,10 @@ public class UpdateRoleEvent extends Event {
|
|||||||
super(event_id, group_id, user_id);
|
super(event_id, group_id, user_id);
|
||||||
this.newRole = newRole;
|
this.newRole = newRole;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UpdateRoleEvent(Long group_id, String user_id, Role newRole) {
|
public UpdateRoleEvent(Long group_id, String user_id, Role newRole) {
|
||||||
super(group_id, user_id);
|
super(group_id, user_id);
|
||||||
this.newRole = newRole;
|
this.newRole = newRole;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,8 @@ public class ControllerService {
|
|||||||
new AddUserEvent(eventService.checkGroup(), account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()),
|
new AddUserEvent(eventService.checkGroup(), account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail()),
|
||||||
new UpdateRoleEvent(eventService.checkGroup(), account.getName(), Role.ADMIN),
|
new UpdateRoleEvent(eventService.checkGroup(), account.getName(), Role.ADMIN),
|
||||||
new UpdateGroupTitleEvent(eventService.checkGroup(), account.getName(), title),
|
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);
|
eventService.saveEventList(eventList);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import mops.gruppen2.domain.event.Event;
|
|||||||
import mops.gruppen2.repository.EventRepository;
|
import mops.gruppen2.repository.EventRepository;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -26,4 +27,11 @@ public class UserService {
|
|||||||
List<Event> events = groupService.getGroupEvents(group_ids);
|
List<Event> events = groupService.getGroupEvents(group_ids);
|
||||||
return groupService.projectEventList(events);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
th:replace="~{mopslayout :: html(name='Gruppenbildung', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}">
|
th:replace="~{mopslayout :: html(name='Gruppenbildung', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Name des Subsystems</title>
|
<title>Gruppenerstellung</title>
|
||||||
<th:block th:fragment="headcontent">
|
<th:block th:fragment="headcontent">
|
||||||
<!-- Links, Skripts, Styles hier einfügen! -->
|
<!-- Links, Skripts, Styles hier einfügen! -->
|
||||||
</th:block>
|
</th:block>
|
||||||
@ -37,7 +37,7 @@
|
|||||||
<label for="beschreibung">Beschreibung der Gruppe</label>
|
<label for="beschreibung">Beschreibung der Gruppe</label>
|
||||||
<textarea th:name="beschreibung" class="form-control" id="beschreibung" rows="3"></textarea>
|
<textarea th:name="beschreibung" class="form-control" id="beschreibung" rows="3"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button class="btn btn-primary" type="submit" style="background: #52a1eb; border-style: none">Erstellen</button>
|
<button class="btn btn-primary" type="submit" style="background: #52a1eb; border-style: none">Erstellen</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
53
src/main/resources/templates/detailsMember.html
Normal file
53
src/main/resources/templates/detailsMember.html
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<!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">
|
||||||
|
<form action="/" method="get">
|
||||||
|
<div style="border: 10px solid aliceblue; background: aliceblue">
|
||||||
|
<h1 style="color: dodgerblue; font-weight: bold" th:text="${group.getTitle()}"></h1>
|
||||||
|
<p style="font-weight: bold">
|
||||||
|
<a th:if="${group.getVisibility() == group.getVisibility().PUBLIC }">Private Gruppe</a>
|
||||||
|
<a th:if="${group.getVisibility() == group.getVisibility().PRIVATE}">Öffentliche Gruppe</a>
|
||||||
|
</p>
|
||||||
|
<p th:text="${group.getDescription()}"></p>
|
||||||
|
<div class="form-group">
|
||||||
|
<div >
|
||||||
|
<div th:if="${role == role.ADMIN}">
|
||||||
|
<button class="btn btn-primary" type="warning">Gruppenmitglieder bearbeiten</button>
|
||||||
|
<button class="btn btn-primary" type="danger" style="background: #52a1eb; border-style: none">Gruppe verlassen</button>
|
||||||
|
</div>
|
||||||
|
<div th:if="${role == role.MEMBER}">
|
||||||
|
<button class="btn btn-primary" type="danger" style="background: #52a1eb; border-style: none">Gruppe verlassen</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</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})}">
|
th:replace="~{mopslayout :: html(name='Gruppenbildung', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Name des Subsystems</title>
|
<title>Eigene Gruppen</title>
|
||||||
<th:block th:fragment="headcontent">
|
<th:block th:fragment="headcontent">
|
||||||
<!-- Links, Skripts, Styles hier einfügen! -->
|
<!-- Links, Skripts, Styles hier einfügen! -->
|
||||||
</th:block>
|
</th:block>
|
||||||
@ -31,7 +31,7 @@
|
|||||||
<div th:each="gruppe: ${gruppen}">
|
<div th:each="gruppe: ${gruppen}">
|
||||||
<div style="border: 10px solid aliceblue; background: aliceblue">
|
<div style="border: 10px solid aliceblue; background: aliceblue">
|
||||||
<h3>
|
<h3>
|
||||||
<a href="url" style="color: dodgerblue; font-weight: bold" th:text="${gruppe.getTitle()}"></a>
|
<a th:href="@{/gruppen2/details(id=${gruppe.getId()})}" style="color: dodgerblue; font-weight: bold" th:text="${gruppe.getTitle()}"></a>
|
||||||
</h3>
|
</h3>
|
||||||
<p th:text="${gruppe.getDescription()}"></p>
|
<p th:text="${gruppe.getDescription()}"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
th:replace="~{mopslayout :: html(name='Gruppenbildung', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}">
|
th:replace="~{mopslayout :: html(name='Gruppenbildung', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Name des Subsystems</title>
|
<title>Suche</title>
|
||||||
<th:block th:fragment="headcontent">
|
<th:block th:fragment="headcontent">
|
||||||
<!-- Links, Skripts, Styles hier einfügen! -->
|
<!-- Links, Skripts, Styles hier einfügen! -->
|
||||||
</th:block>
|
</th:block>
|
||||||
|
|||||||
Reference in New Issue
Block a user