147 lines
4.6 KiB
Text
147 lines
4.6 KiB
Text
package templates
|
|
|
|
import (
|
|
"strconv"
|
|
"fmt"
|
|
"echoTest/models"
|
|
)
|
|
|
|
templ layout(title string) {
|
|
<!DOCTYPE html>
|
|
<html data-theme="light">
|
|
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>{title}</title>
|
|
<script src="https://unpkg.com/htmx.org@1.9.6"></script>
|
|
<link href="https://cdn.jsdelivr.net/npm/daisyui@4.12.14/dist/full.css" rel="stylesheet" type="text/css" />
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@catppuccin/daisyui@1.2.1/dist/catppuccin.css" />
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
</head>
|
|
|
|
<body>
|
|
<div data-theme="macchiato">
|
|
<div class="navbar bg-base-100">
|
|
<div class="flex-1">
|
|
<a class="btn btn-ghost normal-case text-xl">Home</a>
|
|
</div>
|
|
<div class="flex-none">
|
|
<button class="btn btn-primary" hx-get="/end">Beenden</button>
|
|
</div>
|
|
</div>
|
|
<div class="container mx-auto p-4">
|
|
{children...}
|
|
</div>
|
|
<footer class="footer footer-center p-4 bg-base-300 text-base-content">
|
|
<div>
|
|
<p>© 2023 Alle Rechte vorbehalten.</p>
|
|
</div>
|
|
</footer>
|
|
</div>
|
|
</body>
|
|
|
|
</html>
|
|
}
|
|
|
|
templ BewertungenForm(maxPunkte models.MaxPunkte) {
|
|
<form method="post" action="/add" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-4">
|
|
<div class="form-control">
|
|
<label for="hv_max" class="label">HV Punkte</label>
|
|
<input id="hv_max" class="input input-bordered" type="text" name="hv_max" value={fmt.Sprintf("%.2f",
|
|
maxPunkte.HvMax)} />
|
|
</div>
|
|
<div class="form-control">
|
|
<label for="hv_gewichtung" class="label">HV Gewichtung in %</label>
|
|
<input id="hv_gewichtung" class="input input-bordered" type="text" name="hv_gewichtung" value={fmt.Sprintf("%.2f",
|
|
maxPunkte.HvGewichtung)} />
|
|
</div>
|
|
<div class="form-control">
|
|
<label for="lv_max" class="label">LV Punkte</label>
|
|
<input id="lv_max" class="input input-bordered" type="text" name="lv_max" value={fmt.Sprintf("%.2f",
|
|
maxPunkte.LvMax)} />
|
|
</div>
|
|
<div class="form-control">
|
|
<label for="lv_gewichtung" class="label">LV Gewichtung in %</label>
|
|
<input id="lv_gewichtung" class="input input-bordered" type="text" name="lv_gewichtung" value={fmt.Sprintf("%.2f",
|
|
maxPunkte.LvGewichtung)} />
|
|
</div>
|
|
<div class="form-control">
|
|
<input type="text" name="vorname" class="input input-bordered" placeholder="Vorname" />
|
|
</div>
|
|
<div class="form-control">
|
|
<input type="text" name="nachname" class="input input-bordered" placeholder="Nachname" />
|
|
</div>
|
|
<div class="form-control">
|
|
<input type="text" name="hv_punkte" class="input input-bordered" placeholder="HV-Punkte" />
|
|
</div>
|
|
<div class="form-control">
|
|
<input type="text" name="lv_punkte" class="input input-bordered" placeholder="LV-Punkte" />
|
|
</div>
|
|
<div class="form-control">
|
|
<button type="submit" class="btn btn-primary">Add</button>
|
|
</div>
|
|
</form>
|
|
}
|
|
|
|
templ BewertungenTable(bewertungen []models.Bewertung) {
|
|
<div class="overflow-x-auto">
|
|
<table class="table table-zebra">
|
|
<thead>
|
|
<tr>
|
|
<th>Gewertet</th>
|
|
<th>Vorname</th>
|
|
<th>Nachname</th>
|
|
<th>HV-Punkte</th>
|
|
<th>HV-Prozent</th>
|
|
<th>HV-Note</th>
|
|
<th>LV-Punkte</th>
|
|
<th>LV-Prozent</th>
|
|
<th>LV-Note</th>
|
|
<th>Gesamt-Prozent</th>
|
|
<th>Gesamt-Note</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
for _, b := range bewertungen {
|
|
@BewertungRow(b)
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
}
|
|
|
|
templ BewertungRow(b models.Bewertung) {
|
|
<tr id={"bewertung-" + strconv.Itoa(b.ID)}>
|
|
<td>
|
|
<input type="checkbox" class="toggle" checked?={b.Gewertet} hx-post={"/toggle/" + strconv.Itoa(b.ID)}
|
|
hx-target={"#bewertung-" + strconv.Itoa(b.ID)} hx-swap="outerHTML" />
|
|
</td>
|
|
<td>{b.Vorname}</td>
|
|
<td>{b.Nachname}</td>
|
|
<td>{fmt.Sprintf("%.2f", b.HvPunkte)}</td>
|
|
<td>{fmt.Sprintf("%.2f", b.HvProzent)}</td>
|
|
<td>{strconv.Itoa(b.HvNote)}</td>
|
|
<td>{fmt.Sprintf("%.2f", b.LvPunkte)}</td>
|
|
<td>{fmt.Sprintf("%.2f", b.LvProzent)}</td>
|
|
<td>{strconv.Itoa(b.LvNote)}</td>
|
|
<td>{fmt.Sprintf("%.2f", b.GesamtProzent)}</td>
|
|
<td>{strconv.Itoa(b.GesamtNote)}</td>
|
|
</tr>
|
|
}
|
|
|
|
templ BewertungenPage(bewertungen []models.Bewertung, maxPunkte models.MaxPunkte) {
|
|
@layout("Englischarbeit") {
|
|
<div class="card bg-base-100 shadow-xl">
|
|
<div class="card-body">
|
|
<h2 class="card-title">Englischarbeit</h2>
|
|
<h3 class="text-lg font-bold">Bewertungen</h3>
|
|
@BewertungenForm(maxPunkte)
|
|
@BewertungenTable(bewertungen)
|
|
<div class="card-actions justify-end">
|
|
<button hx-get="/export" class="btn btn-primary">Export</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
}
|