feat: add Thymeleaf frontend with ticket management views and styles#10
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 41 minutes and 18 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR integrates Thymeleaf templating support and introduces a web view layer for ticket management. Changes include a home page controller, ticket listing/detail/creation views with corresponding Spring MVC controllers, service method extensions, and a complete CSS stylesheet for styling. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/java/org/group1/projectbackend/config/DataInitializer.java (1)
18-35:⚠️ Potential issue | 🔴 CriticalFix the multi-row insert syntax and make seeding idempotent.
PostgreSQL does not accept repeated
VALUESkeywords here, so a fresh database will fail during startup. Also, theid = 1guard means existing dev databases will never receive users 2-5.🐛 Proposed fix
- Integer userCount = jdbcTemplate.queryForObject( - "SELECT COUNT(*) FROM users WHERE id = 1", - Integer.class - ); - - if (userCount != null && userCount > 0) { - return; - } - jdbcTemplate.update( """ INSERT INTO users (id, username, email, password, full_name, enabled, created_at) - VALUES (1, 'user', 'user@example.com', 'password', 'user', true, CURRENT_TIMESTAMP) - VALUES (2, 'adamaj01', 'adamaj@example.com', 'password', 'Adam', true, CURRENT_TIMESTAMP) - VALUES (3, 'emmtra01', 'emmtra@example.com', 'password', 'Emma', true, CURRENT_TIMESTAMP) - VALUES (4, 'erifal01', 'erifal@example.com', 'password', 'Erika', true, CURRENT_TIMESTAMP) - VALUES (5, 'johjan01', 'johjan@example.com', 'password', 'Johan', true, CURRENT_TIMESTAMP) + VALUES + (1, 'user', 'user@example.com', 'password', 'user', true, CURRENT_TIMESTAMP), + (2, 'adamaj01', 'adamaj@example.com', 'password', 'Adam', true, CURRENT_TIMESTAMP), + (3, 'emmtra01', 'emmtra@example.com', 'password', 'Emma', true, CURRENT_TIMESTAMP), + (4, 'erifal01', 'erifal@example.com', 'password', 'Erika', true, CURRENT_TIMESTAMP), + (5, 'johjan01', 'johjan@example.com', 'password', 'Johan', true, CURRENT_TIMESTAMP) + ON CONFLICT (id) DO NOTHING """ );🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/java/org/group1/projectbackend/config/DataInitializer.java` around lines 18 - 35, The current seeding in DataInitializer uses an incorrect multi-row INSERT (repeated VALUES) and only checks for id = 1, preventing seeding of users 2-5; change the guard using jdbcTemplate.queryForObject to check for any existing users (e.g., COUNT(*) > 0) or check existence of each row, and replace the INSERT SQL in jdbcTemplate.update with a single INSERT statement that lists multiple rows using one VALUES clause with comma-separated tuples, or preferably use INSERT ... ON CONFLICT (id) DO NOTHING to make the operation idempotent so reruns won’t error or duplicate data.
🧹 Nitpick comments (1)
src/main/resources/application.properties (1)
16-19: Scope cache disabling to a dev profile.These defaults disable static resource and Thymeleaf caching for every environment. If this is only for frontend iteration, move them to
application-dev.propertiesor guard them with profile-specific config to avoid production performance regressions.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/resources/application.properties` around lines 16 - 19, The three properties spring.web.resources.cache.period, spring.web.resources.chain.cache, and spring.thymeleaf.cache should not be globally disabled in application.properties; move them into a profile-specific file (e.g., create application-dev.properties) or add profile-scoped equivalents so they only apply when the "dev" profile is active, then remove or revert them from application.properties; update any docs or run configurations to activate the "dev" profile during local/frontend iteration as needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@src/main/java/org/group1/projectbackend/controller/web/TicketViewController.java`:
- Around line 63-74: The createComment method currently accepts a
client-provided userId and trusts it; remove the `@RequestParam` Long userId and
instead obtain the authenticated user on the server (e.g., add a Principal or
Authentication parameter to the controller method), resolve that principal to an
internal user id (for example via a UserService method like
findByUsername(principal.getName()) and getId()), set that id on
CreateCommentDto, and then call commentService.createComment(comment) as before;
update imports and any method signature references to use
Principal/Authentication and remove reliance on the request-supplied userId.
- Around line 50-58: The createTicket handler in TicketViewController builds a
CreateTicketRequest manually from individual `@RequestParam` values so Spring
validation on DTO constraints isn't applied; change the method signature to
accept a validated form object (e.g., replace individual `@RequestParam` params
with a single `@Valid` CreateTicketRequest parameter and add BindingResult if you
need to handle errors) or explicitly validate the constructed
CreateTicketRequest before calling
supportTicketService.createTicket(principal.getName(), request) so
`@NotBlank/`@Size/@NotNull annotations on CreateTicketRequest are enforced.
In `@src/main/resources/static/css/app.css`:
- Line 125: Replace the quoted SFMono-Regular font name in the font-family
declarations to satisfy Stylelint's font-family-name-quotes rule: find
occurrences of the declaration string font-family: "SFMono-Regular", Consolas,
"Liberation Mono", monospace; (and the similar lines at the other reported
locations) and remove the quotes around SFMono-Regular so it becomes
font-family: SFMono-Regular, Consolas, "Liberation Mono", monospace;; apply the
same change at the other reported lines (the other font-family declarations
referencing "SFMono-Regular").
In `@src/main/resources/templates/tickets/detail.html`:
- Around line 70-72: Remove the client-controlled hidden field name="userId"
from the form in the tickets detail template (the form with
th:action="@{/tickets/{id}/comments(id=${ticket.id()})}") so the browser cannot
assert comment ownership; then update the server-side POST handler that
processes POST /tickets/{id}/comments (the controller method that creates/saves
comments) to derive the commenter from the authenticated principal/session
instead of relying on any submitted userId value, setting the comment's owner
from that authenticated user before persisting.
---
Outside diff comments:
In `@src/main/java/org/group1/projectbackend/config/DataInitializer.java`:
- Around line 18-35: The current seeding in DataInitializer uses an incorrect
multi-row INSERT (repeated VALUES) and only checks for id = 1, preventing
seeding of users 2-5; change the guard using jdbcTemplate.queryForObject to
check for any existing users (e.g., COUNT(*) > 0) or check existence of each
row, and replace the INSERT SQL in jdbcTemplate.update with a single INSERT
statement that lists multiple rows using one VALUES clause with comma-separated
tuples, or preferably use INSERT ... ON CONFLICT (id) DO NOTHING to make the
operation idempotent so reruns won’t error or duplicate data.
---
Nitpick comments:
In `@src/main/resources/application.properties`:
- Around line 16-19: The three properties spring.web.resources.cache.period,
spring.web.resources.chain.cache, and spring.thymeleaf.cache should not be
globally disabled in application.properties; move them into a profile-specific
file (e.g., create application-dev.properties) or add profile-scoped equivalents
so they only apply when the "dev" profile is active, then remove or revert them
from application.properties; update any docs or run configurations to activate
the "dev" profile during local/frontend iteration as needed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c93385cb-d7cc-4a9e-b831-fc7176f16414
📒 Files selected for processing (13)
pom.xmlsrc/main/java/org/group1/projectbackend/config/DataInitializer.javasrc/main/java/org/group1/projectbackend/controller/web/HomeController.javasrc/main/java/org/group1/projectbackend/controller/web/TicketViewController.javasrc/main/java/org/group1/projectbackend/service/SupportTicketService.javasrc/main/java/org/group1/projectbackend/service/impl/SupportTicketServiceImpl.javasrc/main/resources/application.propertiessrc/main/resources/static/css/app.csssrc/main/resources/templates/fragments/layout.htmlsrc/main/resources/templates/index.htmlsrc/main/resources/templates/tickets/detail.htmlsrc/main/resources/templates/tickets/list.htmlsrc/main/resources/templates/tickets/new.html
Summary by CodeRabbit
Release Notes