Skip to content

Commit 74bae5b

Browse files
committed
bug-images fixed
1 parent f8d7270 commit 74bae5b

File tree

6 files changed

+168
-111
lines changed

6 files changed

+168
-111
lines changed

src/main/java/com/csaba79coder/littersnap/model/litter/service/LitterService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public LitterModel addNewLitter(LitterCreateOrModifyModel litterModel, Address a
5050
litterEntity.setAddress(address); //TODO set an incoming address also here! if address is not found in entiy new must be created
5151
litterEntity.setDescription(litterModel.getDescription());
5252
try {
53-
litterEntity.setImage(ImageUtil.decompressImage(file.getBytes())); // saving to database, so decompressing!!!
53+
litterEntity.setImage(ImageUtil.compressImage(file.getBytes())); // Compressing the image before saving
5454
} catch (IOException e) {
5555
throw new RuntimeException(e);
5656
}

src/main/resources/templates/add_litter_form.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ <h5 class="modal-title" id="addLitterModalLabel">Add Litter</h5>
3333
<textarea class="form-control" id="description" name="description" required></textarea>
3434
</div>
3535
<div class="form-group mt-3">
36-
<label for="image">Photo</label>
37-
<input type="file" class="form-control-file" id="image" name="image" accept="image/*"
36+
<label for="file">Photo</label>
37+
<input type="file" class="form-control-file" id="file" name="file" accept="image/*"
3838
required>
3939
</div>
4040

Lines changed: 56 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,60 @@
1-
<div class="d-flex justify-content-center">
2-
<div class="add-litter-container">
3-
<!-- Modal content -->
4-
<form th:action="@{/thy/litter/create}" method="post" enctype="multipart/form-data">
5-
<div class="form-group">
6-
<label for="firstLine">First Line:</label>
7-
<br>
8-
<input type="text" class="form-control" id="firstLine" name="firstLine" required th:value="${litter.getAddress().firstLine}">
9-
</div>
10-
<div class="form-group">
11-
<label for="postCode">Post Code:</label>
12-
<br>
13-
<input type="text" class="form-control" id="postCode" name="postCode" required th:value="${litter.getAddress().postCode}">
14-
</div>
15-
<div class="form-group">
16-
<label for="city">City:</label>
17-
<br>
18-
<input type="text" class="form-control" id="city" name="city" required th:value="${litter.getAddress().city}">
19-
</div>
20-
<div class="form-group">
21-
<label for="country">Country:</label>
22-
<br>
23-
<input type="text" class="form-control" id="country" name="country" required th:value="${litter.getAddress().country}">
24-
</div>
25-
<div class="form-group">
26-
<label for="description">Description:</label>
27-
<br>
28-
<textarea class="form-control" id="description" name="description" required>${litter.description}</textarea>
29-
</div>
30-
<div class="form-group mt-3">
31-
<label for="image">Image:</label>
32-
<br>
33-
<input type="file" class="form-control-file mt-3" id="image" name="image" accept="image/*" required>
1+
<div class="modal fade" id="editLitterModal" tabindex="-1" aria-labelledby="addLitterModalLabel" aria-hidden="true">
2+
<div class="modal-dialog">
3+
<div class="modal-content">
4+
<!-- Modal header -->
5+
<div class="modal-header">
6+
<h5 class="modal-title" id="addLitterModalLabel">Edit Litter</h5>
7+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
348
</div>
359

36-
<button type="submit" class="btn btn-primary mt-3">Submit</button>
37-
</form>
10+
<!-- Modal body -->
11+
<div class="modal-body">
12+
<div class="d-flex justify-content-center">
13+
<div class="add-litter-container">
14+
<!-- <form th:action="@{thy/litter/edit/{id}(id=${litter})}" method="post"-->
15+
<!-- enctype="multipart/form-data">-->
16+
<!-- <div class="form-group">-->
17+
<!-- <label for="firstLine">First Line:</label>-->
18+
<!-- <br>-->
19+
<!-- <input type="text" class="form-control" id="firstLine" name="firstLine" required-->
20+
<!-- th:value="${litter != null ? litter.getAddress().firstLine : ''}">-->
21+
<!-- </div>-->
22+
<!-- <div class="form-group">-->
23+
<!-- <label for="postCode">Post Code:</label>-->
24+
<!-- <br>-->
25+
<!-- <input type="text" class="form-control" id="postCode" name="postCode" required-->
26+
<!-- th:value="${litter != null ? litter.getAddress().postCode : ''}">-->
27+
<!-- </div>-->
28+
<!-- <div class="form-group">-->
29+
<!-- <label for="city">City:</label>-->
30+
<!-- <br>-->
31+
<!-- <input type="text" class="form-control" id="city" name="city" required-->
32+
<!-- th:value="${litter != null ? litter.getAddress().city : ''}">-->
33+
<!-- </div>-->
34+
<!-- <div class="form-group">-->
35+
<!-- <label for="country">Country:</label>-->
36+
<!-- <br>-->
37+
<!-- <input type="text" class="form-control" id="country" name="country" required-->
38+
<!-- th:value="${litter != null ? litter.getAddress().country : ''}">-->
39+
<!-- </div>-->
40+
<!-- <div class="form-group">-->
41+
<!-- <label for="description">Description:</label>-->
42+
<!-- <br>-->
43+
<!-- <textarea class="form-control" id="description" name="description" required>${litter != null ? litter.description : ''}</textarea>-->
44+
<!-- </div>-->
45+
<!-- <div class="form-group mt-3">-->
46+
<!-- <label for="image">Image:</label>-->
47+
<!-- <br>-->
48+
<!-- <input type="file" class="form-control-file mt-3" id="image" name="image"-->
49+
<!-- accept="image/*" required>-->
50+
<!-- </div>-->
51+
52+
<!-- <button type="submit" class="btn btn-primary mt-3">Submit</button>-->
53+
<!-- </form>-->
54+
55+
</div>
56+
</div>
57+
</div>
58+
</div>
3859
</div>
3960
</div>

src/main/resources/templates/index.html

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,33 @@
2424
<div class="container-fluid">
2525
<div class="row justify-content-end m-3">
2626
<div class="btn-group col-12 col-md-4 col-lg-2 fixed-buttons">
27-
<button class="btn btn-success btn-sm btn-block m-1" data-bs-toggle="modal"
28-
data-bs-target="#addLitterModal">LogIn
29-
</button>
27+
<!-- <button class="btn btn-success btn-sm btn-block m-1" data-bs-toggle="modal"-->
28+
<!-- data-bs-target="#addLitterModal">LogIn-->
29+
<!-- </button>-->
3030
<button class="btn btn-warning btn-sm btn-block m-1">
3131
SignUp
3232
</button>
3333
</div>
3434
</div>
35+
<button class="btn btn-primary btn-sm btn-block m-1" data-bs-toggle="modal" data-bs-target="#addLitterModal">
36+
TestAddButton
37+
</button>
38+
<button class="btn btn-warning btn-sm btn-block m-1" data-bs-toggle="modal" data-bs-target="#editLitterModal">
39+
TestEditButton
40+
</button>
41+
<button class="btn btn-secondary btn-sm btn-block m-1" data-bs-toggle="modal" data-bs-target="#showLitterListModal">
42+
Test Show List Modal
43+
</button>
44+
45+
<button class="btn btn-danger btn-sm btn-block m-1" data-bs-toggle="modal" data-bs-target="#showLitterDetailsModal">
46+
Test Litter Details
47+
</button>
3548

3649
<div th:replace="add_litter_form"></div>
50+
<div th:replace="edit_litter"></div>
51+
<div th:replace="litter_list"></div>
52+
<div th:replace="litter_details"></div>
53+
3754
<!-- Middle Part -->
3855
<div class="row justify-content-center align-items-center min-vh-100">
3956
<div class="col-12 col-md-8 col-lg-6">
Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,45 @@
1-
<div class="container">
2-
<!-- Content for the litter details page -->
3-
<div class="row">
4-
<div class="col-md-6 offset-md-3">
5-
<h1 class = "text-center">Litter Details</h1>
6-
<hr>
7-
<h4><span class="text-muted">Created At:</span></h4>
8-
<p><span th:text="${litter.getCreatedAt()}"></span></p>
9-
10-
<h4><span class="text-muted">Created By:</span></h4>
11-
<p><span th:text="${litter.getCreatedBy()}"></span></p>
12-
13-
<h4><span class="text-muted">Updated At:</span></h4>
14-
<p><span th:text="${litter.getUpdatedAt()}"></span></p>
15-
16-
<h4><span class="text-muted">Updated By:</span></h4>
17-
<p><span th:text="${litter.getUpdatedBy()}"></span></p>
18-
19-
<h4><span class="text-muted">Address:</span></h4>
20-
<p><span th:text="${litter.getAddress().firstLine + ', ' +
21-
litter.getAddress().postCode + ', ' +
22-
litter.getAddress().city + ', ' +
23-
litter.getAddress().country}"></span></p>
24-
25-
<h4><span class="text-muted">Description:</span></h4>
26-
<p><span th:text="${litter.getDescription()}"></span></p>
27-
28-
<h4><span class="text-muted">Image:</span></h4>
29-
<p><span th:text="${litter.getImage()}"></span></p>
30-
31-
<a href="#" onclick="window.location.href='/thy/litter'"
32-
class="btn btn-primary mt-3">Back</a>
1+
<div class="modal fade" id="showLitterDetailsModal" tabindex="-1" aria-labelledby="addLitterModalLabel" aria-hidden="true">
2+
<div class="modal-dialog">
3+
<div class="modal-content">
4+
<!-- Modal header -->
5+
<div class="modal-header">
6+
<h5 class="modal-title" id="addLitterModalLabel">Litter Details</h5>
7+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
8+
</div>
9+
10+
<!-- Modal body -->
11+
<div class="row">
12+
<div class="col-md-6 offset-md-3">
13+
<h1 class = "text-center">Litter Details</h1>
14+
<hr>
15+
<!-- <h4><span class="text-muted">Created At:</span></h4>-->
16+
<!-- <p><span th:text="${litter.getCreatedAt()}"></span></p>-->
17+
18+
<!-- <h4><span class="text-muted">Created By:</span></h4>-->
19+
<!-- <p><span th:text="${litter.getCreatedBy()}"></span></p>-->
20+
21+
<!-- <h4><span class="text-muted">Updated At:</span></h4>-->
22+
<!-- <p><span th:text="${litter.getUpdatedAt()}"></span></p>-->
23+
24+
<!-- <h4><span class="text-muted">Updated By:</span></h4>-->
25+
<!-- <p><span th:text="${litter.getUpdatedBy()}"></span></p>-->
26+
27+
<!-- <h4><span class="text-muted">Address:</span></h4>-->
28+
<!-- <p><span th:text="${litter.getAddress().firstLine + ', ' +-->
29+
<!-- litter.getAddress().postCode + ', ' +-->
30+
<!-- litter.getAddress().city + ', ' +-->
31+
<!-- litter.getAddress().country}"></span></p>-->
32+
33+
<!-- <h4><span class="text-muted">Description:</span></h4>-->
34+
<!-- <p><span th:text="${litter.getDescription()}"></span></p>-->
35+
36+
<!-- <h4><span class="text-muted">Image:</span></h4>-->
37+
<!-- <p><span th:text="${litter.getImage()}"></span></p>-->
38+
39+
<a href="#" onclick="window.location.href='/thy/litter'"
40+
class="btn btn-primary mt-3">Back</a>
41+
</div>
42+
</div>
3343
</div>
3444
</div>
3545
</div>
Lines changed: 47 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,51 @@
1-
<div class="container">
2-
<div class="row m-4 border border-dark">
3-
<div class="col text-center m-3">
4-
<table class="table table-striped">
5-
<thead>
6-
<tr>
7-
<th>Date</th>
8-
<th>By</th>
9-
<th>Address</th>
10-
<th>PostCode</th>
11-
<th>Status</th>
12-
<th>Action</th>
13-
</tr>
14-
</thead>
15-
<tbody>
16-
<div th:if="${not #lists.isEmpty(litters)}">
17-
<tr th:each="litter : ${litters}">
18-
<td th:text="${litter.getCreatedAt()}"></td>
19-
<td th:text="${litter.getCreatedBy()}"></td>
20-
<td th:text="${litter.getAddress().firstLine}"></td>
21-
<td th:text="${litter.getAddress().postCode}"></td>
22-
<td th:text="${litter.getStatus()}"></td>
23-
<td>
24-
<div class="btn-group col-12 col-md-4 col-lg-2">
25-
<a th:href="@{/thy/litter/{id}(id=${litter.id})}"
26-
class="btn btn-success btn-sm btn-block m-1">View</a>
27-
<a th:href="@{/thy/litter/edit/{id}(id=${litter.id})}"
28-
class="btn btn-warning btn-sm btn-block m-1">Edit</a>
29-
<a th:href="@{/thy/litter/delete(id=${litter.id})}"
30-
class="btn btn-danger btn-sm btn-block m-1">Delete</a>
31-
</div>
32-
</td>
1+
<div class="modal fade" id="showLitterListModal" tabindex="-1" aria-labelledby="addLitterModalLabel" aria-hidden="true">
2+
<div class="modal-dialog">
3+
<div class="modal-content">
4+
<!-- Modal header -->
5+
<div class="modal-header">
6+
<h5 class="modal-title" id="addLitterModalLabel">Add Litter</h5>
7+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
8+
</div>
9+
10+
<!-- Modal body -->
11+
<div class="col text-center m-3">
12+
<table class="table table-striped">
13+
<thead>
14+
<tr>
15+
<th>Date</th>
16+
<th>By</th>
17+
<th>Address</th>
18+
<th>PostCode</th>
19+
<th>Status</th>
20+
<th>Action</th>
3321
</tr>
34-
</div>
35-
<div th:if="${#lists.isEmpty(litters)}">
36-
<p>No data</p>
37-
</div>
38-
</tbody>
39-
</table>
22+
</thead>
23+
<tbody>
24+
<div th:if="${not #lists.isEmpty(litters)}">
25+
<tr th:each="litter : ${litters}">
26+
<td th:text="${litter.getCreatedAt()}"></td>
27+
<td th:text="${litter.getCreatedBy()}"></td>
28+
<td th:text="${litter.getAddress().firstLine}"></td>
29+
<td th:text="${litter.getAddress().postCode}"></td>
30+
<td th:text="${litter.getStatus()}"></td>
31+
<td>
32+
<div class="btn-group col-12 col-md-4 col-lg-2">
33+
<a th:href="@{/thy/litter/{id}(id=${litter.id})}"
34+
class="btn btn-success btn-sm btn-block m-1">View</a>
35+
<a th:href="@{/thy/litter/edit/{id}(id=${litter.id})}"
36+
class="btn btn-warning btn-sm btn-block m-1">Edit</a>
37+
<a th:href="@{/thy/litter/delete(id=${litter.id})}"
38+
class="btn btn-danger btn-sm btn-block m-1">Delete</a>
39+
</div>
40+
</td>
41+
</tr>
42+
</div>
43+
<div th:if="${#lists.isEmpty(litters)}">
44+
<p>No data</p>
45+
</div>
46+
</tbody>
47+
</table>
48+
</div>
4049
</div>
4150
</div>
4251
</div>

0 commit comments

Comments
 (0)