110 lines
5.0 KiB
HTML
110 lines
5.0 KiB
HTML
{% extends "base.html" %}
|
|
{% block title %}Dashboard — Meal Tracker{% endblock %}
|
|
{% block content %}
|
|
|
|
<div class="dashboard-header">
|
|
<h2>
|
|
{% if history_mode %}History — {{ viewing_date.isoformat() }}{% else %}Today's Meals{% endif %}
|
|
</h2>
|
|
<div class="date-nav">
|
|
<a class="btn btn-sm" href="?date={{ prev_date.isoformat() }}">◀ Prev</a>
|
|
<span class="date-display">{{ viewing_date.isoformat() }}</span>
|
|
<a class="btn btn-sm" href="?date={{ next_date.isoformat() }}">Next ▶</a>
|
|
{% if viewing_date != today %}
|
|
<a class="btn btn-sm" href="{{ url_for('meals.dashboard') }}">Today</a>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
{% if not dashboard.users %}
|
|
<p class="empty-state">No registered users yet. Ask household members to register!</p>
|
|
{% else %}
|
|
<div class="table-wrapper">
|
|
<table class="meal-table">
|
|
<thead>
|
|
<tr>
|
|
<th>User</th>
|
|
{% for period in dashboard.periods %}
|
|
<th class="meal-col">{{ period.meal_type|capitalize }}</th>
|
|
{% endfor %}
|
|
{% if is_admin %}
|
|
<th class="action-col"></th>
|
|
{% endif %}
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for user in dashboard.users %}
|
|
{% set is_me = user.id == current_user_id %}
|
|
<tr>
|
|
<td class="user-cell">
|
|
{{ user.username }}
|
|
{% if user.is_admin %}<span class="admin-tag">admin</span>{% endif %}
|
|
{% if is_me %}<span class="you-tag">you</span>{% endif %}
|
|
</td>
|
|
{% for period in dashboard.periods %}
|
|
{% set resp = user.responses[period.meal_type] %}
|
|
<td class="response-cell status-{{ resp.status }}{% if resp.changed_at %} changed-mind{% endif %}">
|
|
{% if is_me and viewing_date >= today %}
|
|
<form method="POST" action="{{ url_for('meals.respond') }}" class="respond-form">
|
|
<input type="hidden" name="date" value="{{ viewing_date.isoformat() }}">
|
|
<input type="hidden" name="meal_type" value="{{ period.meal_type }}">
|
|
<div class="btn-row">
|
|
<button name="status" value="yes"
|
|
class="chip chip-yes {% if resp.status == 'yes' %}active{% endif %}"
|
|
>Home</button>
|
|
<button name="status" value="no"
|
|
class="chip chip-no {% if resp.status == 'no' %}active{% endif %}"
|
|
>Out</button>
|
|
</div>
|
|
</form>
|
|
{% if resp.changed_at %}
|
|
<div class="changed-badge" title="Changed mind at {{ resp.changed_at }}">↻ {{ resp.changed_at[11:16] }}</div>
|
|
{% endif %}
|
|
{% else %}
|
|
<span class="badge badge-{{ resp.status }}">{{ 'Home' if resp.status == 'yes' else ('Out' if resp.status == 'no' else '—') }}</span>
|
|
{% endif %}
|
|
</td>
|
|
{% endfor %}
|
|
{% if is_admin and not is_me and not user.is_admin %}
|
|
<td class="action-cell">
|
|
<form method="POST" action="{{ url_for('meals.admin_remove_user', user_id=user.id) }}"
|
|
onsubmit="return confirm('Remove {{ user.username }} from this household?');">
|
|
<button class="btn btn-sm btn-danger">Remove</button>
|
|
</form>
|
|
</td>
|
|
{% elif is_admin %}
|
|
<td class="action-cell"></td>
|
|
{% endif %}
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="manage-section">
|
|
<details class="manage-details">
|
|
<summary>⚙ Account Settings</summary>
|
|
<div class="manage-forms">
|
|
<form method="POST" action="{{ url_for('meals.delete_account') }}"
|
|
onsubmit="return confirm('Delete YOUR account? This cannot be undone.');" class="manage-form">
|
|
<h4>Delete My Account</h4>
|
|
<input type="password" name="password" placeholder="Enter your password to confirm" required>
|
|
<button class="btn btn-danger">Delete My Account</button>
|
|
</form>
|
|
|
|
{% if is_admin %}
|
|
<form method="POST" action="{{ url_for('meals.admin_delete_household') }}"
|
|
onsubmit="return confirm('Delete the ENTIRE household and ALL members? This cannot be undone.');" class="manage-form">
|
|
<h4>Delete Household</h4>
|
|
<p class="hint">This will remove all users and all data in this household.</p>
|
|
<input type="password" name="password" placeholder="Enter your password to confirm" required>
|
|
<button class="btn btn-danger">Delete Household</button>
|
|
</form>
|
|
{% endif %}
|
|
</div>
|
|
</details>
|
|
</div>
|
|
|
|
{% endblock %}
|