1

link now correct displayed

This commit is contained in:
[Mahgs]
2020-03-24 15:09:44 +01:00
parent 60837d8cf3
commit 89354eec26
2 changed files with 17 additions and 35 deletions

View File

@ -29,7 +29,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.context.annotation.SessionScope; import org.springframework.web.context.annotation.SessionScope;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.security.RolesAllowed; import javax.annotation.security.RolesAllowed;
import javax.servlet.http.HttpServletRequest;
import java.io.CharConversionException; import java.io.CharConversionException;
import java.io.IOException; import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
@ -52,9 +54,6 @@ public class Gruppen2Controller {
private final InviteLinkRepositoryService inviteLinkRepositoryService; private final InviteLinkRepositoryService inviteLinkRepositoryService;
private final Gruppen2Config gruppen2Config; private final Gruppen2Config gruppen2Config;
private final Logger logger; private final Logger logger;
private final Logger logger;
private final String serverURL = "localhost:8080";
public Gruppen2Controller(KeyCloakService keyCloakService, GroupService groupService, UserService userService, ControllerService controllerService, InviteLinkRepositoryService inviteLinkRepositoryService, Gruppen2Config gruppen2Config) { public Gruppen2Controller(KeyCloakService keyCloakService, GroupService groupService, UserService userService, ControllerService controllerService, InviteLinkRepositoryService inviteLinkRepositoryService, Gruppen2Config gruppen2Config) {
this.keyCloakService = keyCloakService; this.keyCloakService = keyCloakService;
@ -62,7 +61,6 @@ public class Gruppen2Controller {
this.userService = userService; this.userService = userService;
this.controllerService = controllerService; this.controllerService = controllerService;
this.inviteLinkRepositoryService = inviteLinkRepositoryService; this.inviteLinkRepositoryService = inviteLinkRepositoryService;
logger = Logger.getLogger("Gruppen2ControllerLogger");
this.gruppen2Config = gruppen2Config; this.gruppen2Config = gruppen2Config;
this.logger = Logger.getLogger("gruppen2ControllerLogger"); this.logger = Logger.getLogger("gruppen2ControllerLogger");
} }
@ -197,7 +195,7 @@ public class Gruppen2Controller {
@RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"}) @RolesAllowed({"ROLE_orga", "ROLE_studentin", "ROLE_actuator)"})
@GetMapping("/details/{id}") @GetMapping("/details/{id}")
public String showGroupDetails(KeycloakAuthenticationToken token, Model model, @PathVariable("id") Long groupId) throws EventException { public String showGroupDetails(KeycloakAuthenticationToken token, Model model, HttpServletRequest request, @PathVariable("id") Long groupId) throws EventException {
model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token)); model.addAttribute("account", keyCloakService.createAccountFromPrincipal(token));
Group group = userService.getGroupById(groupId); Group group = userService.getGroupById(groupId);
Account account = keyCloakService.createAccountFromPrincipal(token); Account account = keyCloakService.createAccountFromPrincipal(token);
@ -230,26 +228,11 @@ public class Gruppen2Controller {
model.addAttribute("user", user); model.addAttribute("user", user);
model.addAttribute("admin", Role.ADMIN); model.addAttribute("admin", Role.ADMIN);
String link = serverURL + "/gruppen2/acceptinvite/" + inviteLinkRepositoryService.findlinkByGroupId(group.getId()); String link = inviteLinkRepositoryService.findlinkByGroupId(group.getId());
model.addAttribute("link", link); String URL = request.getRequestURL().toString();
String serverURL = URL.substring(0, URL.indexOf("gruppen2/"));
String port =""; model.addAttribute("link", serverURL + "gruppen2/acceptinvite/" + link);
String serverAd="";
try {
port = environment.getProperty("server.port");
serverAd= InetAddress.getLoopbackAddress().getHostAddress();
} catch (Exception e) {
logger.warning("Could not find server-address");
}
if (port.isEmpty()){
logger.warning("Serverport missing in application.properties");
}
// hässlicher hardcode
serverAd = "localhost";
String serverAddresse = serverAd + ":" + port;
model.addAttribute("serverAddress", serverAddresse);
return "detailsMember"; return "detailsMember";
} }

View File

@ -43,12 +43,11 @@
<span class="badge badge-pill badge-info" style="background: mediumorchid" <span class="badge badge-pill badge-info" style="background: mediumorchid"
th:text="${parent.getTitle()}">Parent</span> th:text="${parent.getTitle()}">Parent</span>
Click <a th:href="@{'/gruppen2/acceptinvite/' + ${link}}">view</a> to go to yahoo.
<div class="input-group mb-3" style="margin-top: 10px" th:if="${group.getVisibility() == group.getVisibility().PRIVATE}"> <div class="input-group mb-3" style="margin-top: 10px" th:if="${group.getVisibility() == group.getVisibility().PRIVATE}">
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text" id="inputGroup-sizing-default" style="background: #52a1eb">Einladungslink:</span> <span class="input-group-text" id="inputGroup-sizing-default" style="background: #52a1eb">Einladungslink:</span>
</div> </div>
<input type="text" class="form-control" th:value="|${serverAddress}/gruppen2/acceptinvite/${link}|" <input type="text" class="form-control" th:value="${link}"
aria-label="Recipient's username" aria-describedby="basic-addon2" id="groupLink" style="background: white" readonly> aria-label="Recipient's username" aria-describedby="basic-addon2" id="groupLink" style="background: white" readonly>
<div class="input-group-append"> <div class="input-group-append">
<button class="btn btn-outline-secondary" type="button" onclick="copyLink()">Link kopieren</button> <button class="btn btn-outline-secondary" type="button" onclick="copyLink()">Link kopieren</button>