From 07765b83674542fd10ba85c236e9b31382ee679c Mon Sep 17 00:00:00 2001 From: Sebastiaan de Schaetzen Date: Sat, 7 Jun 2025 08:47:53 +0200 Subject: [PATCH] Working on fragments --- .../pcinv/controllers/WebController.java | 11 +++++++++-- src/main/resources/templates/fragments.html | 13 +++++++++++++ src/main/resources/templates/index.html | 14 +++++--------- 3 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 src/main/resources/templates/fragments.html diff --git a/src/main/java/be/seeseepuff/pcinv/controllers/WebController.java b/src/main/java/be/seeseepuff/pcinv/controllers/WebController.java index 7c6d0df..caf9de1 100644 --- a/src/main/java/be/seeseepuff/pcinv/controllers/WebController.java +++ b/src/main/java/be/seeseepuff/pcinv/controllers/WebController.java @@ -1,12 +1,19 @@ package be.seeseepuff.pcinv.controllers; +import be.seeseepuff.pcinv.services.AssetService; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +@RequiredArgsConstructor @Controller public class WebController { + private final AssetService assetService; + @GetMapping("/") - public String index() { - return "index"; // This will resolve to src/main/resources/templates/index.html + public String index(Model model) { + model.addAttribute("asset_count", assetService.countAssets()); + return "index"; } } diff --git a/src/main/resources/templates/fragments.html b/src/main/resources/templates/fragments.html new file mode 100644 index 0000000..4ca2c16 --- /dev/null +++ b/src/main/resources/templates/fragments.html @@ -0,0 +1,13 @@ + + + + + PC Inventory + + +

PC Inventory -

+
+
+
+ + diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index a4ee839..f528dd7 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -1,9 +1,5 @@ - - - - PC Inventory - - -

Hello, world!

- - +
+
+

This system holds 5 assets.

+
+