You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
3.6 KiB
122 lines
3.6 KiB
package templates
|
|
|
|
import "track-gopher/models"
|
|
import "fmt"
|
|
|
|
// Public version of the final results page - no navigation, no group selection
|
|
templ FinalResultsPublic(results []models.FinalResult, groupName string, revealCount int) {
|
|
@LayoutPublic("Final Results") {
|
|
<div class="container mt-4">
|
|
<div class="text-center mb-5">
|
|
<h1 class="display-4">Final Results</h1>
|
|
<h2 class="text-primary" hx-ext="sse" sse-connect="/api/admin/events" sse-swap="group-name">{ groupName }</h2>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-header bg-primary text-white">
|
|
<h3 class="mb-0">Final Standings</h3>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-striped table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th>Place</th>
|
|
<th>Racer</th>
|
|
<th>Car #</th>
|
|
<th>Times</th>
|
|
<th>Final Time</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="results-body" hx-ext="sse" sse-connect="/api/admin/events" sse-swap="results-reveal">
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="card-footer">
|
|
<small class="text-muted">Final time is the average of the fastest 3 times (discarding the slowest time if 4 runs completed)</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
.reveal-animation {
|
|
animation: fadeIn 1s;
|
|
}
|
|
|
|
@keyframes fadeIn {
|
|
from { opacity: 0; transform: translateY(20px); }
|
|
to { opacity: 1; transform: translateY(0); }
|
|
}
|
|
</style>
|
|
}
|
|
}
|
|
|
|
templ FinalResultsTable(results []models.FinalResult) {
|
|
for _, result := range results {
|
|
<tr class="reveal-animation">
|
|
<td>{ fmt.Sprintf("%d", result.Place) }</td>
|
|
<td>{ result.Racer.FirstName } { result.Racer.LastName }</td>
|
|
<td>{ result.Racer.CarNumber }</td>
|
|
<td>
|
|
<small>
|
|
for i, time := range result.Times {
|
|
if i > 0 {
|
|
,
|
|
}
|
|
if time >= 9.999 {
|
|
DNF
|
|
} else {
|
|
{ fmt.Sprintf("%.3f", time) }
|
|
}
|
|
}
|
|
</small>
|
|
</td>
|
|
<td>
|
|
if result.DNF {
|
|
<span class="text-danger">DNF</span>
|
|
} else {
|
|
<strong>{ fmt.Sprintf("%.3f", result.AverageTime) }</strong>
|
|
}
|
|
</td>
|
|
</tr>
|
|
}
|
|
}
|
|
|
|
// Admin version with group selection - kept for admin use
|
|
templ FinalResultsPage(groups []models.Group, selectedGroupID int64, results []models.FinalResult, selectedGroupName string) {
|
|
@Layout("Final Results") {
|
|
<div class="container mt-4">
|
|
<h1 class="mb-4">Final Results</h1>
|
|
|
|
<div class="row mb-4">
|
|
<div class="col-md-6">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="mb-0">Select Group</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<form id="group-select-form" method="get" action="/results">
|
|
<div class="mb-3">
|
|
<label for="group_id" class="form-label">Racing Group</label>
|
|
<select class="form-select" id="group_id" name="group_id" onchange="this.form.submit()">
|
|
<option value="">Select a group...</option>
|
|
for _, group := range groups {
|
|
<option value={ fmt.Sprintf("%d", group.ID) } selected?={ group.ID == selectedGroupID }>
|
|
{ group.Name }
|
|
</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
if selectedGroupID > 0 {
|
|
@FinalResults(results, selectedGroupName)
|
|
}
|
|
</div>
|
|
}
|
|
} |