Make stats refresh, and add filter support to stats endpoint

This commit is contained in:
Peter Stockings
2025-01-26 23:01:39 +11:00
parent 23de6ef1f7
commit 527395d704
10 changed files with 73 additions and 65 deletions

View File

@@ -163,8 +163,10 @@
{% block content %}
{% endblock %}
</div>
{% block stats %}
{% endblock %}
<div id="stats">
{% block stats %}
{% endblock %}
</div>
</main>
</div>

View File

@@ -157,15 +157,14 @@
</div>
{% endif %}
</div>
</div>
{% endblock %}
{% block stats %}
<div class="hidden" hx-get="{{ url_for('get_stats_for_person', person_id=person_id) }}" hx-trigger="load"
hx-target="this" hx-swap="outerHTML">
hx-target="#stats" hx-swap="innerHTML">
</div>
</div>
{% endblock %}
{% block add_workout_button %}

View File

@@ -81,10 +81,16 @@
</div>
</div>
<div class="hidden" hx-get="{{ url_for('get_stats_for_person', person_id=person_id) }}" hx-trigger="load"
hx-target="#stats" hx-swap="innerHTML">
</div>
{% endblock %}
{% block add_workout_button %}
<button
class="fixed z-90 bottom-10 right-8 bg-blue-600 w-20 h-20 rounded-full drop-shadow-lg flex justify-center items-center text-white text-4xl hover:bg-blue-700 hover:drop-shadow-2xl hover:animate-bounce duration-300"
hx-post="{{ url_for('create_workout', person_id=person_id) }}" hx-target='body' hx-swap='beforeend'>
hx-post="{{ url_for('create_workout', person_id=person_id) }}" hx-push-url="true" hx-target="#container">
<svg viewBox="0 0 20 20" enable-background="new 0 0 20 20" class="w-6 h-6 inline-block">
<path fill="#FFFFFF" d="M16,10c0,0.553-0.048,1-0.601,1H11v4.399C11,15.951,10.553,16,10,16c-0.553,0-1-0.049-1-0.601V11H4.601
C4.049,11,4,10.553,4,10c0-0.553,0.049-1,0.601-1H9V4.601C9,4.048,9.447,4,10,4c0.553,0,1,0.048,1,0.601V9h4.399

View File

@@ -1,4 +1,5 @@
<div class="mt-4 mb-4 w-full grid grid-cols-1 md:grid-cols-3 2xl:grid-cols-4 gap-4">
<div class="mt-4 mb-4 w-full grid grid-cols-1 md:grid-cols-3 2xl:grid-cols-4 gap-4" hx-get="{{ refresh_url }}"
hx-target="this" hx-swap="outerHTML" hx-trigger="refreshStats from:body">
{% for stat in stats %}
<div class="bg-white shadow rounded-lg p-4 sm:p-6 xl:p-8 ">
<div class="flex items-center">

View File

@@ -159,11 +159,13 @@
</div>
</div>
<div class="hidden" hx-get="{{ url_for('get_stats_for_person', person_id=person_id) }}"
hx-include="[name='exercise_id'],[name='min_date'],[name='max_date']" hx-trigger="load" hx-target="#stats"
hx-swap="innerHTML">
</div>
{% endblock %}
{% block stats %}
{{ render_partial('partials/stats.html', stats=stats) }}
{% endblock %}
{% block add_workout_button %}
<button

View File

@@ -142,4 +142,8 @@
</div>
<div class="hidden" hx-get="{{ url_for('get_stats_for_person', person_id=person_id) }}" hx-trigger="load"
hx-target="#stats" hx-swap="innerHTML">
</div>
{% endblock %}