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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.example.untitled.exception.UserAlreadyExistsException;
import org.example.untitled.user.service.UserService;
import org.example.untitled.usercase.service.CaseService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Controller;
Expand All @@ -28,6 +29,7 @@ public UserController(UserService service, CaseService caseService) {
}

@GetMapping("/user")
@PreAuthorize("hasRole('USER')")
public String userLanding(Model model,
@AuthenticationPrincipal UserDetails userDetails,
@RequestParam(required = false) String filter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
import org.example.untitled.usercase.CaseEntity;
import org.example.untitled.usercase.Comment;
import org.example.untitled.usercase.dto.CommentDto;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.ListCrudRepository;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface CommentRepository extends ListCrudRepository<Comment, Long> {
List<CommentDto> findCommentsByCaseEntity(CaseEntity caseEntity);

@Query("SELECT new org.example.untitled.usercase.dto.CommentDto(" +
"c.id, c.text, c.author.id, c.author.username, c.caseEntity.id, c.createdAt) " +
"FROM Comment c WHERE c.caseEntity = :caseEntity " +
"ORDER BY c.createdAt ASC")
List<CommentDto> findCommentsByCaseEntity(@Param("caseEntity") CaseEntity caseEntity);
}
10 changes: 7 additions & 3 deletions src/main/resources/templates/ticket.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<html xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
lang="en">
<head>
<meta charset="UTF-8">
<title>Ticket</title>
Expand All @@ -26,7 +28,6 @@ <h1>Ticket Details</h1>
<div>
<div class="ticket-comments">
<div th:each="comment : ${comments}" class="comment-box">
<p class="comment-title" th:text="${comment.title}"></p>
<p class="comment-text" th:text="${comment.text}"></p>
<p class="comment-author">
Author: <span th:text="${comment.authorUsername}"></span>
Expand All @@ -37,7 +38,10 @@ <h1>Ticket Details</h1>
<div class="ticket-footer">
<nav>
<a th:href="@{/tickets/{id}/close(id=${ticket.id})}">Close</a> |
<a th:href="@{/tickets}">Back</a>
<a sec:authorize="hasAnyRole('HANDLER', 'SUPERVISOR', 'ADMIN')"
th:href="@{/handler}" class="btn btn-secondary">Back</a>
<a sec:authorize="hasRole('USER')"
th:href="@{/user}" class="btn btn-secondary">Back</a>
Comment thread
coderabbitai[bot] marked this conversation as resolved.
</nav>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/templates/userpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<h1>My Tickets</h1>
<div class="ticket-actions">
<a th:href="@{/tickets/create}" class="btn">+ New ticket</a>
<a th:href="@{/upload}" class="btn btn-secondary">Upload file</a>
<a th:href="@{/tickets/upload}" class="btn btn-secondary">Upload file</a>
</div>
</div>

Expand Down Expand Up @@ -46,6 +46,7 @@ <h1>My Tickets</h1>
<span class="assigned"
th:text="${ticket.assignedToUsername != null ? 'Assigned to: ' + ticket.assignedToUsername : 'Unassigned'}"></span>
<div class="ticket-button">
<a th:href="@{/tickets/{id}(id=${ticket.id})}" class="btn btn-secondary">View</a>
<a th:href="@{/tickets/{id}/edit(id=${ticket.id})}" class="btn btn-secondary">Edit</a>
<a th:if="${ticket.status.name() != 'CLOSED' and ticket.status.name() != 'SOLVED'}"
th:href="@{/tickets/{id}/close(id=${ticket.id})}" class="btn btn-danger">Close</a>
Expand Down