Refactor routes.py
This commit is contained in:
@@ -51,11 +51,11 @@
|
||||
</li>
|
||||
<li class="mr-3">
|
||||
<a class="inline-block py-2 px-4 no-underline
|
||||
{% if request.path == url_for('main.manage_data') %}
|
||||
{% if request.path == url_for('data.manage_data') %}
|
||||
text-white
|
||||
{% else %}
|
||||
text-gray-600 hover:text-gray-200 hover:text-underline
|
||||
{% endif %}" href="{{ url_for('main.manage_data') }}">Data
|
||||
{% endif %}" href="{{ url_for('data.manage_data') }}">Data
|
||||
</a>
|
||||
</li>
|
||||
<li class="mr-3">
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<span>Back</span>
|
||||
</a>
|
||||
<h1 class="text-3xl font-bold text-center text-gray-800 mb-6">Add Reading</h1>
|
||||
<form method="POST" action="{{ url_for('main.add_reading') }}" novalidate class="space-y-6">
|
||||
<form method="POST" action="{{ url_for('reading.add_reading') }}" novalidate class="space-y-6">
|
||||
{{ form.hidden_tag() }}
|
||||
|
||||
<!-- Timestamp Field -->
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
class="px-4 py-2 bg-gray-300 text-gray-700 rounded hover:bg-gray-400">
|
||||
Cancel
|
||||
</a>
|
||||
<form method="POST" action="{{ url_for('main.confirm_delete', reading_id=reading.id) }}">
|
||||
<form method="POST" action="{{ url_for('reading.confirm_delete', reading_id=reading.id) }}">
|
||||
<button type="submit" class="px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700">
|
||||
Confirm
|
||||
</button>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<!-- 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('main.add_reading') }}"
|
||||
<a rel="prefetch" href="{{ url_for('reading.add_reading') }}"
|
||||
class="bg-blue-600 text-white px-4 py-2 rounded shadow hover:bg-blue-700">
|
||||
+ Add New Reading
|
||||
</a>
|
||||
@@ -98,7 +98,7 @@
|
||||
<!-- List -->
|
||||
<div x-show="activeView === 'list'" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{% for reading in readings %}
|
||||
<a href="{{ url_for('main.edit_reading', reading_id=reading.id) }}"
|
||||
<a href="{{ url_for('reading.edit_reading', reading_id=reading.id) }}"
|
||||
class="bg-white shadow-md rounded-lg p-4 flex flex-col justify-between relative hover:shadow-lg transition-shadow">
|
||||
<!-- Timestamp -->
|
||||
<div class="absolute top-2 right-2 flex items-center text-gray-400 text-xs">
|
||||
@@ -155,7 +155,7 @@
|
||||
<div class="text-sm font-bold text-gray-500">{{ day.strftime('%a, %b %d') }}</div>
|
||||
{% if day in readings_by_date %}
|
||||
{% for reading in readings_by_date[day]|sort(attribute="timestamp", reverse = True) %}
|
||||
<a href="{{ url_for('main.edit_reading', reading_id=reading.id) }}"
|
||||
<a href="{{ url_for('reading.edit_reading', reading_id=reading.id) }}"
|
||||
class="block mt-2 p-0 md:p-2 bg-green-100 rounded-lg shadow hover:bg-green-200 transition">
|
||||
<p class="text-xs font-medium text-green-800">
|
||||
{{ reading.systolic }}/{{ reading.diastolic }} mmHg
|
||||
@@ -223,7 +223,7 @@
|
||||
<span class="text-gray-500 font-semibold">{{ day.day }}</span>
|
||||
</div>
|
||||
{% for reading in day.readings %}
|
||||
<a href="{{ url_for('main.edit_reading', reading_id=reading.id) }}"
|
||||
<a href="{{ url_for('reading.edit_reading', reading_id=reading.id) }}"
|
||||
class="block mt-2 p-0 md:p-2 bg-green-100 rounded-lg shadow hover:bg-green-200 transition">
|
||||
<p class="text-xs font-medium text-green-800">
|
||||
{{ reading.systolic }}/{{ reading.diastolic }} mmHg
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<!-- Import Data Section -->
|
||||
<div class="bg-white p-6 rounded-lg shadow-md mb-6">
|
||||
<h2 class="text-lg font-semibold mb-4">Import Data</h2>
|
||||
<form method="POST" action="{{ url_for('main.manage_data') }}" enctype="multipart/form-data">
|
||||
<form method="POST" action="{{ url_for('data.manage_data') }}" enctype="multipart/form-data">
|
||||
<label for="file" class="block text-sm font-medium text-gray-700 mb-2">Upload CSV File</label>
|
||||
<input type="file" name="file" id="file"
|
||||
class="w-full p-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
||||
@@ -30,7 +30,7 @@
|
||||
<!-- Export Data Section -->
|
||||
<div class="bg-white p-6 rounded-lg shadow-md">
|
||||
<h2 class="text-lg font-semibold mb-4">Export Data</h2>
|
||||
<a href="{{ url_for('main.export_data') }}"
|
||||
<a href="{{ url_for('data.export_data') }}"
|
||||
class="bg-green-600 text-white px-6 py-2 rounded-lg shadow-md hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500">
|
||||
Download CSV
|
||||
</a>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
</a>
|
||||
|
||||
<!-- Delete Button (Top-Right) -->
|
||||
<a href="{{ url_for('main.confirm_delete', reading_id=reading.id) }}"
|
||||
<a href="{{ url_for('reading.confirm_delete', reading_id=reading.id) }}"
|
||||
class="absolute top-4 right-4 text-red-500 hover:text-red-700">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
|
||||
class="size-6">
|
||||
@@ -23,7 +23,7 @@
|
||||
</a>
|
||||
|
||||
<h1 class="text-2xl font-bold mb-4 text-center">Edit Reading</h1>
|
||||
<form method="POST" action="{{ url_for('main.edit_reading', reading_id=reading.id) }}" novalidate
|
||||
<form method="POST" action="{{ url_for('reading.edit_reading', reading_id=reading.id) }}" novalidate
|
||||
class="bg-white p-8 rounded-lg shadow-md">
|
||||
{{ form.hidden_tag() }}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user