Merge remote-tracking branch 'origin/html-gruppe' into html-gruppe
# Conflicts: # src/main/java/mops/gruppen2/controllers/Gruppen2Controller.java
This commit is contained in:
@ -1,24 +1,36 @@
|
|||||||
package mops.gruppen2.controllers;
|
package mops.gruppen2.controllers;
|
||||||
|
|
||||||
import mops.gruppen2.services.KeyCloakService;
|
|
||||||
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.context.annotation.SessionScope;
|
|
||||||
|
|
||||||
import javax.annotation.security.RolesAllowed;
|
import javax.annotation.security.RolesAllowed;
|
||||||
|
|
||||||
|
import mops.gruppen2.entities.Gruppe;
|
||||||
|
import mops.gruppen2.security.Account;
|
||||||
|
import org.keycloak.KeycloakPrincipal;
|
||||||
|
import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.context.annotation.SessionScope;
|
||||||
|
|
||||||
|
@SessionScope
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/gruppen2")
|
|
||||||
public class Gruppen2Controller {
|
public class Gruppen2Controller {
|
||||||
|
/**
|
||||||
private final KeyCloakService keyCloakService;
|
* Creates an Account.
|
||||||
|
*
|
||||||
public Gruppen2Controller(KeyCloakService keyCloakService) {
|
* @param token Ein toller token
|
||||||
this.keyCloakService = keyCloakService;
|
* @return Account with current userdata
|
||||||
|
*/
|
||||||
|
private Account createAccountFromPrincipal(KeycloakAuthenticationToken token) {
|
||||||
|
KeycloakPrincipal principal = (KeycloakPrincipal) token.getPrincipal();
|
||||||
|
return new Account(
|
||||||
|
principal.getName(),
|
||||||
|
principal.getKeycloakSecurityContext().getIdToken().getEmail(),
|
||||||
|
null,
|
||||||
|
principal.getKeycloakSecurityContext().getIdToken().getGivenName(),
|
||||||
|
principal.getKeycloakSecurityContext().getIdToken().getFamilyName(),
|
||||||
|
token.getAccount().getRoles());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Zeigt die index.html an.
|
/**Zeigt die index.html an.
|
||||||
@ -27,10 +39,26 @@ public class Gruppen2Controller {
|
|||||||
* @param model tolles model
|
* @param model tolles model
|
||||||
* @return index.html
|
* @return index.html
|
||||||
*/
|
*/
|
||||||
|
@GetMapping("/")
|
||||||
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
|
||||||
@GetMapping("")
|
|
||||||
public String index(KeycloakAuthenticationToken token, Model model) {
|
public String index(KeycloakAuthenticationToken token, Model model) {
|
||||||
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
|
model.addAttribute("account", createAccountFromPrincipal(token));
|
||||||
return "index";
|
return "index";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/")
|
||||||
|
public String addGruppe(@ModelAttribute Gruppe gruppe) {
|
||||||
|
System.out.println(gruppe);
|
||||||
|
return "redirect:/";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/createGroup")
|
||||||
|
public String createGruppe(){
|
||||||
|
return "create";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/findGroup")
|
||||||
|
public String findGruppe(){
|
||||||
|
return "search";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,34 +25,7 @@
|
|||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
<main th:fragment="bodycontent">
|
<main th:fragment="bodycontent">
|
||||||
<div class="container-fluid">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-4">
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">Titel</th>
|
|
||||||
<th scope="col">Beschreibung</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>Titel1</td>
|
|
||||||
<td>Beschreibung1</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>Titel2</th>
|
|
||||||
<td>Beschreibung2</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Titel3</td>
|
|
||||||
<td>Beschreibung3</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@ -25,26 +25,7 @@
|
|||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
<main th:fragment="bodycontent">
|
<main th:fragment="bodycontent">
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-6 rounded-sm text-center m-0">
|
|
||||||
<h1>Gruppenerstellung</h1>
|
|
||||||
<form method="post" action="/">
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Titel der Gruppe</label>
|
|
||||||
<input class="form-control" type="text" th:value="${titel}" name="titel" placeholder="Titel der Gruppe">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Beschreibung der Gruppe</label>
|
|
||||||
<input class="form-control" type="text" th:value="${beschreibung}" name="beschreibung" placeholder="Beschreibung der Gruppe">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<button type="submit" class="btn btn-outline-dark">weiter</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@ -25,7 +25,26 @@
|
|||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
<main th:fragment="bodycontent">
|
<main th:fragment="bodycontent">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-sm-8 ">
|
||||||
|
<h1>Gruppenerstellung</h1>
|
||||||
|
<form method="post" action="/">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Titel der Gruppe</label>
|
||||||
|
<input class="form-control" type="text" th:value="${titel}" name="titel" placeholder="Titel der Gruppe">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Beschreibung der Gruppe</label>
|
||||||
|
<input class="form-control" type="text" th:value="${beschreibung}" name="beschreibung" placeholder="Beschreibung der Gruppe">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<button type="submit" class="btn btn-outline-dark">weiter</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user