Skip to content

Commit

Permalink
add view tag info page and the endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
ZDenizYStenhaug committed Jan 11, 2022
1 parent 6b2c971 commit cb26733
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
import org.springframework.web.bind.annotation.GetMapping;
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.servlet.config.annotation.WebMvcConfigurer;

import javax.validation.Valid;
import java.io.IOException;

@Controller
@RequestMapping(Routing.ROOT_TAG)
Expand Down Expand Up @@ -71,4 +73,19 @@ public String allTags(Model model) {
}
return "tags";
}

@PostMapping(Routing.URI_VIEW)
public String viewMoreInfoAboutTag(Model model,
@RequestParam("tagName") String name) throws IOException {
Tag tag = tagService.findByName(name);
String extract = tagService.getMoreInformationAboutTag(tag);
model.addAttribute("tag", tag);
model.addAttribute("extract", extract);
String username = memberService.getCurrentUserLogin();
if(!username.equals("anonymousUser")) {
Member member = memberService.findByUsername(username);
model.addAttribute("messageCount", String.valueOf(messageService.checkForUnreadMessage(member)));
}
return "view-tag-info";
}
}
19 changes: 19 additions & 0 deletions src/main/resources/templates/view-offer.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@
</form>
</li>
</ul>
<h4>Tags:</h4>
<table class="table table-borderless">
<thead>
<tr>
<th scope="col">name</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr th:each="tag: ${offer.offerTags}">
<td><span th:text="${tag.name}"></span> </td>
<td>
<form method="POST" th:action="@{/tag/view(tagName=${tag.name})}">
<button type="submit" name="submit" value="value" class="btn btn-sm btn-outline-info">Show more information</button>
</form>
</td>
</tr>
</tbody>
</table>
<div style="margin-bottom: 30px">
<div th:fragment="shop_map" >
<!--Div element to display map-->
Expand Down
42 changes: 42 additions & 0 deletions src/main/resources/templates/view-tag-info.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
xmlns:sec="https://www.thymeleaf.org/thymeleaf-extras-springsecurity5"
lang="en"><head>
<head>
<meta charset="UTF-8">
<!-- Bootstrap core CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

<title>Manage Offer</title>
</head>
<body>


<header class="p-3 bg-dark text-white">
<div class="container">
<div class="d-flex flex-wrap align-items-center justify-content-center justify-content-lg-start">
<ul class="nav col-12 col-lg-auto me-lg-auto mb-2 justify-content-center mb-md-0">
<li class="nav-link navbar-brand">AKITA</li>
<li><a href="/offer/all" class="nav-link px-2 text-white">Offers</a></li>
<li><a href="/event/all" class="nav-link px-2 text-white">Events</a></li>
<li><a href="/tag/all" class="nav-link px-2 text-white">Tags</a></li>
</ul>

<div class="text-end" sec:authorize="isAnonymous()">
<a href="/member/login" align="right" class="btn btn-outline-light me-2" role="button" aria-pressed="true">Login</a>
<a href="/member/registration" align="right" class="btn btn-warning" role="button" aria-pressed="true">Sign-up</a>
</div>

<div class="text-end" sec:authorize="isAuthenticated()">
<a href="/message/all/" class="btn btn-outline-light me-2" role="button" aria-pressed="true">Messages (<span th:text="${messageCount}">messageCount</span>)</a>

<a href="/member/profile" align="right" class="btn btn-outline-light me-2" role="button" aria-pressed="true">Go to profile</a>
<a href="/member/logout" align="right" class="btn btn-warning" role="button" aria-pressed="true">Logout</a>
</div>
</div>
</div>
</header>
<h3>Tag: <span th:text="${tag.name}"></span></h3>
<p><span th:text="${extract}"></span></p>
</body>
</html>

0 comments on commit cb26733

Please sign in to comment.