Refactor dashboard

This commit is contained in:
Peter Stockings
2025-01-27 14:46:20 +11:00
parent a7592a29f6
commit f70438e4e4
5 changed files with 335 additions and 218 deletions

View File

@@ -20,10 +20,8 @@
placeholder: 'Filter people',
})
end">
{% for p in people %}
<option value="{{ p['PersonId'] }}" {% if p['PersonId'] in selected_person_ids %}selected{%
endif %}>{{
p['Name']
{% for person in people %}
<option value="{{ person.id }}" {% if person.selected %}selected{% endif %}>{{ person.name
}}</option>
{% endfor %}
</select>
@@ -47,9 +45,9 @@
placeholder: 'Filter exercises',
})
end">
{% for e in exercises %}
<option value="{{ e.exercise_id }}" {% if e.exercise_id in selected_exercise_ids
%}selected{% endif %}>{{ e.name }}</option>
{% for exercise in exercises %}
<option value="{{ exercise.id }}" {% if exercise.selected %}selected{% endif %}>
{{ exercise.name }}</option>
{% endfor %}
</select>
</div>
@@ -102,7 +100,7 @@
hx-target="this" hx-swap="outerHTML">
</div>
{% if model['People']|length == 0 %}
{% if dashboard|length == 0 %}
<div class="bg-purple-100 rounded-lg py-5 px-6 mb-4 text-base text-purple-700 mb-3" role="alert" id="no-workouts">
No workouts selected.
</div>
@@ -110,36 +108,35 @@
<div class="w-full grid grid-cols-1 xl:grid-cols-3 2xl:grid-cols-3 gap-4">
{% for p in model['People'] %}
{% for person in dashboard %}
<div class="bg-white shadow rounded-lg p-4 sm:p-6 xl:p-8 ">
<div class="mb-4 flex items-center justify-between">
<div>
<h3 class="text-xl font-bold text-gray-900 mb-2">{{ p['PersonName'] }}</h3>
<h3 class="text-xl font-bold text-gray-900 mb-2">{{ person.name }}</h3>
<span class="text-base font-normal text-gray-500">Current rep maxes</span>
</div>
<div class="flex-shrink-0">
<a hx-get="{{ url_for('get_calendar' ,person_id=p['PersonId']) }}" hx-push-url="true"
hx-target="#container"
<a hx-get="{{ url_for('get_calendar', person_id=person.id) }}" hx-push-url="true" hx-target="#container"
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg p-2 cursor-pointer">View
workouts</a>
</div>
</div>
{% if p['NumberOfWorkouts'] == 0 %}
{% if person.exercises|length == 0 %}
<div class="bg-purple-100 rounded-lg py-5 px-6 mb-4 text-base text-purple-700 mb-3" role="alert">
No workouts completed.
</div>
{% endif %}
{% for e in p['Exercises'] %}
{% if e['Topsets']|length > 1 %}
{% for exercise in person.exercises %}
{% if exercise.sets|length > 1 %}
<div class="flex flex-col mt-8">
<div class="overflow-x-auto rounded-lg">
<div class="align-middle inline-block min-w-full">
<div class="shadow overflow-hidden sm:rounded-lg">
<div class="w-full mt-2 pb-2 aspect-video">
{{ render_partial('partials/sparkline.html', **e['ExerciseProgressGraph']) }}
{{ render_partial('partials/sparkline.html', **exercise.graph) }}
</div>
<table class="min-w-full divide-y divide-gray-200">
@@ -161,16 +158,19 @@
</thead>
<tbody class="bg-white">
{% for rm in e['Topsets'] %}
<tr>
{% for set in exercise.sets %}
<tr hx-get="{{ url_for('goto_tag') }}"
hx-vals='{"filter": "?exercise_id={{ set.exercise_id }}", "person_id" : "{{ person.id }}" }'
hx-target="#container" hx-swap="innerHTML" hx-push-url="true"
class="cursor-pointer">
<td class="p-4 whitespace-nowrap text-sm font-normal text-gray-500">
{{ rm['StartDate'] }}
{{ set.workout_start_date | strftime("%b %d %Y") }}
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
{{ rm['Repetitions'] }} x {{ rm['Weight'] }}kg
{{ set.reps }} x {{ set.weight }}kg
</td>
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
{{ rm['Estimated1RM'] }}kg
{{ set.estimated_1rm }}kg
</td>
</tr>
{% endfor %}