Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
- Spring Boot Test
- Spring Boot Starter Test
- Spring Boot Test Autoconfigure
- JUnit 5

## Basic setup

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package com.csaba79coder.littersnap;

import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class LitterSnapApplication {
public class LitterSnapApplication implements ApplicationRunner {

public static void main(String[] args) {
SpringApplication.run(LitterSnapApplication.class, args);
}

@Override
public void run(ApplicationArguments args) throws Exception {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
Expand All @@ -38,6 +39,7 @@ public List<UserModel> findAllUsers() {
return userRepository.findAll()
.stream()
.map(Mapper::mapUserEntityToModel)
.sorted(Comparator.comparing(UserModel::getFirstName))
.collect(Collectors.toList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.csaba79coder.littersnap.model.user.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
Expand All @@ -11,4 +13,10 @@
public class UserViewController {

private final UserService userService;

@GetMapping
public String renderAllUsers(Model model) {
model.addAttribute("users", userService.findAllUsers());
return "user";
}
}
6 changes: 5 additions & 1 deletion src/main/resources/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,9 @@ body {
/* }*/
/*}*/


caption {
caption-side: top;
text-align: center;
color: green;
}

99 changes: 99 additions & 0 deletions src/main/resources/templates/user.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous">

<!-- Font Awesome CSS -->
<link rel='stylesheet' href='https://use.fontawesome.com/releases/v5.3.1/css/all.css'>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
<!-- Include jQuery from Google CDN -->
<link rel="stylesheet" th:href="@{/style.css}">
<link th:src="@{/script.js}">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/css/bootstrap.min.css">

<title>Litter Snap Users</title>
</head>

<body>
<div class="background-overlay"></div>
<div class="container mt-4 bg-white">
<div class="row">
<div class="col">
<div class="table-responsive"> <!--style="overflow: hidden;"-->
<div class="table table-striped">
<table id="users" class="table">
<caption> Users of LitterSnap </caption>
<!-- Table content -->
<thead>
<tr>
<th> Id </th>
<th> Created At </th>
<th> Created By </th>
<th> Updated At </th>
<th> Updated By </th>
<th> Firstname </th>
<th> Email </th>
<th> Role </th>
</tr>
</thead>
<tbody>
<tr th:if="${users.isEmpty()}">
<td colspan="4"> No Users Available </td>
</tr>
<tr th:each="user : ${users}">
<td><span th:text="${user.getId()}"> Id </span></td>
<td><span th:text="${user.getCreatedAt()}"> Created At </span></td>
<td><span th:text="${user.getCreatedBy()}"> Created By </span></td>
<td><span th:text="${user.getUpdatedAt()}"> Updated At </span></td>
<td><span th:text="${user.getUpdatedBy()}"> Updated By </span></td>
<td><span th:text="${user.getFirstName()}"> Firstname </span></td>
<td><span th:text="${user.getEmail()}"> Email </span></td>
<td><span th:text="${user.getRole()}"> Role </span></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>

<div class="row justify-content-center align-items-center min-vh-100">
<div class="col-12 col-md-8 col-lg-6">

<div class="container logo-and-slogan-container">
<div class="row ">
<div class="col-5 col-md-5 col-lg-5">
<img th:src="@{/images/ManAndPhone.png}" alt="Image" class="man-with-the-phone-icon">
</div>
</div>
</div>

<input type="text" class="form-control" id="city" name="city" placeholder="Search ..."
required>
</div>
</div>

<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.7/dist/umd/popper.min.js"
integrity="sha384-zYPOMqeu1DAVkHiLqWBUTcbYfZ8osu1Nd6Z89ify25QV9guujx43ITvfi12/QExE"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.min.js"
integrity="sha384-Y4oOpwW3duJdCWv5ly8SCFYWqFDsfob/3GkgExXKV4idmbt98QcxXYs9UoXAB7BZ"
crossorigin="anonymous"></script>

<div class="footer-overlay">
<footer>
<div class="container-fluid">
<p>&copy; 2023 Vasile, Csaba and Kevin. Wiley Edge. All rights reserved.</p>
</div>
</footer>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>