@ -1,11 +1,5 @@
|
||||
package mops.gruppen2;
|
||||
|
||||
import lombok.Setter;
|
||||
import mops.gruppen2.domain.Exceptions.EventException;
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.service.EventService;
|
||||
import mops.gruppen2.service.GroupService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@ -18,7 +12,6 @@ import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableSwagger2
|
||||
|
@ -1,15 +1,10 @@
|
||||
package mops.gruppen2.config;
|
||||
|
||||
import mops.gruppen2.domain.Exceptions.EventException;
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.service.EventService;
|
||||
import mops.gruppen2.service.GroupService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
public class Gruppen2Config {
|
||||
|
||||
|
@ -7,13 +7,16 @@ import mops.gruppen2.domain.Exceptions.EventException;
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.domain.apiWrapper.UpdatedGroupRequestMapper;
|
||||
import mops.gruppen2.domain.event.Event;
|
||||
import mops.gruppen2.service.*;
|
||||
import mops.gruppen2.service.APIFormatterService;
|
||||
import mops.gruppen2.service.EventService;
|
||||
import mops.gruppen2.service.GroupService;
|
||||
import mops.gruppen2.service.SerializationService;
|
||||
import org.springframework.security.access.annotation.Secured;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -6,15 +6,27 @@ import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.domain.Role;
|
||||
import mops.gruppen2.domain.User;
|
||||
import mops.gruppen2.security.Account;
|
||||
import mops.gruppen2.service.*;
|
||||
import mops.gruppen2.service.ControllerService;
|
||||
import mops.gruppen2.service.CsvService;
|
||||
import mops.gruppen2.service.EventService;
|
||||
import mops.gruppen2.service.GroupService;
|
||||
import mops.gruppen2.service.InviteLinkRepositoryService;
|
||||
import mops.gruppen2.service.KeyCloakService;
|
||||
import mops.gruppen2.service.UserService;
|
||||
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.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.context.annotation.SessionScope;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -25,13 +37,14 @@ import java.util.List;
|
||||
@RequestMapping("/gruppen2")
|
||||
public class Gruppen2Controller {
|
||||
|
||||
Gruppen2Config gruppen2Config;
|
||||
private final KeyCloakService keyCloakService;
|
||||
private final EventService eventService;
|
||||
private final GroupService groupService;
|
||||
private final UserService userService;
|
||||
private final ControllerService controllerService;
|
||||
private final InviteLinkRepositoryService inviteLinkRepositoryService;
|
||||
@Autowired
|
||||
Gruppen2Config gruppen2Config;
|
||||
|
||||
public Gruppen2Controller(KeyCloakService keyCloakService, EventService eventService, GroupService groupService, UserService userService, ControllerService controllerService, InviteLinkRepositoryService inviteLinkRepositoryService) {
|
||||
this.keyCloakService = keyCloakService;
|
||||
@ -70,10 +83,10 @@ public class Gruppen2Controller {
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_actuator)"})
|
||||
@PostMapping("/createLecture")
|
||||
public String pCreateLecture(KeycloakAuthenticationToken token,
|
||||
@RequestParam(value = "title") String title,
|
||||
@RequestParam(value = "beschreibung") String beschreibung,
|
||||
@RequestParam(value = "visibility", required = false) Boolean visibility,
|
||||
@RequestParam(value = "file", required = false) MultipartFile file) throws IOException, EventException {
|
||||
@RequestParam(value = "title") String title,
|
||||
@RequestParam(value = "beschreibung") String beschreibung,
|
||||
@RequestParam(value = "visibility", required = false) Boolean visibility,
|
||||
@RequestParam(value = "file", required = false) MultipartFile file) throws IOException, EventException {
|
||||
|
||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||
List<User> userList = new ArrayList<>();
|
||||
@ -88,7 +101,7 @@ public class Gruppen2Controller {
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_actuator)"})
|
||||
@PostMapping("/details/members/addUsersFromCsv")
|
||||
public String addUsersFromCsv(@RequestParam (value = "group_id") Long group_id,
|
||||
public String addUsersFromCsv(@RequestParam(value = "group_id") Long group_id,
|
||||
@RequestParam(value = "file", required = false) MultipartFile file) throws IOException {
|
||||
List<User> userList = new ArrayList<>();
|
||||
if (!file.isEmpty()) {
|
||||
@ -111,7 +124,7 @@ public class Gruppen2Controller {
|
||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||
List<Group> groupse = new ArrayList<>();
|
||||
if (suchbegriff != null) {
|
||||
groupse = groupService.findGroupWith(suchbegriff,account);
|
||||
groupse = groupService.findGroupWith(suchbegriff, account);
|
||||
}
|
||||
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
|
||||
model.addAttribute("gruppen", groupse);
|
||||
@ -134,7 +147,7 @@ public class Gruppen2Controller {
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||
@GetMapping("/details/{id}")
|
||||
public String showGroupDetails(KeycloakAuthenticationToken token, Model model, @PathVariable (value="id") Long id) throws EventException, ResponseStatusException {
|
||||
public String showGroupDetails(KeycloakAuthenticationToken token, Model model, @PathVariable(value = "id") Long id) throws EventException, ResponseStatusException {
|
||||
|
||||
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
|
||||
Group group = userService.getGroupById(id);
|
||||
@ -154,11 +167,13 @@ public class Gruppen2Controller {
|
||||
@PostMapping("/detailsBeitreten")
|
||||
public String joinGroup(KeycloakAuthenticationToken token, Model model, @RequestParam(value = "id") Long id) throws EventException {
|
||||
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
|
||||
Account account = keyCloakService.createAccountFromPrincipal (token);
|
||||
User user = new User(account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail());
|
||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||
User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
|
||||
Group group = userService.getGroupById(id);
|
||||
if(group.getMembers().contains(user)) return "errorRenameLater"; //hier soll eigentlich auf die bereits beigetretene Gruppe weitergeleitet werden
|
||||
controllerService.addUser(account,id);
|
||||
if (group.getMembers().contains(user)) {
|
||||
return "errorRenameLater"; //hier soll eigentlich auf die bereits beigetretene Gruppe weitergeleitet werden
|
||||
}
|
||||
controllerService.addUser(account, id);
|
||||
return "redirect:/gruppen2/";
|
||||
}
|
||||
|
||||
@ -188,7 +203,7 @@ public class Gruppen2Controller {
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator"})
|
||||
@PostMapping("/leaveGroup")
|
||||
public String pLeaveGroup(KeycloakAuthenticationToken token, @RequestParam (value="group_id") Long id) throws EventException {
|
||||
public String pLeaveGroup(KeycloakAuthenticationToken token, @RequestParam(value = "group_id") Long id) throws EventException {
|
||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||
User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
|
||||
controllerService.deleteUser(user.getUser_id(), id);
|
||||
@ -197,10 +212,10 @@ public class Gruppen2Controller {
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||
@GetMapping("/details/members/{id}")
|
||||
public String editMembers(Model model, KeycloakAuthenticationToken token, @PathVariable (value="id") Long id) throws EventException {
|
||||
public String editMembers(Model model, KeycloakAuthenticationToken token, @PathVariable(value = "id") Long id) throws EventException {
|
||||
Account account = keyCloakService.createAccountFromPrincipal(token);
|
||||
Group group = userService.getGroupById(id);
|
||||
if(group.getRoles().get(account.getName()) == Role.ADMIN) {
|
||||
if (group.getRoles().get(account.getName()) == Role.ADMIN) {
|
||||
model.addAttribute("account", account);
|
||||
model.addAttribute("members", group.getMembers());
|
||||
model.addAttribute("group", group);
|
||||
@ -213,16 +228,16 @@ public class Gruppen2Controller {
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||
@PostMapping("/details/members/changeRole")
|
||||
public String changeRole(KeycloakAuthenticationToken token, @RequestParam (value = "group_id") Long group_id,
|
||||
@RequestParam (value = "user_id") String user_id) throws EventException {
|
||||
public String changeRole(KeycloakAuthenticationToken token, @RequestParam(value = "group_id") Long group_id,
|
||||
@RequestParam(value = "user_id") String user_id) throws EventException {
|
||||
controllerService.updateRole(user_id, group_id);
|
||||
return "redirect:/gruppen2/details/members/" + group_id;
|
||||
}
|
||||
|
||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||
@PostMapping("/details/members/deleteUser")
|
||||
public String deleteUser(KeycloakAuthenticationToken token,@RequestParam (value = "group_id") Long group_id,
|
||||
@RequestParam (value = "user_id") String user_id) throws EventException {
|
||||
public String deleteUser(KeycloakAuthenticationToken token, @RequestParam(value = "group_id") Long group_id,
|
||||
@RequestParam(value = "user_id") String user_id) throws EventException {
|
||||
controllerService.deleteUser(user_id, group_id);
|
||||
return "redirect:/gruppen2/details/members/" + group_id;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mops.gruppen2.domain.Exceptions;
|
||||
|
||||
public class EventException extends Exception {
|
||||
|
||||
private String msg;
|
||||
|
||||
public EventException(String msg) {
|
||||
|
@ -1,7 +1,8 @@
|
||||
package mops.gruppen2.domain.Exceptions;
|
||||
|
||||
public class UserAlreadyExistsException extends EventException {
|
||||
public UserAlreadyExistsException(String msg){
|
||||
super(msg);
|
||||
|
||||
public UserAlreadyExistsException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
package mops.gruppen2.domain.Exceptions;
|
||||
|
||||
public class UserNotFoundException extends EventException{
|
||||
public UserNotFoundException(String msg){
|
||||
public class UserNotFoundException extends EventException {
|
||||
|
||||
public UserNotFoundException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import mops.gruppen2.domain.Exceptions.UserAlreadyExistsException;
|
||||
import mops.gruppen2.domain.Exceptions.UserNotFoundException;
|
||||
import mops.gruppen2.domain.event.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Repräsentiert den aggregierten Zustand einer Gruppe.
|
||||
@ -18,12 +18,12 @@ import java.util.*;
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class Group {
|
||||
|
||||
private final List<User> members;
|
||||
private final Map<String, Role> roles;
|
||||
private long id;
|
||||
private String title;
|
||||
private String description;
|
||||
private final List<User> members;
|
||||
private final Map<String, Role> roles;
|
||||
|
||||
private GroupType type;
|
||||
private Visibility visibility;
|
||||
private Long parent;
|
||||
|
@ -10,6 +10,7 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(exclude = {"givenname", "familyname", "email"})
|
||||
public class User {
|
||||
|
||||
String user_id;
|
||||
String givenname;
|
||||
String familyname;
|
||||
|
@ -11,6 +11,7 @@ import java.util.List;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UpdatedGroupRequestMapper {
|
||||
|
||||
private Long status;
|
||||
private List<Group> groupList;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import org.springframework.data.relational.core.mapping.Table;
|
||||
@Table("event")
|
||||
@Data
|
||||
public class EventDTO {
|
||||
|
||||
@Id
|
||||
Long event_id;
|
||||
Long group_id;
|
||||
|
@ -9,6 +9,7 @@ import org.springframework.data.relational.core.mapping.Table;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class InviteLinkDTO {
|
||||
|
||||
@Id
|
||||
Long link_id;
|
||||
Long group_id;
|
||||
|
@ -16,6 +16,7 @@ import mops.gruppen2.domain.User;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AddUserEvent extends Event {
|
||||
|
||||
String givenname;
|
||||
String familyname;
|
||||
String email;
|
||||
@ -27,10 +28,10 @@ public class AddUserEvent extends Event {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public void apply(Group group) throws EventException{
|
||||
public void apply(Group group) throws EventException {
|
||||
User user = new User(this.user_id, this.givenname, this.familyname, this.email);
|
||||
|
||||
if (group.getMembers().contains(user)){
|
||||
if (group.getMembers().contains(user)) {
|
||||
throw new UserAlreadyExistsException("Der User existiert bereits");
|
||||
}
|
||||
|
||||
|
@ -11,12 +11,11 @@ import mops.gruppen2.domain.Visibility;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CreateGroupEvent extends Event {
|
||||
|
||||
private Visibility groupVisibility;
|
||||
private Long groupParent;
|
||||
private GroupType groupType;
|
||||
|
||||
|
||||
|
||||
public CreateGroupEvent(Long group_id, String user_id, Long parent, GroupType type, Visibility visibility) {
|
||||
super(group_id, user_id);
|
||||
this.groupParent = parent;
|
||||
|
@ -1,11 +1,11 @@
|
||||
package mops.gruppen2.domain.event;
|
||||
|
||||
import lombok.*;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import mops.gruppen2.domain.Exceptions.EventException;
|
||||
import mops.gruppen2.domain.Exceptions.UserNotFoundException;
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.domain.User;
|
||||
import mops.gruppen2.domain.Group;
|
||||
|
||||
/**
|
||||
* Entfernt ein einzelnes Mitglied einer Gruppe.
|
||||
@ -13,6 +13,7 @@ import mops.gruppen2.domain.Group;
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
public class DeleteUserEvent extends Event {
|
||||
|
||||
public DeleteUserEvent(Long group_id, String user_id) {
|
||||
super(group_id, user_id);
|
||||
}
|
||||
|
@ -19,15 +19,16 @@ import mops.gruppen2.domain.Group;
|
||||
property = "type"
|
||||
)
|
||||
@JsonSubTypes({
|
||||
@JsonSubTypes.Type(value = AddUserEvent.class, name = "AddUserEvent"),
|
||||
@JsonSubTypes.Type(value = CreateGroupEvent.class, name = "CreateGroupEvent"),
|
||||
@JsonSubTypes.Type(value = DeleteUserEvent.class, name = "DeleteUserEvent"),
|
||||
@JsonSubTypes.Type(value = UpdateGroupDescriptionEvent.class, name = "UpdateGroupDescriptionEvent"),
|
||||
@JsonSubTypes.Type(value = UpdateGroupTitleEvent.class, name = "UpdateGroupTitleEvent"),
|
||||
@JsonSubTypes.Type(value = UpdateRoleEvent.class, name = "UpdateRoleEvent"),
|
||||
})
|
||||
@JsonSubTypes.Type(value = AddUserEvent.class, name = "AddUserEvent"),
|
||||
@JsonSubTypes.Type(value = CreateGroupEvent.class, name = "CreateGroupEvent"),
|
||||
@JsonSubTypes.Type(value = DeleteUserEvent.class, name = "DeleteUserEvent"),
|
||||
@JsonSubTypes.Type(value = UpdateGroupDescriptionEvent.class, name = "UpdateGroupDescriptionEvent"),
|
||||
@JsonSubTypes.Type(value = UpdateGroupTitleEvent.class, name = "UpdateGroupTitleEvent"),
|
||||
@JsonSubTypes.Type(value = UpdateRoleEvent.class, name = "UpdateRoleEvent"),
|
||||
})
|
||||
@Setter
|
||||
public class Event {
|
||||
|
||||
Long group_id;
|
||||
String user_id;
|
||||
|
||||
|
@ -12,6 +12,7 @@ import mops.gruppen2.domain.Group;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UpdateGroupDescriptionEvent extends Event {
|
||||
|
||||
String newGroupDescription;
|
||||
|
||||
public UpdateGroupDescriptionEvent(Long group_id, String user_id, String newGroupDescription) {
|
||||
|
@ -12,6 +12,7 @@ import mops.gruppen2.domain.Group;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UpdateGroupTitleEvent extends Event {
|
||||
|
||||
String newGroupTitle;
|
||||
|
||||
public UpdateGroupTitleEvent(Long group_id, String user_id, String newGroupTitle) {
|
||||
|
@ -1,13 +1,11 @@
|
||||
package mops.gruppen2.domain.event;
|
||||
|
||||
import lombok.*;
|
||||
import mops.gruppen2.domain.Exceptions.EventException;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import mops.gruppen2.domain.Exceptions.UserNotFoundException;
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.domain.Role;
|
||||
import mops.gruppen2.domain.User;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Aktualisiert die Gruppenrolle eines Teilnehmers.
|
||||
@ -18,14 +16,14 @@ import java.util.Optional;
|
||||
public class UpdateRoleEvent extends Event {
|
||||
|
||||
Role newRole;
|
||||
|
||||
|
||||
public UpdateRoleEvent(Long group_id, String user_id, Role newRole) {
|
||||
super(group_id, user_id);
|
||||
this.newRole = newRole;
|
||||
}
|
||||
|
||||
public void apply(Group group) throws UserNotFoundException{
|
||||
if (!group.getRoles().containsKey(user_id)){
|
||||
public void apply(Group group) throws UserNotFoundException {
|
||||
if (!group.getRoles().containsKey(user_id)) {
|
||||
throw new UserNotFoundException("Der User wurde nicht gefunden");
|
||||
}
|
||||
group.getRoles().put(this.user_id, this.newRole);
|
||||
|
@ -10,6 +10,7 @@ import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface EventRepository extends CrudRepository<EventDTO, Long> {
|
||||
|
||||
@Query("select distinct group_id from event where user_id =:id")
|
||||
List<Long> findGroup_idsWhereUser_id(@Param("id") String user_id);
|
||||
|
||||
@ -19,9 +20,9 @@ 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 visibility =:vis")
|
||||
List<Long> findGroup_idsWhereVisibility(@Param("vis") Boolean visibility);
|
||||
|
||||
@Query("SELECT DISTINCT group_id FROM event WHERE event_id > :status")
|
||||
public List<Long> findNewEventSinceStatus(@Param("status") Long status);
|
||||
|
||||
|
@ -1,12 +1,14 @@
|
||||
package mops.gruppen2.security;
|
||||
|
||||
import java.util.Set;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class Account {
|
||||
|
||||
private final String name; //user_id
|
||||
private final String email;
|
||||
private final String image;
|
||||
|
@ -16,39 +16,30 @@ import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Configuration
|
||||
public class KeycloakConfig {
|
||||
|
||||
@Value("${keycloak.resource}")
|
||||
private String clientId;
|
||||
|
||||
@Value("${keycloak.credentials.secret}")
|
||||
private String clientSecret;
|
||||
|
||||
@Value("${hhu_keycloak.token-uri}")
|
||||
private String tokenUri;
|
||||
|
||||
@Bean
|
||||
public KeycloakSpringBootConfigResolver keycloakConfigResolver() {
|
||||
return new KeycloakSpringBootConfigResolver();
|
||||
}
|
||||
|
||||
@Value("${keycloak.resource}")
|
||||
|
||||
private String clientId;
|
||||
|
||||
@Value("${keycloak.credentials.secret}")
|
||||
|
||||
private String clientSecret;
|
||||
|
||||
@Value("${hhu_keycloak.token-uri}")
|
||||
|
||||
private String tokenUri;
|
||||
|
||||
|
||||
@Bean
|
||||
public RestTemplate serviceAccountRestTemplate() {
|
||||
|
||||
ClientCredentialsResourceDetails resourceDetails = new ClientCredentialsResourceDetails();
|
||||
|
||||
resourceDetails.setGrantType(OAuth2Constants.CLIENT_CREDENTIALS);
|
||||
|
||||
resourceDetails.setAccessTokenUri(tokenUri);
|
||||
|
||||
resourceDetails.setClientId(clientId);
|
||||
|
||||
resourceDetails.setClientSecret(clientSecret);
|
||||
|
||||
|
||||
return new OAuth2RestTemplate(resourceDetails);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter {
|
||||
|
||||
@Bean
|
||||
@Scope(scopeName = WebApplicationContext.SCOPE_REQUEST,
|
||||
proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
public AccessToken getAccessToken() {
|
||||
HttpServletRequest request =
|
||||
((ServletRequestAttributes) RequestContextHolder
|
||||
@ -61,14 +61,14 @@ class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter {
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
super.configure(http);
|
||||
http.authorizeRequests()
|
||||
.antMatchers("/actuator/**")
|
||||
.hasRole("monitoring")
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
.antMatchers("/h2-console/**")
|
||||
.permitAll()
|
||||
.anyRequest()
|
||||
.permitAll();
|
||||
.antMatchers("/actuator/**")
|
||||
.hasRole("monitoring")
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
.antMatchers("/h2-console/**")
|
||||
.permitAll()
|
||||
.anyRequest()
|
||||
.permitAll();
|
||||
|
||||
http.csrf().disable();
|
||||
http.headers().frameOptions().disable();
|
||||
@ -88,5 +88,6 @@ class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter {
|
||||
jsr250Enabled = true)
|
||||
public static class MethodSecurityConfig
|
||||
extends GlobalMethodSecurityConfiguration {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,8 @@ import java.util.List;
|
||||
|
||||
@Service
|
||||
public class APIFormatterService {
|
||||
static public UpdatedGroupRequestMapper wrapp(Long status, List<Group> groupList){
|
||||
|
||||
static public UpdatedGroupRequestMapper wrapp(Long status, List<Group> groupList) {
|
||||
return new UpdatedGroupRequestMapper(status, groupList);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,18 @@
|
||||
package mops.gruppen2.service;
|
||||
|
||||
import mops.gruppen2.domain.*;
|
||||
import mops.gruppen2.domain.Exceptions.EventException;
|
||||
import mops.gruppen2.domain.event.*;
|
||||
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.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.security.Account;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -34,7 +44,7 @@ public class ControllerService {
|
||||
createInviteLink(group_id);
|
||||
}
|
||||
|
||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(group_id, account.getName(), null , GroupType.SIMPLE, visibility1);
|
||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(group_id, account.getName(), null, GroupType.SIMPLE, visibility1);
|
||||
eventService.saveEvent(createGroupEvent);
|
||||
User user = new User(account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
|
||||
|
||||
@ -49,8 +59,8 @@ public class ControllerService {
|
||||
}
|
||||
|
||||
|
||||
public void addUser(Account account, Long group_id){
|
||||
AddUserEvent addUserEvent = new AddUserEvent(group_id,account.getName(),account.getGivenname(),account.getFamilyname(),account.getEmail());
|
||||
public void addUser(Account account, Long group_id) {
|
||||
AddUserEvent addUserEvent = new AddUserEvent(group_id, account.getName(), account.getGivenname(), account.getFamilyname(), account.getEmail());
|
||||
eventService.saveEvent(addUserEvent);
|
||||
}
|
||||
|
||||
@ -61,13 +71,13 @@ public class ControllerService {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTitle(Account account, Long group_id, String title){
|
||||
UpdateGroupTitleEvent updateGroupTitleEvent = new UpdateGroupTitleEvent(group_id,account.getName(),title);
|
||||
public void updateTitle(Account account, Long group_id, String title) {
|
||||
UpdateGroupTitleEvent updateGroupTitleEvent = new UpdateGroupTitleEvent(group_id, account.getName(), title);
|
||||
eventService.saveEvent(updateGroupTitleEvent);
|
||||
}
|
||||
|
||||
public void updateDescription(Account account, Long group_id, String description){
|
||||
UpdateGroupDescriptionEvent updateGroupDescriptionEvent = new UpdateGroupDescriptionEvent(group_id,account.getName(),description);
|
||||
public void updateDescription(Account account, Long group_id, String description) {
|
||||
UpdateGroupDescriptionEvent updateGroupDescriptionEvent = new UpdateGroupDescriptionEvent(group_id, account.getName(), description);
|
||||
eventService.saveEvent(updateGroupDescriptionEvent);
|
||||
}
|
||||
|
||||
@ -76,7 +86,9 @@ public class ControllerService {
|
||||
Group group = userService.getGroupById(group_id);
|
||||
User user = null;
|
||||
for (User member : group.getMembers()) {
|
||||
if(member.getUser_id().equals(user_id)) user = member;
|
||||
if (member.getUser_id().equals(user_id)) {
|
||||
user = member;
|
||||
}
|
||||
}
|
||||
assert user != null;
|
||||
if (group.getRoles().get(user.getUser_id()) == Role.ADMIN) {
|
||||
@ -91,7 +103,9 @@ public class ControllerService {
|
||||
Group group = userService.getGroupById(group_id);
|
||||
User user = null;
|
||||
for (User member : group.getMembers()) {
|
||||
if(member.getUser_id().equals(user_id)) user = member;
|
||||
if (member.getUser_id().equals(user_id)) {
|
||||
user = member;
|
||||
}
|
||||
}
|
||||
assert user != null;
|
||||
DeleteUserEvent deleteUserEvent = new DeleteUserEvent(group_id, user.getUser_id());
|
||||
|
@ -13,6 +13,7 @@ import java.util.List;
|
||||
|
||||
@Service
|
||||
public class EventService {
|
||||
|
||||
private final SerializationService serializationService;
|
||||
private final EventRepository eventStore;
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
package mops.gruppen2.service;
|
||||
|
||||
import mops.gruppen2.domain.dto.EventDTO;
|
||||
import mops.gruppen2.domain.Exceptions.EventException;
|
||||
import mops.gruppen2.domain.Group;
|
||||
import mops.gruppen2.domain.Visibility;
|
||||
import mops.gruppen2.domain.dto.EventDTO;
|
||||
import mops.gruppen2.domain.event.Event;
|
||||
import mops.gruppen2.repository.EventRepository;
|
||||
import mops.gruppen2.security.Account;
|
||||
@ -25,7 +24,8 @@ public class GroupService {
|
||||
this.eventRepository = eventRepository;
|
||||
}
|
||||
|
||||
/** Sucht in der DB alle Zeilen raus welche eine der Gruppen_ids hat.
|
||||
/**
|
||||
* 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
|
||||
@ -33,14 +33,15 @@ public class GroupService {
|
||||
*/
|
||||
public List<Event> getGroupEvents(List<Long> group_ids) {
|
||||
List<EventDTO> eventDTOS = new ArrayList<>();
|
||||
for (Long group_id: group_ids) {
|
||||
for (Long group_id : group_ids) {
|
||||
eventDTOS.addAll(eventRepository.findEventDTOByGroup_id(group_id));
|
||||
}
|
||||
return 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
|
||||
/**
|
||||
* 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
|
||||
@ -57,8 +58,9 @@ 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
|
||||
/**
|
||||
* 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
|
||||
@ -73,7 +75,7 @@ public class GroupService {
|
||||
}
|
||||
|
||||
private List<Long> removeUserGroups(List<Long> group_ids, List<Long> user_groups) {
|
||||
for (Long group_id: user_groups) {
|
||||
for (Long group_id : user_groups) {
|
||||
group_ids.remove(group_id);
|
||||
}
|
||||
return group_ids;
|
||||
@ -82,6 +84,7 @@ public class GroupService {
|
||||
/**
|
||||
* sucht alle Zeilen in der DB wo die Visibility true ist und entfernt alle Gruppen des Users.
|
||||
* Erstellt eine Liste aus Gruppen.
|
||||
*
|
||||
* @return
|
||||
* @throws EventException
|
||||
*/
|
||||
@ -97,14 +100,15 @@ public class GroupService {
|
||||
/**
|
||||
* 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, Account account) throws EventException {
|
||||
List<Group> groups = new ArrayList<>();
|
||||
for (Group group: getAllGroupWithVisibilityPublic(account.getName())) {
|
||||
if (group.getTitle().toLowerCase().contains(search.toLowerCase()) || group.getDescription().toLowerCase().contains(search.toLowerCase())){
|
||||
for (Group group : getAllGroupWithVisibilityPublic(account.getName())) {
|
||||
if (group.getTitle().toLowerCase().contains(search.toLowerCase()) || group.getDescription().toLowerCase().contains(search.toLowerCase())) {
|
||||
groups.add(group);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,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);
|
||||
|
@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
//Hallo
|
||||
@Service
|
||||
public class UserService {
|
||||
@ -25,11 +26,11 @@ public class UserService {
|
||||
|
||||
public List<Group> getUserGroups(User user) throws EventException {
|
||||
List<Long> group_ids = eventRepository.findGroup_idsWhereUser_id(user.getUser_id());
|
||||
List<Event> events = groupService.getGroupEvents(group_ids);
|
||||
List<Event> events = groupService.getGroupEvents(group_ids);
|
||||
List<Group> groups = groupService.projectEventList(events);
|
||||
List<Group> newGroups = new ArrayList<>();
|
||||
for (Group group: groups) {
|
||||
if(group.getMembers().contains(user)){
|
||||
for (Group group : groups) {
|
||||
if (group.getMembers().contains(user)) {
|
||||
newGroups.add(group);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
server.port=8080
|
||||
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.url=jdbc:h2:mem:blogdb
|
||||
@ -16,6 +15,5 @@ keycloak.resource=gruppenfindung
|
||||
keycloak.credentials.secret=fc6ebf10-8c63-4e71-a667-4eae4e8209a1
|
||||
keycloak.verify-token-audience=true
|
||||
keycloak.use-resource-role-mappings=true
|
||||
|
||||
keycloak.autodetect-bearer-only=true
|
||||
keycloak.confidential-port= 443
|
||||
|
@ -1,5 +1,4 @@
|
||||
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
|
||||
@ -10,12 +9,10 @@ spring.datasource.password=geheim
|
||||
keycloak.principal-attribute=preferred_username
|
||||
keycloak.auth-server-url=https://keycloak.cs.hhu.de/auth
|
||||
keycloak.realm=MOPS
|
||||
|
||||
hhu_keycloak.token-uri=https://keycloak.cs.hhu.de/auth/realms/MOPS/protocol/openid-connect/token
|
||||
keycloak.resource=gruppenfindung
|
||||
keycloak.credentials.secret= fc6ebf10-8c63-4e71-a667-4eae4e8209a1
|
||||
keycloak.verify-token-audience=true
|
||||
keycloak.use-resource-role-mappings=true
|
||||
|
||||
keycloak.autodetect-bearer-only=true
|
||||
keycloak.confidential-port= 443
|
||||
|
@ -1,3 +1,5 @@
|
||||
-- noinspection SqlDialectInspectionForFile
|
||||
|
||||
-- noinspection SqlNoDataSourceInspectionForFile
|
||||
|
||||
DROP TABLE IF EXISTS event;
|
||||
|
@ -16,7 +16,7 @@
|
||||
<li>
|
||||
<a th:href="@{/gruppen2}" href="/">Gruppen</a>
|
||||
</li>
|
||||
<li class="active">
|
||||
<li class="active">
|
||||
<a th:href="@{/gruppen2/createGroup}" href="/createGroup">Erstellen</a>
|
||||
</li>
|
||||
<li>
|
||||
@ -34,23 +34,29 @@
|
||||
<div class="col-10">
|
||||
<h1>Gruppenerstellung</h1>
|
||||
<form method="post" action="/gruppen2/createGroup">
|
||||
<div class="shadow p-2" 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">Titel</label>
|
||||
<input type="text" class="form-control" id="titel" th:name="title" required>
|
||||
<input class="form-control" id="titel" required th:name="title"
|
||||
type="text">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="beschreibung">Beschreibung</label>
|
||||
<textarea th:name="beschreibung" class="form-control" id="beschreibung" rows="3" required></textarea>
|
||||
<textarea class="form-control" id="beschreibung" required
|
||||
rows="3" th:name="beschreibung"></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>
|
||||
<input class="custom-control-input" id="visibility" th:name="visibility"
|
||||
type="checkbox">
|
||||
<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 disabled selected="true">--Bitte Veranstaltung auswählen--
|
||||
</option>
|
||||
<option>1</option>
|
||||
<option>2</option>
|
||||
<option>3</option>
|
||||
@ -58,7 +64,10 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group pt-4">
|
||||
<button class="btn btn-primary" type="submit" style="background: #52a1eb; border-style: none">Erstellen</button>
|
||||
<button class="btn btn-primary"
|
||||
style="background: #52a1eb; border-style: none"
|
||||
type="submit">Erstellen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -7,7 +7,8 @@
|
||||
<title>Gruppenerstellung</title>
|
||||
<th:block th:fragment="headcontent">
|
||||
<!-- Links, Skripts, Styles hier einfügen! -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
|
||||
<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>
|
||||
@ -37,32 +38,43 @@
|
||||
<div class="row">
|
||||
<div class="col-10">
|
||||
<h1>Veranstaltung erstellen</h1>
|
||||
<div class="shadow p-2" style=" border: 10px solid aliceblue; background: aliceblue">
|
||||
<form method="post" action="/gruppen2/createLecture" enctype="multipart/form-data">
|
||||
<div class="shadow p-2"
|
||||
style=" border: 10px solid aliceblue; background: aliceblue">
|
||||
<form action="/gruppen2/createLecture" enctype="multipart/form-data"
|
||||
method="post">
|
||||
<div class="form-group">
|
||||
<label for="titel">Titel</label>
|
||||
<input type="text" class="form-control" id="titel" th:name="title" required>
|
||||
<input class="form-control" id="titel" required th:name="title"
|
||||
type="text">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="beschreibung">Beschreibung</label>
|
||||
<textarea th:name="beschreibung" class="form-control" id="beschreibung" rows="3" required></textarea>
|
||||
<textarea class="form-control" id="beschreibung" required
|
||||
rows="3" th:name="beschreibung"></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>
|
||||
<input class="custom-control-input" id="visibility" th:name="visibility"
|
||||
type="checkbox">
|
||||
<label class="custom-control-label" for="visibility">Private
|
||||
Gruppe</label>
|
||||
</div>
|
||||
<div class="form-group pt-4">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="custom-file">
|
||||
<input type="file" class="custom-file-input" id="file" th:name="file">
|
||||
<label class="custom-file-label" for="file">CSV Datei von Mitgliedern hochladen</label>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group pt-4">
|
||||
<button class="btn btn-primary" type="submit" style="background: #52a1eb; border-style: none">Erstellen</button>
|
||||
<button class="btn btn-primary"
|
||||
style="background: #52a1eb; border-style: none"
|
||||
type="submit">Erstellen
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@ -71,11 +83,11 @@
|
||||
</div>
|
||||
<script>
|
||||
// Add the following code if you want the name of the file appear on select
|
||||
$(".custom-file-input").on("change", function() {
|
||||
$(".custom-file-input").on("change", function () {
|
||||
var fileName = $(this).val().split("\\").pop();
|
||||
$(this).siblings(".custom-file-label").addClass("selected").html(fileName);
|
||||
});
|
||||
</script>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
@ -30,12 +30,16 @@
|
||||
<main th:fragment="bodycontent">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-9 shadow-sm p-4" style="border: 10px solid aliceblue; background: aliceblue">
|
||||
<div class="col-9 shadow-sm p-4"
|
||||
style="border: 10px solid aliceblue; background: aliceblue">
|
||||
<h1 style="color: black; font-weight: bold" 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" 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>
|
||||
<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>
|
||||
</h3>
|
||||
<br>
|
||||
<div class="shadow-sm p-4" style="background: white">
|
||||
@ -43,11 +47,15 @@
|
||||
</div>
|
||||
<br>
|
||||
<div class="text-right btn-toolbar" style="float: right" role="toolbar">
|
||||
<button class="btn btn-primary" style="background: dodgerblue; border: none; margin: 5px">
|
||||
<button class="btn btn-primary"
|
||||
style="background: dodgerblue; border: none; margin: 5px">
|
||||
<a th:href="@{/gruppen2}" style="color: white">Zurück</a>
|
||||
</button>
|
||||
<form method="post" action="/gruppen2/leaveGroup">
|
||||
<button th:value="${group.getId()}" th:name="group_id" class="btn btn-danger" type="submit" style="border-style: none; margin: 5px">Gruppe verlassen</button>
|
||||
<button class="btn btn-danger" style="border-style: none; margin: 5px"
|
||||
th:name="group_id" th:value="${group.getId()}"
|
||||
type="submit">Gruppe verlassen
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@ -55,8 +63,10 @@
|
||||
<div style="display: inline-block; margin: 0">
|
||||
<h2>Mitglieder</h2>
|
||||
<div th:if='${group.getRoles().get(user.getUser_id()) == admin}'>
|
||||
<form method="get" th:action="@{/gruppen2/details/members/{id}(id=${group.getId()})}">
|
||||
<button class="btn btn-secondary" style="background: slategrey; float: right">
|
||||
<form method="get"
|
||||
th:action="@{/gruppen2/details/members/{id}(id=${group.getId()})}">
|
||||
<button class="btn btn-secondary"
|
||||
style="background: slategrey; float: right">
|
||||
Mitglieder bearbeiten
|
||||
</button>
|
||||
</form>
|
||||
@ -65,10 +75,12 @@
|
||||
<br>
|
||||
</div>
|
||||
<div>
|
||||
<ul th:each="member : ${group.getMembers()}" class="list-group-flush" style="background: slategrey">
|
||||
<li class="list-group-item" style="background: aliceblue">
|
||||
<ul class="list-group-flush" style="background: slategrey"
|
||||
th:each="member : ${group.getMembers()}">
|
||||
<li class="list-group-item" style="background: aliceblue">
|
||||
<span th:text="${member.getUser_id()}"></span>
|
||||
<span th:if='${group.getRoles().get(member.getUser_id()) == admin}' class="badge badge-success">admin</span>
|
||||
<span class="badge badge-success"
|
||||
th:if='${group.getRoles().get(member.getUser_id()) == admin}'>admin</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -77,4 +89,4 @@
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
@ -31,20 +31,31 @@
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-9">
|
||||
<div class="shadow-sm p-4" style="border: 10px solid aliceblue; background: aliceblue">
|
||||
<div class="shadow-sm p-4"
|
||||
style="border: 10px solid aliceblue; background: aliceblue">
|
||||
<h1 style="color: black; font-weight: bold" 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" 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>
|
||||
<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>
|
||||
</h3>
|
||||
<div class="shadow-sm p-4" style="background: white">
|
||||
<p style="overflow-wrap: break-word" th:text="${group.getDescription()}"></p>
|
||||
<p style="overflow-wrap: break-word"
|
||||
th:text="${group.getDescription()}"></p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="text-right">
|
||||
<form method="post" action="/gruppen2/detailsBeitreten">
|
||||
<button type="submit" th:href="@{/gruppen2/detailsBeitreten(id=${group.getId()})}" th:name="id" th:value="${group.id}" class="btn btn-primary" style="border-style: none;">Gruppe beitreten</button>
|
||||
<button class="btn btn-primary"
|
||||
style="border-style: none;"
|
||||
th:href="@{/gruppen2/detailsBeitreten(id=${group.getId()})}"
|
||||
th:name="id" th:value="${group.id}"
|
||||
type="submit">Gruppe beitreten
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@ -54,4 +65,4 @@
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
@ -6,7 +6,8 @@
|
||||
<title>Gruppendetails</title>
|
||||
<th:block th:fragment="headcontent">
|
||||
<!-- Links, Skripts, Styles hier einfügen! -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
|
||||
<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>
|
||||
@ -38,16 +39,25 @@
|
||||
<div class="shadow p-2" style="border: 10px solid aliceblue; background: aliceblue">
|
||||
<!-- absichern im controller nicht vergessen -->
|
||||
<div class="form-group pt-4" th:if="${account.getRoles().contains('orga')}">
|
||||
<form method="post" action="/gruppen2/details/members/addUsersFromCsv" enctype="multipart/form-data">
|
||||
<form action="/gruppen2/details/members/addUsersFromCsv"
|
||||
enctype="multipart/form-data"
|
||||
method="post">
|
||||
<div class="row">
|
||||
<div class="col-9">
|
||||
<div class="custom-file">
|
||||
<input type="file" class="custom-file-input" id="file" th:name="file">
|
||||
<label class="custom-file-label" for="file">CSV Datei von Mitgliedern hochladen</label>
|
||||
<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>
|
||||
<div class="col-3">
|
||||
<button th:name="group_id" th:value="${group.getId()}" class="btn btn-primary" type="submit" style="background: #52a1eb; border-style: none">Mitglieder hinzufügen</button>
|
||||
<button class="btn btn-primary"
|
||||
style="background: #52a1eb; border-style: none"
|
||||
th:name="group_id" th:value="${group.getId()}"
|
||||
type="submit">
|
||||
Mitglieder hinzufügen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@ -62,28 +72,36 @@
|
||||
</thead>
|
||||
<tbody class="table-striped">
|
||||
|
||||
<tr th:each="member : ${group.getMembers()}">
|
||||
<th th:text="${member.getUser_id()}"></th>
|
||||
<td>
|
||||
<span th:if='${group.getRoles().get(member.getUser_id()) != admin}'>Mitglied</span>
|
||||
<span th:if='${group.getRoles().get(member.getUser_id()) == admin}'>Admin</span>
|
||||
</td>
|
||||
<td>
|
||||
<form method="post" action="/gruppen2/details/members/changeRole">
|
||||
<input type="hidden" th:name="group_id" th:value="${group.getId()}">
|
||||
<input type="hidden" th:name="user_id" th:value="${member.getUser_id()}">
|
||||
<button type="submit" class="btn btn-warning btn-sm">Rolle ändern</button><!-- th:if -->
|
||||
</form>
|
||||
<form method="post" action="/gruppen2/details/members/deleteUser">
|
||||
<input type="hidden" th:name="group_id" th:value="${group.getId()}">
|
||||
<input type="hidden" th:name="user_id" th:value="${member.getUser_id()}">
|
||||
<button class="btn btn-danger btn-sm">Mitglied entfernen</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<tr th:each="member : ${group.getMembers()}">
|
||||
<th th:text="${member.getUser_id()}"></th>
|
||||
<td>
|
||||
<span th:if='${group.getRoles().get(member.getUser_id()) != admin}'>Mitglied</span>
|
||||
<span th:if='${group.getRoles().get(member.getUser_id()) == admin}'>Admin</span>
|
||||
</td>
|
||||
<td>
|
||||
<form action="/gruppen2/details/members/changeRole" method="post">
|
||||
<input th:name="group_id" th:value="${group.getId()}"
|
||||
type="hidden">
|
||||
<input th:name="user_id" th:value="${member.getUser_id()}"
|
||||
type="hidden">
|
||||
<button class="btn btn-warning btn-sm" type="submit">Rolle
|
||||
ändern
|
||||
</button><!-- th:if -->
|
||||
</form>
|
||||
<form action="/gruppen2/details/members/deleteUser" method="post">
|
||||
<input th:name="group_id" th:value="${group.getId()}"
|
||||
type="hidden">
|
||||
<input th:name="user_id" th:value="${member.getUser_id()}"
|
||||
type="hidden">
|
||||
<button class="btn btn-danger btn-sm">Mitglied entfernen
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<button type="button" class="btn btn-primary" style="background: #52a1eb; border-style: none">
|
||||
<button class="btn btn-primary" style="background: #52a1eb; border-style: none"
|
||||
type="button">
|
||||
<a th:href="@{/gruppen2/details(id=${group.getId()})}" style="color: white">Fertig</a>
|
||||
</button>
|
||||
</div>
|
||||
@ -92,7 +110,7 @@
|
||||
</div>
|
||||
<script>
|
||||
// Add the following code if you want the name of the file appear on select
|
||||
$(".custom-file-input").on("change", function() {
|
||||
$(".custom-file-input").on("change", function () {
|
||||
var fileName = $(this).val().split("\\").pop();
|
||||
$(this).siblings(".custom-file-label").addClass("selected").html(fileName);
|
||||
});
|
||||
|
@ -1,18 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
||||
<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>Error</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="mx-auto" style="vertical-align: center; horiz-align: center; top: 50%; left: 50%; margin-top: 200px">
|
||||
<div class="text-center" style="background: aliceblue; align-items: center; margin: auto; width: 1000px; vertical-align: center; padding: 50px; display: block">
|
||||
<div class="mx-auto"
|
||||
style="vertical-align: center; horiz-align: center; top: 50%; left: 50%; margin-top: 200px">
|
||||
<div class="text-center"
|
||||
style="background: aliceblue; align-items: center; margin: auto; width: 1000px; vertical-align: center; padding: 50px; display: block">
|
||||
<h1 style="text-align: center">Da ist etwas schiefgelaufen!</h1>
|
||||
<h2 style="text-align: center">Die Seite, nach der du suchst, scheint nicht zu existieren.</h2>
|
||||
<h2 style="text-align: center">Die Seite, nach der du suchst, scheint nicht zu
|
||||
existieren.</h2>
|
||||
<br>
|
||||
<div>
|
||||
<button type="button" class="btn btn-primary" style="margin: auto">
|
||||
@ -23,4 +29,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
@ -10,23 +10,23 @@
|
||||
</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>
|
||||
<!-- Fix double point -->
|
||||
<li th:if="${account.getRoles().contains('orga')}">
|
||||
<a th:href="@{/gruppen2/createLecture}" href="/createLecture">Veranstaltung</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<nav class="navigation navigation-secondary" is="mops-navigation" th:fragment="navigation">
|
||||
<ul>
|
||||
<li class="active">
|
||||
<a href="/" th:href="@{/gruppen2}">Gruppen</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/createGroup" th:href="@{/gruppen2/createGroup}">Erstellen</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/findGroup" th:href="@{/gruppen2/findGroup}">Suche</a>
|
||||
</li>
|
||||
<!-- Fix double point -->
|
||||
<li th:if="${account.getRoles().contains('orga')}">
|
||||
<a href="/createLecture" th:href="@{/gruppen2/createLecture}">Veranstaltung</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
<main th:fragment="bodycontent">
|
||||
<div class="container-fluid">
|
||||
@ -36,18 +36,23 @@
|
||||
<form action="/" method="get">
|
||||
<h3 style="color: dodgerblue; font-weight: bold;">
|
||||
<small style="font-weight: normal; color: black">Mitglied in </small>
|
||||
<small style="font-weight: bold; color: black" th:text="${gruppen.size()}"></small>
|
||||
<small style="font-weight: normal; color: black" th:if='${gruppen.size()==1}'> Gruppe.</small>
|
||||
<small style="font-weight: normal; color: black" th:if='${gruppen.size()!=1}'> Gruppen.</small>
|
||||
<small style="font-weight: bold; color: black"
|
||||
th:text="${gruppen.size()}"></small>
|
||||
<small style="font-weight: normal; color: black"
|
||||
th:if='${gruppen.size()==1}'> Gruppe.</small>
|
||||
<small style="font-weight: normal; color: black"
|
||||
th:if='${gruppen.size()!=1}'> Gruppen.</small>
|
||||
</h3>
|
||||
<br>
|
||||
<div th:each="gruppe: ${gruppen}">
|
||||
<div class="shadow-sm p-4" style="border: none; background: aliceblue">
|
||||
<h3 style="color: dodgerblue; font-weight: bold;">
|
||||
<a th:href="@{/gruppen2/details/{id}(id=${gruppe.getId()})}" th:text="${gruppe.getTitle()}"></a>
|
||||
<a th:href="@{/gruppen2/details/{id}(id=${gruppe.getId()})}"
|
||||
th:text="${gruppe.getTitle()}"></a>
|
||||
</h3>
|
||||
<div class="shadow-sm p-4" style="background: white">
|
||||
<p style="overflow-wrap: break-word" th:text="${#strings.abbreviate(gruppe.getDescription(),300)}"></p>
|
||||
<p style="overflow-wrap: break-word"
|
||||
th:text="${#strings.abbreviate(gruppe.getDescription(),300)}"></p>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
@ -58,4 +63,4 @@
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
@ -36,29 +36,37 @@
|
||||
<div class="shadow" style="border: 10px solid aliceblue; background: aliceblue">
|
||||
<div class="form-group">
|
||||
<label for="suchleiste">Suchbegriff:</label>
|
||||
<input id="suchleiste" class="form-control" placeholder="z.B. Programmieren, Lerngruppe, ..." th:name="suchbegriff" type="text">
|
||||
<input class="form-control" id="suchleiste"
|
||||
placeholder="z.B. Programmieren, Lerngruppe, ..."
|
||||
th:name="suchbegriff" type="text">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary" style="background: #52a1eb; border-style: none">Suchen</button>
|
||||
<button class="btn btn-primary"
|
||||
style="background: #52a1eb; border-style: none"
|
||||
type="submit">Suchen
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<br>
|
||||
<table class="table">
|
||||
<!-- Erscheint dann, wenn man "Suchen" Button klickt und Ergebnisse angezeigt werden, aber so solls aussehen -->
|
||||
<thead th:if="${!gruppen.isEmpty()}">
|
||||
<tr>
|
||||
<th scope="col">Gruppenname</th>
|
||||
<th scope="col">Beschreibung</th>
|
||||
<th scope="col">Mitgliederanzahl</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="col">Gruppenname</th>
|
||||
<th scope="col">Beschreibung</th>
|
||||
<th scope="col">Mitgliederanzahl</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody th:each="gruppe : ${gruppen}">
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<a th:href="@{/gruppen2/detailsSearch(id=${gruppe.getId()})}" th:text="${gruppe.title}">Gruppenname</a>
|
||||
</th>
|
||||
<td style="" th:text="${#strings.abbreviate(gruppe.getDescription(), 50)}">Beschreibung</td>
|
||||
<td th:text="${gruppe.getMembers().size()}">Mitgliederanzahl</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<a th:href="@{/gruppen2/detailsSearch(id=${gruppe.getId()})}"
|
||||
th:text="${gruppe.title}">Gruppenname</a>
|
||||
</th>
|
||||
<td style="" th:text="${#strings.abbreviate(gruppe.getDescription(), 50)}">
|
||||
Beschreibung
|
||||
</td>
|
||||
<td th:text="${gruppe.getMembers().size()}">Mitgliederanzahl</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -66,4 +74,4 @@
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user