112 lines
5.6 KiB
HTML
112 lines
5.6 KiB
HTML
{% extends "_layout.html" %}
|
|
{% block content %}
|
|
<div class="max-w-5xl mx-auto p-4 space-y-6">
|
|
<!-- Header Section with "Add New Reading" Button -->
|
|
<div class="flex justify-between items-center">
|
|
<h1 class="text-2xl font-bold text-gray-800">Dashboard</h1>
|
|
<a rel="prefetch" href="{{ url_for('reading.add_reading') }}"
|
|
class="bg-primary-600 text-white px-4 py-2 rounded shadow hover:bg-primary-700">
|
|
+ Add New Reading
|
|
</a>
|
|
</div>
|
|
|
|
<!-- Weekly Summary -->
|
|
<div class="bg-gradient-to-r from-primary-500 to-primary-700 text-white p-6 rounded-xl shadow-md">
|
|
<h3 class="text-lg font-bold">Weekly Summary</h3>
|
|
<div class="flex justify-between mt-4">
|
|
<div>
|
|
<p class="text-sm font-semibold">Systolic Average</p>
|
|
<p class="text-2xl">{{ systolic_avg }} <span class="text-base">mmHg</span></p>
|
|
</div>
|
|
<div>
|
|
<p class="text-sm font-semibold">Diastolic Average</p>
|
|
<p class="text-2xl">{{ diastolic_avg }} <span class="text-base">mmHg</span></p>
|
|
</div>
|
|
<div>
|
|
<p class="text-sm font-semibold">Heart Rate Average</p>
|
|
<p class="text-2xl">{{ heart_rate_avg }} <span class="text-base">bpm</span></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Progress Badges -->
|
|
<div>
|
|
<div class="flex flex-wrap gap-4">
|
|
{% for badge in badges %}
|
|
<div class="bg-green-100 text-green-800 px-4 py-2 rounded shadow text-sm font-medium">
|
|
{{ badge }}
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
|
|
<div x-data="{ open: {{ 'true' if request.method == 'POST' else 'false' }} }" class="relative">
|
|
<!-- Compact Icon -->
|
|
<button @click="open = !open"
|
|
class="bg-primary-600 text-white p-3 rounded-full shadow-lg focus:outline-none hover:bg-primary-700">
|
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2"
|
|
stroke="currentColor" class="w-6 h-6">
|
|
<path x-show="!open" stroke-linecap="round" stroke-linejoin="round" d="M6 9l6 6 6-6" />
|
|
<path x-show="open" x-cloak stroke-linecap="round" stroke-linejoin="round" d="M18 15l-6-6-6 6" />
|
|
</svg>
|
|
</button>
|
|
|
|
<!-- Collapsible Filter Form -->
|
|
<div x-show="open" x-transition.duration.300ms
|
|
class="w-full md:w-1/3 bg-white p-6 rounded-xl shadow-lg border border-gray-200">
|
|
<div class="flex justify-between items-center mb-4">
|
|
<h3 class="text-lg font-bold text-gray-800">Filter Readings</h3>
|
|
</div>
|
|
<form method="POST" action="{{ url_for('main.dashboard') }}" class="space-y-4">
|
|
<!-- Start Date -->
|
|
<div>
|
|
<label for="start_date" class="block text-sm font-medium text-gray-700">Start Date</label>
|
|
<input type="date" name="start_date" id="start_date"
|
|
class="w-full p-3 border border-gray-300 rounded-xl shadow-sm focus:outline-none focus:ring-2 focus:ring-primary-500">
|
|
</div>
|
|
|
|
<!-- End Date -->
|
|
<div>
|
|
<label for="end_date" class="block text-sm font-medium text-gray-700">End Date</label>
|
|
<input type="date" name="end_date" id="end_date"
|
|
class="w-full p-3 border border-gray-300 rounded-xl shadow-sm focus:outline-none focus:ring-2 focus:ring-primary-500">
|
|
</div>
|
|
|
|
<!-- Apply Button -->
|
|
<div>
|
|
<button type="submit"
|
|
class="w-full bg-primary-600 text-white py-2 rounded-xl font-semibold shadow-md hover:bg-primary-700 focus:outline-none">
|
|
Apply Filters
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="max-w-5xl mx-auto" x-data="{ activeView: '{{ active_view }}' }">
|
|
<!-- Tabs -->
|
|
<div class="flex border-b mb-4">
|
|
<button @click="activeView = 'list'" hx-get="{{ url_for('main.dashboard_list') }}"
|
|
hx-target="#dashboard-content" :class="{'border-primary-600 text-primary-600': activeView === 'list'}"
|
|
class="px-4 py-2 text-sm font-medium border-b-2">List View</button>
|
|
<button @click="activeView = 'weekly'" hx-get="{{ url_for('main.dashboard_weekly') }}"
|
|
hx-target="#dashboard-content" :class="{'border-primary-600 text-primary-600': activeView === 'weekly'}"
|
|
class="px-4 py-2 text-sm font-medium border-b-2">Weekly View</button>
|
|
<button @click="activeView = 'monthly'" hx-get="{{ url_for('main.dashboard_monthly') }}"
|
|
hx-target="#dashboard-content"
|
|
:class="{'border-primary-600 text-primary-600': activeView === 'monthly'}"
|
|
class="px-4 py-2 text-sm font-medium border-b-2">Monthly View</button>
|
|
<button @click="activeView = 'graph'" hx-get="{{ url_for('main.dashboard_graph') }}"
|
|
hx-target="#dashboard-content" :class="{'border-primary-600 text-primary-600': activeView === 'graph'}"
|
|
class="px-4 py-2 text-sm font-medium border-b-2">Graph View</button>
|
|
</div>
|
|
|
|
<!-- Dashboard Content Target Area for HTMX -->
|
|
<div id="dashboard-content">
|
|
{% include 'partials/dashboard_list.html' %}
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
{% endblock %} |