This commit is contained in:
@@ -1,12 +1,19 @@
|
|||||||
package be.seeseepuff.pcinv.controllers;
|
package be.seeseepuff.pcinv.controllers;
|
||||||
|
|
||||||
|
import be.seeseepuff.pcinv.services.AssetService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Controller
|
@Controller
|
||||||
public class WebController {
|
public class WebController {
|
||||||
|
private final AssetService assetService;
|
||||||
|
|
||||||
@GetMapping("/")
|
@GetMapping("/")
|
||||||
public String index() {
|
public String index(Model model) {
|
||||||
return "index"; // This will resolve to src/main/resources/templates/index.html
|
model.addAttribute("asset_count", assetService.countAssets());
|
||||||
|
return "index";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
13
src/main/resources/templates/fragments.html
Normal file
13
src/main/resources/templates/fragments.html
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:fragment="base(title, content)">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>PC Inventory</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>PC Inventory - <span th:text="${title}"></span></h1>
|
||||||
|
<hr>
|
||||||
|
<div th:replace="${content}">
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
<html>
|
<div th:replace="fragments :: base(title='Home', content=~{::content})">
|
||||||
<head>
|
<div th:fragment="content">
|
||||||
<meta charset="UTF-8">
|
<p>This system holds <span th:text="${asset_count}">5</span> assets.</p>
|
||||||
<title>PC Inventory</title>
|
</div>
|
||||||
</head>
|
</div>
|
||||||
<body>
|
|
||||||
<h1>Hello, world!</h1>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user