Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
http.authorizeHttpRequests(
auth -> auth
.requestMatchers("/auth/**", "/", "/home", "/images/**", "/style.css",
"/upload/**", "/login", "/register", "/favicon.ico", "/access-denied")
"/upload/**", "/login", "/register", "/static/favicon.ico", "/access-denied")
Comment thread
FeFFe1996 marked this conversation as resolved.
.permitAll()
.requestMatchers("/admin/**").hasRole("ADMIN")
.requestMatchers("/handler/**").hasAnyRole("HANDLER", "SUPERVISOR", "ADMIN")
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/example/untitled/s3/S3RestController.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.example.untitled.s3;

import org.example.untitled.usercase.service.CaseService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
Expand All @@ -14,7 +15,7 @@ public class S3RestController {
private final Logger log = LoggerFactory.getLogger(S3RestController.class);
private final S3Service s3Service;

public S3RestController(S3Service s3Service){
public S3RestController(S3Service s3Service, CaseService caseService){
this.s3Service = s3Service;
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/example/untitled/s3/S3Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public void deleteFile(String filename){
s3Client.deleteObject(req -> req
.bucket(BUCKET_NAME)
.key(filename));

}

public UploadedFile createFile(CaseEntity caseEntity, String s3Key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ public interface UploadedFileRepository extends ListCrudRepository<UploadedFile,
UploadedFile getUploadedFilesByFilename(String filename);

List<UploadedFile> getUploadedFilesByUploadedBy(User uploadedBy);

void deleteUploadedFileByS3Key(String s3Key);
}
Binary file added src/main/resources/static/favicon.ico
Binary file not shown.
4 changes: 4 additions & 0 deletions src/main/resources/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,7 @@ main {
padding-bottom: 8px;
border-bottom: 1px solid #1e3a5f;
}

li{
list-style-type: none;
}
Comment thread
FeFFe1996 marked this conversation as resolved.
29 changes: 11 additions & 18 deletions src/main/resources/templates/ticket.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ <h1>Ticket Details</h1>
<div class="ticket-body">
<p>Handler: <span th:text="*{assignedToUsername} ?: 'Unassigned'"></span></p>
<p th:text="*{description}"></p>
<p>Files</p>
<ul class="file-list">
<li th:each="file : ${files}">
<a href="#"
th:text="${file.getFilename()}"
th:attr="data-file=${file.getS3Key()}"
onclick="event.preventDefault(); downloadFile(this.dataset.file)"></a>
</li>
</ul>
</div>
</div>
</div>
Expand All @@ -52,22 +61,17 @@ <h2 class="section-title">Comments</h2>
<h2 class="section-title">Add Comment</h2>
<form th:action="@{/tickets/{id}/comments(id=${ticket.id})}"
th:object="${comment}"
method="post">
method="POST">
<div>
<label for="text">Comment:</label>
<textarea id="text" th:field="*{text}" placeholder="Write your comment here..."></textarea>
<span th:if="${#fields.hasErrors('text')}"
th:errors="*{text}"
class="field-error"></span>
</div>
<div>
<input type="hidden" id="fileNameHidden">
<input type="file" id="fileInput" multiple>
<p id="status"></p>
</div>
<div id="hidden-file-inputs"></div>
<div style="margin-top: 12px;">
<button onclick="uploadNewFile()" type="submit" class="btn" id="submitBtn">Add Comment</button>
<button type="submit" class="btn">Add Comment</button>
</div>
</form>
</div>
Expand All @@ -85,17 +89,6 @@ <h2 class="section-title">Activity Log</h2>
</div>
</div>
</div>
<div class="show-files">
<tr th:each="file : ${files}">
<td th:text="${file.getFilename()}"></td>
<td>
<button th:data-file="${file.getS3Key()}"
onclick="downloadFile(this.getAttribute('data-file'))"
class="button">Download</button>
</td>
</tr>

</div>

<footer style="margin-top: 24px;">
<nav style="display: flex; gap: 10px;">
Expand Down
30 changes: 11 additions & 19 deletions src/main/resources/templates/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,18 @@ <h1>Uploaded Files</h1>
</div>
</div>
<section>
<table>
<thead>
<tr>
<th>File Name</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr th:each="file : ${files}">
<td th:text="${file.getFilename()}"></td>
<td>
<button th:data-file="${file.getS3Key()}"
onclick="downloadFile(this.getAttribute('data-file'))"
class="button">Download</button>
</td>
</tr>
</tbody>
</table>
<ul class="file-list">
<li th:each="file : ${files}">
<a href="#"
th:text="${file.getFilename()}"
th:attr="data-file=${file.getS3Key()}"
onclick="event.preventDefault(); downloadFile(this.dataset.file)"></a>
</li>
</ul>


</ul>
</section>
<p><a th:href="@{/user}"></a></p>
</div>

</main>
Expand Down