Merge pull request #76 from hhu-propra2/fix-vis-in-db
partially fix vis in db
This commit is contained in:
@ -33,7 +33,6 @@ public class Gruppen2Controller {
|
||||
private final GroupService groupService;
|
||||
private final UserService userService;
|
||||
private final ControllerService controllerService;
|
||||
private List<Group> groups = new ArrayList<>();
|
||||
|
||||
public Gruppen2Controller(KeyCloakService keyCloakService, EventService eventService, GroupService groupService, UserService userService, ControllerService controllerService) {
|
||||
this.keyCloakService = keyCloakService;
|
||||
@ -58,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";
|
||||
}
|
||||
|
||||
@ -83,10 +83,16 @@ public class Gruppen2Controller {
|
||||
@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/";
|
||||
}
|
||||
|
||||
@ -27,10 +27,15 @@ 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),
|
||||
|
||||
@ -77,7 +77,7 @@ public class GroupService {
|
||||
* @throws EventException
|
||||
*/
|
||||
public List<Group> getAllGroupWithVisibilityPublic() throws EventException {
|
||||
return projectEventList(eventService.translateEventDTOs(eventRepository.findEventDTOByVisibility(Boolean.FALSE)));
|
||||
return projectEventList(eventService.translateEventDTOs(eventRepository.findEventDTOByVisibility(Boolean.TRUE)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -38,11 +38,9 @@
|
||||
<label for="beschreibung">Beschreibung</label>
|
||||
<textarea th:name="beschreibung" class="form-control" id="beschreibung" rows="3" required></textarea>
|
||||
</div>
|
||||
<div class="checkbox p-2">
|
||||
<label for="visibility"></label>
|
||||
<input type="checkbox" id="visibility" > Privat
|
||||
<label for="groupType" class="pr-5"></label>
|
||||
<input type="checkbox" id="groupType"> Veranstaltung
|
||||
<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>
|
||||
|
||||
@ -31,8 +31,8 @@
|
||||
<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().PUBLIC }">Private Gruppe</span>
|
||||
<span class="badge badge-pill badge-primary" th:if="${group.getVisibility() == group.getVisibility().PRIVATE}">Öffentliche Gruppe</span>
|
||||
<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>
|
||||
@ -43,6 +43,7 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="col-3" style="white-space: nowrap">
|
||||
<div>
|
||||
<h2 style="display: inline-block; margin: 0">Mitglieder</h2>
|
||||
|
||||
@ -25,8 +25,10 @@
|
||||
</nav>
|
||||
</header>
|
||||
<main th:fragment="bodycontent">
|
||||
<h1>Meine Gruppen</h1>
|
||||
<div class="container-fluid">
|
||||
<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">
|
||||
@ -39,6 +41,24 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<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>
|
||||
</html>
|
||||
Reference in New Issue
Block a user