1

fix problem where search was keeping same search throughout session and some UI changes

This commit is contained in:
killerber4t
2020-03-14 23:29:49 +01:00
parent 63279d8fe6
commit 264d4ad052
3 changed files with 40 additions and 33 deletions

View File

@ -70,20 +70,16 @@ 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",groups);
model.addAttribute("gruppen",groupse);
return "search";
}
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
@PostMapping("/findGroup")
public String searchGroup(KeycloakAuthenticationToken token, Model model, @RequestParam(value = "suchbegriff") String suchbegriff) throws EventException {
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
groups = groupService.findGroupWith(suchbegriff);
return "redirect:/gruppen2/findGroup";
}
@PostMapping("/createGroup")
public String pCreateGroup(KeycloakAuthenticationToken token,
@RequestParam(value = "title") String title,
@ -102,10 +98,9 @@ public class Gruppen2Controller {
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);
model.addAttribute("role",group.getRoles().get(user.getUser_id()));
return "detailsMember";
}
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Group not found");