Add duration pipe and display event duration on webpage#5
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a duration pipe to compute and display event durations on the webpage, while also updating some dependency injection patterns and asset references for consistency.
- Added a new DurationPipe for calculating event durations.
- Updated Angular services to use the new inject() API instead of constructor injection.
- Updated the main script reference in the HTML and made minor style adjustments to display the duration.
Reviewed Changes
Copilot reviewed 9 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/ui/web/index.html | Updated the main script file reference. |
| internal/ui/angular-ui/src/app/services/tt/tt.service.ts | Switched to using inject() for dependency injection. |
| internal/ui/angular-ui/src/app/services/TimeSlot/time-slot.service.ts | Switched to using inject() for dependency injection. |
| internal/ui/angular-ui/src/app/duration.pipe.ts | Added a new pipe to compute duration from start and end times. |
| internal/ui/angular-ui/src/app/components/time-slot/time-slot.component.ts | Imported the DurationPipe into the time-slot component. |
| internal/ui/angular-ui/src/app/components/time-slot/time-slot.component.scss | Added styling for the duration display. |
| internal/ui/angular-ui/src/app/components/time-slot/time-slot.component.html | Included the duration pipe in the component template. |
| internal/api/api-webserver.go | Added a commented-out alternative CORS header for local development. |
| go.mod | Updated the version of the bbolt dependency. |
Files not reviewed (1)
- internal/ui/angular-ui/package-lock.json: Language not supported
| <div class="content-container"> | ||
| <div class="content"> | ||
| {{ timeSlot()?.Text }} | ||
| <span>{{ timeSlot()?.Start | duration:timeSlot()?.End }}</span> |
There was a problem hiding this comment.
[nitpick] Consider caching the result of timeSlot() in a local variable or via an ngIf directive to avoid multiple invocations in the template, which can improve performance if timeSlot() is computationally expensive.
|
|
||
| func setCorsHeaders(writer http.ResponseWriter) { | ||
| writer.Header().Set("Access-Control-Allow-Origin", ui.WebserverUrl) | ||
| // writer.Header().Set("Access-Control-Allow-Origin", "http://localhost:4200") |
There was a problem hiding this comment.
[nitpick] If this commented-out CORS header is no longer needed, consider removing it to keep the code clean.
| // writer.Header().Set("Access-Control-Allow-Origin", "http://localhost:4200") |
There was a problem hiding this comment.
I wanted to leave it to easily enable debugging by just uncommenting it again
|
Can you increase the min height of the TimeSlot Component? Then I am fine |
No description provided.