Move forecast map into exercise history

This commit is contained in:
Peter Stockings
2026-09-06 14:38:30 +10:00
parent 7af0202c30
commit d26da9a066
3 changed files with 99 additions and 69 deletions
+5 -33
View File
@@ -79,7 +79,7 @@ M{% for value, position in lower_points %}{{ (((position * vb_width) + margin) |
<button
class="inline-flex justify-center p-1 text-gray-500 rounded cursor-pointer hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-white dark:hover:bg-gray-600"
title="Show History"
hx-get="{{ url_for('workout.get_exercise_history', person_id=person_id, exercise_id=exercise_id, source_topset_id=latest_topset_id) }}"
hx-get="{{ url_for('workout.get_exercise_history', person_id=person_id, exercise_id=exercise_id, source_topset_id=latest_topset_id, forecast='true' if forecast_enabled else 'false', forecast_weeks=forecast_weeks, forecast_reps=forecast_target_reps) }}"
hx-target="#svg-plot-{{ unique_id }}" hx-swap="outerHTML">
<svg class="w-5 h-5 border border-gray-300 rounded p-0.5" fill="none" stroke="currentColor"
viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
@@ -140,7 +140,7 @@ M{% for value, position in lower_points %}{{ (((position * vb_width) + margin) |
</div>
</div>
{% if forecast.selected_top_set %}
<div class="mt-3 rounded-lg border border-emerald-100 bg-white/80 px-3 py-2.5">
<div class="mt-3 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 rounded-lg border border-emerald-100 bg-white/80 px-3 py-2.5">
<div class="flex items-center justify-between gap-2">
<div>
<div class="text-xs font-semibold uppercase tracking-wide text-gray-500">Projected top set</div>
@@ -151,38 +151,10 @@ M{% for value, position in lower_points %}{{ (((position * vb_width) + margin) |
<div class="font-semibold text-emerald-700">{{ forecast.selected_top_set.lower_weight_display }}–{{ forecast.selected_top_set.upper_weight_display }}kg</div>
</div>
</div>
<div class="text-[11px] text-gray-500 mt-2">
Based on {{ forecast.observed_rep_min }}–{{ forecast.observed_rep_max }} reps in view, expanded by ±{{ forecast.rep_buffer }} reps.
Click a row to use that rep target in the chart hover.
<div class="text-[11px] text-gray-500 sm:text-right">
Full rep-to-weight forecast in the table view.<br>
Based on {{ forecast.observed_rep_min }}–{{ forecast.observed_rep_max }} reps in view.
</div>
<div class="text-xs font-semibold text-gray-600 mt-3 mb-1">Rep-to-weight map</div>
<div class="mt-2 max-h-64 overflow-y-auto rounded border border-gray-100">
<table class="w-full text-xs text-left">
<thead class="sticky top-0 bg-gray-50 text-gray-500">
<tr>
<th class="px-2 py-1.5 font-medium">Reps</th>
<th class="px-2 py-1.5 font-medium">Est. load</th>
<th class="px-2 py-1.5 font-medium">Model range</th>
<th class="px-2 py-1.5 font-medium text-right">Proj. E1RM</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
{% for top_set in forecast.top_sets %}
<tr class="cursor-pointer {% if forecast.selected_reps == top_set.repetitions %}bg-emerald-50 text-emerald-800 font-semibold{% else %}bg-white text-gray-600 hover:bg-gray-50{% endif %}"
title="Use {{ top_set.repetitions }} reps for chart hover"
hx-get="{{ url_for('get_exercise_progress_for_user', person_id=person_id, exercise_id=exercise_id, epoch=selected_epoch, forecast='true', forecast_weeks=forecast_weeks, forecast_reps=top_set.repetitions) }}"
hx-include="#svg-plot-{{ unique_id }} [name='min_date'], #svg-plot-{{ unique_id }} [name='max_date'], #svg-plot-{{ unique_id }} [name='degree']"
hx-target="#svg-plot-{{ unique_id }}" hx-swap="outerHTML">
<td class="px-2 py-1.5">{{ top_set.repetitions }}</td>
<td class="px-2 py-1.5">{{ top_set.weight_display }}kg</td>
<td class="px-2 py-1.5">{{ top_set.lower_weight_display }}–{{ top_set.upper_weight_display }}kg</td>
<td class="px-2 py-1.5 text-right">{{ top_set.e1rm_display }}kg</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="text-[11px] text-gray-400 mt-2">Loads rounded to the nearest {{ forecast.target_weight_increment_display }}kg from your recorded increments.</div>
</div>
{% endif %}
<div class="flex flex-wrap items-center gap-2 mt-3">