feat: add Phase 4 Logging & Tracking — inline set logging, history views
Add workout logging so users can track sets, reps, weight, and a
"felt easy?" toggle inline from the workout day view via HTMX.
Sessions auto-create on first log. History page shows past sessions
with detailed per-exercise breakdowns.
New services: WorkoutSessionService, LogService
New routes: POST /log, /log/{id}/edit, /log/{id}/delete, GET /history, /history/{id}
New templates: log_form, log_entry, session_card, log_history, session_detail
Modified: exercise_card (inline logging), nav (History link), workouts route (session context)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
23
app/templates/pages/log_history.html
Normal file
23
app/templates/pages/log_history.html
Normal file
@@ -0,0 +1,23 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Workout History -- SneakySwole{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<hgroup>
|
||||
<h1>Workout History</h1>
|
||||
{% if active_profile %}
|
||||
<p>History for: <strong>{{ active_profile.display_name }}</strong></p>
|
||||
{% else %}
|
||||
<p>No profile selected -- <a href="/profiles">select one</a></p>
|
||||
{% endif %}
|
||||
</hgroup>
|
||||
|
||||
{% if sessions %}
|
||||
{% for ws in sessions %}
|
||||
{% set day = days_by_id.get(ws.workout_day_id) %}
|
||||
{% include "partials/session_card.html" %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<p>No workout sessions recorded yet.</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
51
app/templates/pages/session_detail.html
Normal file
51
app/templates/pages/session_detail.html
Normal file
@@ -0,0 +1,51 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Session Detail -- SneakySwole{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<hgroup>
|
||||
{% set day = days_by_id.get(workout_session.workout_day_id) %}
|
||||
<h1>
|
||||
{{ day.name if day else "Workout" }}
|
||||
-- {{ workout_session.date.strftime('%B %d, %Y') }}
|
||||
</h1>
|
||||
{% if workout_session.notes %}
|
||||
<p>{{ workout_session.notes }}</p>
|
||||
{% endif %}
|
||||
</hgroup>
|
||||
|
||||
{% for exercise_id, logs in logs_by_exercise.items() %}
|
||||
{% set exercise = exercises_by_id[exercise_id] %}
|
||||
<article>
|
||||
<header>
|
||||
<h3>{{ exercise.name }}</h3>
|
||||
</header>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Set</th>
|
||||
<th>Reps</th>
|
||||
<th>Weight</th>
|
||||
<th>Easy?</th>
|
||||
<th>Notes</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for log in logs %}
|
||||
<tr>
|
||||
<td>{{ log.set_number }}</td>
|
||||
<td>{{ log.reps_completed }}</td>
|
||||
<td>{{ log.weight_used }}</td>
|
||||
<td>{{ "Yes" if log.felt_easy else "No" }}</td>
|
||||
<td>{{ log.notes or "" }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</article>
|
||||
{% else %}
|
||||
<p>No exercises logged in this session.</p>
|
||||
{% endfor %}
|
||||
|
||||
<a href="/history" role="button" class="outline">Back to History</a>
|
||||
{% endblock %}
|
||||
@@ -24,5 +24,18 @@
|
||||
<p>{{ exercise.form_cues }}</p>
|
||||
</details>
|
||||
|
||||
<!-- Phase 4 adds: inline logging form here -->
|
||||
<!-- Inline logging (Phase 4) -->
|
||||
{% if active_profile %}
|
||||
<div id="logs-exercise-{{ exercise.id }}">
|
||||
{% if existing_logs and existing_logs[exercise.id] %}
|
||||
{% set logs = existing_logs[exercise.id] %}
|
||||
{% set exercise_id = exercise.id %}
|
||||
{% set next_set = logs|length + 1 %}
|
||||
{% include "partials/log_entry.html" %}
|
||||
{% else %}
|
||||
{% set next_set = 1 %}
|
||||
{% include "partials/log_form.html" %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</article>
|
||||
|
||||
39
app/templates/partials/log_entry.html
Normal file
39
app/templates/partials/log_entry.html
Normal file
@@ -0,0 +1,39 @@
|
||||
<!-- Displays logged sets for a single exercise within a session -->
|
||||
{% if logs %}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Set</th>
|
||||
<th>Reps</th>
|
||||
<th>Weight</th>
|
||||
<th>Easy?</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for log in logs %}
|
||||
<tr>
|
||||
<td>{{ log.set_number }}</td>
|
||||
<td>{{ log.reps_completed }}</td>
|
||||
<td>{{ log.weight_used }}</td>
|
||||
<td>{{ "Yes" if log.felt_easy else "No" }}</td>
|
||||
<td>
|
||||
<form hx-post="/log/{{ log.id }}/delete"
|
||||
hx-target="#logs-exercise-{{ exercise_id }}"
|
||||
hx-swap="innerHTML"
|
||||
hx-confirm="Delete this set?"
|
||||
style="display:inline; margin:0;">
|
||||
<button type="submit" class="outline secondary"
|
||||
style="padding:0.2rem 0.5rem; font-size:0.8rem;">
|
||||
Delete
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
|
||||
<!-- Next set form -->
|
||||
{% include "partials/log_form.html" %}
|
||||
24
app/templates/partials/log_form.html
Normal file
24
app/templates/partials/log_form.html
Normal file
@@ -0,0 +1,24 @@
|
||||
<!-- Inline logging form, included inside each exercise_card.html -->
|
||||
<form hx-post="/log"
|
||||
hx-target="#logs-exercise-{{ exercise.id }}"
|
||||
hx-swap="innerHTML"
|
||||
style="margin-bottom:0;">
|
||||
<input type="hidden" name="exercise_id" value="{{ exercise.id }}">
|
||||
<input type="hidden" name="workout_day_id" value="{{ workout_day_id }}">
|
||||
<input type="hidden" name="set_number" value="{{ next_set|default(1) }}">
|
||||
|
||||
<div style="display:flex; align-items:center; gap:0.5rem; flex-wrap:wrap;">
|
||||
<small style="white-space:nowrap; opacity:0.7;">Set {{ next_set|default(1) }}</small>
|
||||
<input type="number" name="reps" placeholder="Reps"
|
||||
min="0" max="100" required
|
||||
style="width:5rem; margin-bottom:0;">
|
||||
<input type="text" name="weight" placeholder="Weight (lbs)"
|
||||
required
|
||||
style="width:8rem; margin-bottom:0;">
|
||||
<label style="display:flex; align-items:center; gap:0.3rem; margin-bottom:0; white-space:nowrap;">
|
||||
<input type="checkbox" name="felt_easy" role="switch" style="margin-bottom:0;">
|
||||
Easy?
|
||||
</label>
|
||||
<button type="submit" style="margin-bottom:0; width:auto; white-space:nowrap;">Log Set</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -27,6 +27,7 @@
|
||||
</details>
|
||||
</li>
|
||||
<li><a href="/workouts">Workouts</a></li>
|
||||
<li><a href="/history">History</a></li>
|
||||
<li><a href="/exercises">Exercises</a></li>
|
||||
<li><a href="/profiles">Profiles</a></li>
|
||||
<li><a href="/logout">Logout</a></li>
|
||||
|
||||
16
app/templates/partials/session_card.html
Normal file
16
app/templates/partials/session_card.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<article>
|
||||
<header>
|
||||
<hgroup>
|
||||
<h3>{{ day.name if day else "Unknown" }} Day</h3>
|
||||
<p>{{ ws.date.strftime('%A, %B %d, %Y') }}</p>
|
||||
</hgroup>
|
||||
</header>
|
||||
{% if ws.notes %}
|
||||
<p>{{ ws.notes }}</p>
|
||||
{% endif %}
|
||||
<footer>
|
||||
<a href="/history/{{ ws.id }}" role="button" class="outline">
|
||||
View Details
|
||||
</a>
|
||||
</footer>
|
||||
</article>
|
||||
Reference in New Issue
Block a user