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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ public ResponseEntity<Void> deleteExistingLitter(@PathVariable("id") UUID id) {

return ResponseEntity.status(204).build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@
import com.csaba79coder.littersnap.util.Mapper;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
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.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Base64;
Expand Down Expand Up @@ -71,25 +66,23 @@ public String getLitterById(@PathVariable("id") UUID id, Model model) {
}

@GetMapping("/create")
public String showAddLitterForm(Model model) {
public String showAddLitterForm(Model model, @RequestParam(value = "city", required = false) String capturedCity) {
try {
LitterCreateOrModifyModel litterModel = new LitterCreateOrModifyModel();

// Set any other necessary properties in the litterModel object

model.addAttribute("city", capturedCity);
model.addAttribute("litter", litterModel);
return "litter_add_form";
model.addAttribute("view","litter_add_form");
return "welcome";
} catch (NoSuchElementException e) {
model.addAttribute("errorMessage", e.getMessage());
return "error_page"; // Redirect to the error page to display the error message
}
}

@PostMapping("/create")
public String addNewLitter(@ModelAttribute("litter") LitterCreateOrModifyModel litterModel,
@ModelAttribute("address") Address address,
@RequestParam("file") MultipartFile file,
Model model) {
public String addNewLitter(@ModelAttribute("litter") LitterCreateOrModifyModel litterModel, @ModelAttribute("address") Address address, @RequestParam("file") MultipartFile file, Model model) {
try {
litterService.addNewLitter(litterModel, address, file);
return "redirect:/thy/litter";
Expand All @@ -110,7 +103,7 @@ public String showEditForm(@PathVariable UUID id, Model model) {
model.addAttribute("postcode", litter.getAddress().getPostCode());
model.addAttribute("description", litter.getDescription());
model.addAttribute("image", litter.getImage());
model.addAttribute("view","litter_edit_form");
model.addAttribute("view", "litter_edit_form");
return "welcome";
} catch (NoSuchElementException e) {
model.addAttribute("errorMessage", e.getMessage());
Expand All @@ -131,7 +124,7 @@ public String updateLitter(@PathVariable UUID id, @ModelAttribute("report") Litt


@GetMapping("/delete/{id}")
public String deleteLitter(@PathVariable UUID id,Model model) {
public String deleteLitter(@PathVariable UUID id, Model model) {

try {
litterService.deleteLitter(id);
Expand All @@ -144,5 +137,4 @@ public String deleteLitter(@PathVariable UUID id,Model model) {
}



}
40 changes: 40 additions & 0 deletions src/main/resources/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,46 @@ body {
z-index: 999;
}

/*Image redendering size controll*/
.image-container {
max-width: 350px; /* Set the maximum width for the image container */
margin: auto; /* Center the container horizontally */
cursor: pointer; /* Show the pointer cursor when hovering */
}

.image-container img {
width: 100%; /* Make the image fill the container */
height: auto; /* Maintain aspect ratio */
transition: transform 0.3s; /* Add a smooth transition effect */
}

.image-container img:hover {
transform: scale(1.2); /* Scale the image to 120% on hover */
}

/*NavBar style*/
.navbar {
background-color: #f8f9fa;
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
}

.navbar-brand {
font-size: 1.5rem;
font-weight: bold;
color: #333;
}

.navbar-nav .nav-link {
font-size: 1.1rem;
color: #333;
transition: color 0.3s;
}

.navbar-nav .nav-link:hover {
color: #007bff;
}

/*Logo Style*/
.logo-and-slogan-container {
position: relative;
}
Expand Down
81 changes: 36 additions & 45 deletions src/main/resources/templates/litter_add_form.html
Original file line number Diff line number Diff line change
@@ -1,49 +1,40 @@
<div class="modal fade" id="addLitterModal" tabindex="-1" aria-labelledby="addLitterModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal header -->
<div class="modal-header">
<h5 class="modal-title" id="addLitterModalLabel">Add Litter</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>

<!-- Modal body -->
<div class="modal-body">
<div class="d-flex justify-content-center">
<div class="add-litter-container">
<form th:action="@{/thy/litter/create}" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="firstLine">First Line</label>
<input type="text" class="form-control" id="firstLine" name="firstLine" required>
</div>
<div class="form-group">
<label for="postCode">Post Code</label>
<input type="text" class="form-control" id="postCode" name="postCode" required>
</div>
<div class="form-group">
<label for="city">City</label>
<input type="text" class="form-control" id="city" name="city" required>
</div>
<div class="form-group">
<label for="country">Country</label>
<input type="text" class="form-control" id="country" name="country" required>
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea class="form-control" id="description" name="description"
required></textarea>
</div>
<div class="form-group mt-3">
<label for="file">Photo</label>
<input type="file" class="form-control-file" id="file" name="file" accept="image/*"
required>
</div>

<button type="submit" class="btn btn-primary mt-3">Submit</button>
</form>
<div class="container mt-4 bg-white">
<div class="row">
<div class="col">
<div class="d-flex justify-content-center">
<div class="add-litter-container">
<form th:action="@{/thy/litter/create}" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="firstLine">First Line</label>
<input type="text" class="form-control" id="firstLine" name="firstLine" required>
</div>
<div class="form-group">
<label for="postCode">Post Code</label>
<input type="text" class="form-control" id="postCode" name="postCode" required>
</div>
<div class="form-group">
<label for="city">City</label>
<input type="text" class="form-control" id="city" name="city" th:value="${city}" required>
</div>
</div>
<div class="form-group">
<label for="country">Country</label>
<input type="text" class="form-control" id="country" name="country" required>
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea class="form-control" id="description" name="description"
required></textarea>
</div>
<div class="form-group mt-3">
<label for="file">Photo</label>
<input type="file" class="form-control-file" id="file" name="file" accept="image/*"
required>
</div>

<button type="submit" class="btn btn-primary mt-3">Submit</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
12 changes: 11 additions & 1 deletion src/main/resources/templates/litter_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ <h4><span class="text-muted">Description:</span></h4>
<p><span th:text="${description}"></span></p>

<h4><span class="text-muted">Image:</span></h4>
<img th:src="@{'data:image/png;base64,' + ${image}}" alt="Litter Image" />
<div class="image-container" onclick="expandImage()">
<img th:src="@{'data:image/png;base64,' + ${image}}" alt="Litter Image" />
</div>


<h4><span class="text-muted">Status:</span></h4>
<p><span th:text="${status}"></span></p>
Expand All @@ -35,4 +38,11 @@ <h4><span class="text-muted">Status:</span></h4>

</div>

<script>
function expandImage() {
var img = document.querySelector('.image-container img');
img.style.transform = img.style.transform === 'scale(1.2)' ? 'none' : 'scale(1.2)';
}
</script>


99 changes: 73 additions & 26 deletions src/main/resources/templates/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,49 +22,97 @@

<div class="background-overlay"></div>
<div class="container-fluid">
<!-- Button to trigger the modal -->
<div class="row justify-content-end m-3">
<div class="btn-group col-12 col-md-4 col-lg-2 fixed-buttons">
<div class="d-flex justify-content-end align-items-center">
<div class="me-2">Welcome, <span th:text="Csaba"></span></div>
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton"
data-bs-toggle="dropdown" aria-expanded="false">
<i class="fas fa-bars"></i>
</button>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="dropdownMenuButton">
<li><a class="dropdown-item" href="#">Logout</a></li>
<li><a class="dropdown-item" th:href="@{/thy/litter}">View Reports</a></li>
</ul>
</div>

<nav class="navbar sticky-top navbar-expand-lg bg-body-tertiary">
<div class="container-fluid">
<a class="navbar-brand" style=" color:#1c5485;" th:href="@{/thy/litter}">LitterSnap</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<div class="me-2">Welcome, <span style=" color:green; font-weight: bold" th:text="Csaba"></span></div>
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" th:href="@{/thy/litter}">View Reports</a>
</li>
<li class="nav-item">
<a class="nav-link active" th:href="@{/thy/users}">View Users</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" th:href="@{/}">Logout</a>
</li>

</ul>

<form th:action="@{/thy/litter/create}" method="get" class="d-flex">
<div class="form-group flex-grow-1">
<input type="text" class="form-control" id="cityInput" name="city"
placeholder="Enter the city..." required>
</div>
<button type="submit" class="btn btn-primary btn-sm-md">Add Litter</button>
</form>
</div>
</div>
</div>
</nav>

<button class="btn btn-primary btn-sm btn-block ml-20" data-bs-toggle="modal" data-bs-target="#addLitterModal">
Add Litter
</button>
<a th:href="@{/thy/users}" class="btn btn-success btn-sm">User List</a>


<div th:replace="~{litter_add_form}"></div>


<div class="container mt-4 bg-white">


<!-- Hamburger button-->
<!-- <div class="row justify-content-end m-3">-->
<!-- <div class="btn-group col-12 col-md-4 col-lg-2 fixed-buttons">-->
<!-- <div class="d-flex align-items-center">-->
<!-- <div class="me-2">Welcome, <span th:text="Csaba"></span></div>-->
<!-- <div class="dropdown">-->
<!-- <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton"-->
<!-- data-bs-toggle="dropdown" aria-expanded="false">-->
<!-- <i class="fas fa-bars"></i>-->
<!-- </button>-->
<!-- <ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">-->
<!-- <li><a class="dropdown-item" >Logout</a></li>-->
<!-- <li><a class="dropdown-item" th:href="@{/thy/litter}">View Reports</a></li>-->
<!-- <li><a class="dropdown-item" th:href="@{/thy/users}">User List</a></li>-->
<!-- </ul>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->




<!--Getting the input and populating the addlitter-->
<!-- <div class="row justify-content-center mt-10">-->
<!-- <div class="col-12 col-md-7 col-lg-6">-->
<!-- <form th:action="@{/thy/litter/create}" method="get" class="d-flex">-->
<!-- <div class="form-group flex-grow-1">-->
<!-- <input type="text" class="form-control" id="cityInput" name="city"-->
<!-- placeholder="Enter the city..." required>-->
<!-- </div>-->
<!-- <button type="submit" class="btn btn-primary btn-sm-md">Add Litter</button>-->
<!-- </form>-->
<!-- </div>-->
<!-- </div>-->


<!-- Container for dynamic content -->
<div class="container mt-4 bg-white">
<div class="row">
<div class="col">

<!-- Dynamic content placeholder -->
<div th:if="~{${view}}" class="row m-4">
<div class="col">
<!-- Dynamic Content Placeholder -->
<div th:insert="~{${view}}"></div>

</div>
</div>
</div>
</div>
</div>

<!-- Middle Part -->
<div class="row d-flex align-items-end justify-content-end min-vh-100">
<div class="col-12 col-md-8 col-lg-6">
Expand All @@ -82,8 +130,6 @@
</div>
</div>
</div>


</div>


Expand All @@ -94,6 +140,7 @@
integrity="sha384-Y4oOpwW3duJdCWv5ly8SCFYWqFDsfob/3GkgExXKV4idmbt98QcxXYs9UoXAB7BZ"
crossorigin="anonymous"></script>


<div class="footer-overlay">
<footer>
<div class="container-fluid">
Expand Down