Files
agentbox-test/templates/dashboard.html
T
agentbox 2cd435daf2
CI / test-and-package (push) Successful in 36s
Add cron container and per-household timezone for auto-reminders
- docker-compose.yml: meal-cron service loops send_reminders_cron.py every 60s
- send_reminders_cron.py: checks each household's local time, sends ntfy
  reminders at 10:00 (lunch) and 16:00 (dinner), guarded against duplicates
- models.py: timezone, last_lunch_reminder, last_dinner_reminder on households
- meals.py: /admin/timezone route for admins to set household timezone
- dashboard: timezone selector (20 common zones) in Account Settings
- i18n: 5 new translation keys for timezone strings
- Dockerfile: copy send_reminders_cron.py
- tests: 4 new timezone tests (admin set, non-admin denied, default UTC, auth)
- docs: updated AGENTS.md
2026-08-01 06:23:33 +00:00

150 lines
8.0 KiB
HTML

{% extends "base.html" %}
{% block title %}{{ t('Dashboard — Meal Tracker') }}{% endblock %}
{% block content %}
<div class="dashboard-header">
<h2>
{% if history_mode %}{{ t('History — {date}', date=viewing_date.isoformat()) }}{% else %}{{ t("Today's Meals") }}{% endif %}
</h2>
<div class="date-nav">
<a class="btn btn-sm" href="?date={{ prev_date.isoformat() }}">{{ t('◀ Prev') }}</a>
<span class="date-display">{{ viewing_date.isoformat() }}</span>
<a class="btn btn-sm" href="?date={{ next_date.isoformat() }}">{{ t('Next ▶') }}</a>
{% if viewing_date != today %}
<a class="btn btn-sm" href="{{ url_for('meals.dashboard') }}">{{ t('Today') }}</a>
{% endif %}
</div>
</div>
{% if not dashboard.users %}
<p class="empty-state">{{ t('No registered users yet. Ask household members to register!') }}</p>
{% else %}
<div class="table-wrapper">
<table class="meal-table">
<thead>
<tr>
<th>{{ t('User') }}</th>
{% for period in dashboard.periods %}
<th class="meal-col">{{ t(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">{{ t('admin') }}</span>{% endif %}
{% if is_me %}<span class="you-tag">{{ t('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 %}"
>{{ t('Home') }}</button>
<button name="status" value="no"
class="chip chip-no {% if resp.status == 'no' %}active{% endif %}"
>{{ t('Out') }}</button>
</div>
</form>
{% if resp.changed_at %}
<div class="changed-badge" title="{{ t('Changed mind at {time}', time=resp.changed_at) }}">↻ {{ resp.changed_at[11:16] }}</div>
{% endif %}
{% else %}
<span class="badge badge-{{ resp.status }}">{{ t('Home') if resp.status == 'yes' else (t('Out') if resp.status == 'no' else t('—')) }}</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(this.dataset.confirmMsg);"
data-confirm-msg="{{ t('Remove {name} from this household?', name=user.username) }}">
<button class="btn btn-sm btn-danger">{{ t('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>{{ t('⚙ Account Settings') }}</summary>
<div class="manage-forms">
<form method="POST" action="{{ url_for('meals.delete_account') }}"
onsubmit="return confirm(this.dataset.confirmMsg);"
data-confirm-msg="{{ t('Delete YOUR account? This cannot be undone.') }}"
class="manage-form">
<h4>{{ t('Delete My Account') }}</h4>
<input type="password" name="password" placeholder="{{ t('Enter your password to confirm') }}" required>
<button class="btn btn-danger">{{ t('Delete My Account') }}</button>
</form>
<form method="POST" action="{{ url_for('meals.ntfy_settings') }}" class="manage-form">
<h4>🔔 {{ t('Ntfy Notifications') }}</h4>
<p class="hint">{{ t('Get meal reminders on your phone via ntfy.') }}</p>
<label for="ntfy_url">{{ t('Ntfy Topic URL') }}</label>
<input type="text" id="ntfy_url" name="ntfy_url"
placeholder="https://ntfy.sh/your-topic"
value="{{ ntfy.ntfy_url or '' }}">
<label for="ntfy_token">{{ t('Access Token') }} <span class="hint">{{ t('(optional)') }}</span></label>
<input type="password" id="ntfy_token" name="ntfy_token"
placeholder="tk_..."
value="{{ ntfy.ntfy_token or '' }}">
<div class="btn-row" style="margin-top: 8px;">
<button type="submit" class="btn btn-primary btn-sm">{{ t('Save') }}</button>
<button type="submit" class="btn btn-sm" formaction="{{ url_for('meals.ntfy_test') }}">{{ t('Send Test') }}</button>
</div>
</form>
{% if is_admin %}
<form method="POST" action="{{ url_for('meals.admin_set_timezone') }}" class="manage-form">
<h4>🕐 {{ t('Household Timezone') }}</h4>
<p class="hint">{{ t('Used to send reminders at 10:00 (lunch) and 16:00 (dinner) local time.') }}</p>
<select name="timezone" class="select-input">
{% set tz = household.timezone or 'UTC' %}
{% for zone in ['UTC', 'Europe/Zurich', 'Europe/Paris', 'Europe/Berlin', 'Europe/London',
'America/New_York', 'America/Chicago', 'America/Denver', 'America/Los_Angeles',
'America/Toronto', 'America/Sao_Paulo', 'America/Argentina/Buenos_Aires',
'Asia/Tokyo', 'Asia/Shanghai', 'Asia/Kolkata', 'Asia/Dubai',
'Australia/Sydney', 'Pacific/Auckland', 'Africa/Cairo', 'Africa/Johannesburg'] %}
<option value="{{ zone }}" {% if zone == tz %}selected{% endif %}>{{ zone }}</option>
{% endfor %}
</select>
<button type="submit" class="btn btn-primary btn-sm" style="margin-top: 8px;">{{ t('Save') }}</button>
</form>
{% endif %}
{% if is_admin %}
<form method="POST" action="{{ url_for('meals.admin_delete_household') }}"
onsubmit="return confirm(this.dataset.confirmMsg);"
data-confirm-msg="{{ t('Delete the ENTIRE household and ALL members? This cannot be undone.') }}"
class="manage-form">
<h4>{{ t('Delete Household') }}</h4>
<p class="hint">{{ t('This will remove all users and all data in this household.') }}</p>
<input type="password" name="password" placeholder="{{ t('Enter your password to confirm') }}" required>
<button class="btn btn-danger">{{ t('Delete Household') }}</button>
</form>
{% endif %}
</div>
</details>
</div>
{% endblock %}