Embeds the git short hash and UTC build timestamp into both binaries via ldflags so it's easy to confirm which build is actually deployed, without needing to hand-maintain a version number. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
207 lines
10 KiB
Text
207 lines
10 KiB
Text
package templates
|
|
|
|
import (
|
|
"strconv"
|
|
"github.com/hculpan/areweplaying/pkg/data"
|
|
"github.com/hculpan/areweplaying/pkg/version"
|
|
)
|
|
|
|
templ Setup(session data.Session) {
|
|
<html>
|
|
@Header()
|
|
|
|
<body class="bg-dark text-light">
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-3">
|
|
<a href="/" class="btn btn-secondary"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
|
|
fill="currentColor" class="bi bi-arrow-left" viewBox="0 0 16 16">
|
|
<path fill-rule="evenodd"
|
|
d="M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8" />
|
|
</svg>Back to Main Page</a>
|
|
</div>
|
|
<div class="col-3">
|
|
<a href="/send-reminder" class="btn btn-secondary">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
|
|
class="bi bi-envelope-plus" viewBox="0 0 16 16">
|
|
<path
|
|
d="M2 2a2 2 0 0 0-2 2v8.01A2 2 0 0 0 2 14h5.5a.5.5 0 0 0 0-1H2a1 1 0 0 1-.966-.741l5.64-3.471L8 9.583l7-4.2V8.5a.5.5 0 0 0 1 0V4a2 2 0 0 0-2-2zm3.708 6.208L1 11.105V5.383zM1 4.217V4a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v.217l-7 4.2z" />
|
|
<path
|
|
d="M16 12.5a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0m-3.5-2a.5.5 0 0 0-.5.5v1h-1a.5.5 0 0 0 0 1h1v1a.5.5 0 0 0 1 0v-1h1a.5.5 0 0 0 0-1h-1v-1a.5.5 0 0 0-.5-.5" />
|
|
</svg>
|
|
Send Reminder
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div class="row mt-4">
|
|
<h1>Setup</h1>
|
|
</div>
|
|
<div class="row">
|
|
<form action="/save-setup" method="post">
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input" type="checkbox" value="nextSession" id="nextSession"
|
|
name="nextSession" />
|
|
<label class="form-check-label" for="nextSession">Change to next session</label>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="incrementDaysInput" class="form-label">Days to Increment</label>
|
|
<input type="number" class="form-control" id="incrementDaysInput" name="incDays" min="1"
|
|
style="max-width: 150px;" max="999" value={ strconv.Itoa(session.IncrementDays) } />
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="sessionStatus" class="form-label">Session Status</label>
|
|
<select class="form-select" aria-label="Default select example" name="sessionStatus"
|
|
style="max-width: 150px;">
|
|
<option selected></option>
|
|
<option value="planned">Planned</option>
|
|
<option value="canceled">Canceled</option>
|
|
</select>
|
|
</div>
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input" type="checkbox" value="sendEmail" id="sendEmail" name="sendEmail" />
|
|
<label class="form-check-label" for="sendEmail">Send Email</label>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Save</button>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="row mt-5">
|
|
<div class="col d-flex align-items-center gap-3">
|
|
<h2 class="mb-0">Players</h2>
|
|
<button type="button" class="btn btn-success btn-sm" data-bs-toggle="modal" data-bs-target="#addPlayerModal">
|
|
+ Add Player
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="row mt-2">
|
|
<div class="col">
|
|
<table class="table table-dark table-striped table-bordered">
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Email</th>
|
|
<th>GM</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
for _, p := range session.Players {
|
|
<tr>
|
|
<td>{ p.Name }</td>
|
|
<td>{ p.Email }</td>
|
|
<td>
|
|
if p.Gm {
|
|
<span class="badge bg-warning text-dark">GM</span>
|
|
}
|
|
</td>
|
|
<td>
|
|
<button type="button" class="btn btn-secondary btn-sm me-1"
|
|
data-bs-toggle="modal"
|
|
data-bs-target="#editPlayerModal"
|
|
data-name={ p.Name }
|
|
data-email={ p.Email }
|
|
data-gm={ strconv.FormatBool(p.Gm) }
|
|
data-attending={ p.Attending }
|
|
onclick="populateEditModal(this)">
|
|
Edit
|
|
</button>
|
|
<form action="/admin/players/delete" method="post" class="d-inline">
|
|
<input type="hidden" name="name" value={ p.Name } />
|
|
<button type="submit" class="btn btn-danger btn-sm"
|
|
onclick="return confirm('Delete ' + this.form.querySelector('[name=name]').value + '?')">Delete</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Add Player Modal -->
|
|
<div class="modal fade" id="addPlayerModal" tabindex="-1" aria-labelledby="addPlayerModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content bg-dark text-light">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="addPlayerModalLabel">Add Player</h5>
|
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<form action="/admin/players/add" method="post">
|
|
<div class="modal-body">
|
|
<div class="mb-3">
|
|
<label for="addName" class="form-label">Name</label>
|
|
<input type="text" class="form-control" id="addName" name="name" required />
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="addEmail" class="form-label">Email</label>
|
|
<input type="email" class="form-control" id="addEmail" name="email" required />
|
|
</div>
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" id="addGm" name="gm" />
|
|
<label class="form-check-label" for="addGm">Game Master</label>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
|
<button type="submit" class="btn btn-primary">Add Player</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Edit Player Modal -->
|
|
<div class="modal fade" id="editPlayerModal" tabindex="-1" aria-labelledby="editPlayerModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content bg-dark text-light">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="editPlayerModalLabel">Edit Player</h5>
|
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<form action="/admin/players/edit" method="post">
|
|
<input type="hidden" id="editOriginalName" name="originalName" />
|
|
<input type="hidden" id="editAttending" name="attending" />
|
|
<div class="modal-body">
|
|
<div class="mb-3">
|
|
<label for="editName" class="form-label">Name</label>
|
|
<input type="text" class="form-control" id="editName" name="name" required />
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="editEmail" class="form-label">Email</label>
|
|
<input type="email" class="form-control" id="editEmail" name="email" required />
|
|
</div>
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" id="editGm" name="gm" />
|
|
<label class="form-check-label" for="editGm">Game Master</label>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
|
<button type="submit" class="btn btn-primary">Save Changes</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
|
|
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
|
|
crossorigin="anonymous"></script>
|
|
<script>
|
|
function populateEditModal(btn) {
|
|
document.getElementById('editOriginalName').value = btn.dataset.name;
|
|
document.getElementById('editName').value = btn.dataset.name;
|
|
document.getElementById('editEmail').value = btn.dataset.email;
|
|
document.getElementById('editGm').checked = btn.dataset.gm === 'true';
|
|
document.getElementById('editAttending').value = btn.dataset.attending;
|
|
}
|
|
</script>
|
|
|
|
<footer class="container text-muted small mt-4">
|
|
Build: { version.Version } ({ version.BuildTime })
|
|
</footer>
|
|
</body>
|
|
|
|
</html>
|
|
}
|