Initial commit with webpage

This commit is contained in:
bkelldog committed 2026-11-06 11:42:34 -05:00
commit 26875de1dd
55 files changed
+5726

No files matched your search

+103
View File
@@ -0,0 +1,103 @@
{% extends "base.html" %}
{% block title %}Settings{% endblock %}
{% block content %}
<section class="card" id="profile">
<h2>Baby</h2>
<form method="post" action="/settings/profile" class="form-grid">
<label>Name
<input type="text" name="baby_name" value="{{ profile.baby_name }}" maxlength="80" required>
</label>
<label>Birth date
<input type="date" name="birth_date" value="{{ profile.birth_date.isoformat() if profile.birth_date else '' }}">
</label>
<label>Timezone
<select name="timezone" data-tz-select>
{% for z in zones %}<option {% if z == profile.timezone %}selected{% endif %}>{{ z }}</option>{% endfor %}
{% if profile.timezone not in zones %}<option selected>{{ profile.timezone }}</option>{% endif %}
</select>
</label>
<label><span>Device sync interval <span class="muted">(minutes)</span></span>
<input type="number" name="sync_interval_min" value="{{ profile.sync_interval_min }}" min="5" max="1440" step="5">
</label>
<label class="check span-2">
<input type="checkbox" name="clock_24h" value="true" {% if profile.clock_24h %}checked{% endif %}>
24-hour clock
</label>
<div class="span-2"><button class="btn">Save</button></div>
</form>
</section>
<section class="card" id="buttons">
<h2>Buttons</h2>
<p class="muted small">What each button on the Mamadachi logs (SW1–SW8 on the board). Changes reach the device at its next sync; presses already logged keep their type.</p>
<form method="post" action="/settings/buttons">
<div class="button-grid">
{% for n, k in buttons.items() %}
<label class="button-slot">
<span class="button-num">{{ n }}</span>
<select name="button_{{ n }}">
<option value="">— unassigned —</option>
{% for kind in kinds if kind.active or (k and kind.slug == k.slug) %}
<option value="{{ kind.slug }}" {% if k and kind.slug == k.slug %}selected{% endif %}>{{ kind.emoji }} {{ kind.label }}</option>
{% endfor %}
</select>
</label>
{% endfor %}
</div>
<button class="btn">Save layout</button>
</form>
</section>
<section class="card" id="kinds">
<h2>Event types</h2>
<p class="muted small">
<strong>Single press</strong>: each press is one event (a diaper).
<strong>Start / stop</strong>: the first press starts it, the next ends it (sleep). If a start is older than <em>auto-close</em> minutes, the next press starts a new one instead, so a forgotten stop doesn't become a 2-day nap.
</p>
<form method="post" action="/settings/kinds">
<div class="kinds">
{% for k in kinds %}
<fieldset class="kind-row{% if not k.active %} is-hidden{% endif %}">
<legend><span class="dot cat-{{ k.category }}"></span>{{ categories[k.category] }}</legend>
<label class="k-emoji">Icon<input type="text" name="{{ k.slug }}__emoji" value="{{ k.emoji }}" maxlength="8"></label>
<label class="k-label">Name<input type="text" name="{{ k.slug }}__label" value="{{ k.label }}" maxlength="40" required></label>
<label class="k-short">On device<input type="text" name="{{ k.slug }}__short" value="{{ k.short }}" maxlength="10"></label>
<label class="k-mode">Press
<select name="{{ k.slug }}__mode">
<option value="instant" {% if not k.is_duration %}selected{% endif %}>Single press</option>
<option value="duration" {% if k.is_duration %}selected{% endif %}>Start / stop</option>
</select>
</label>
<label class="k-max"><span>Auto-close <span class="muted">min</span></span><input type="number" name="{{ k.slug }}__max" value="{{ k.max_minutes or '' }}" min="1" max="2880"></label>
<label class="check k-active"><input type="checkbox" name="{{ k.slug }}__active" {% if k.active %}checked{% endif %} {% if k.slug == 'other' %}disabled checked{% endif %}> Show</label>
</fieldset>
{% endfor %}
</div>
<button class="btn">Save types</button>
</form>
<details class="add-kind">
<summary><h3>Add a type</h3></summary>
<form method="post" action="/settings/kinds/new" class="form-grid">
<label>Name<input type="text" name="label" maxlength="40" required placeholder="e.g. Vitamin D"></label>
<label><span>Icon <span class="muted">(an emoji)</span></span><input type="text" name="emoji" maxlength="8"></label>
<label>Group
<select name="category">{% for key, label in categories.items() %}<option value="{{ key }}">{{ label }}</option>{% endfor %}</select>
</label>
<label>Press
<select name="mode"><option value="instant">Single press</option><option value="duration">Start / stop</option></select>
</label>
<div class="span-2"><button class="btn">Add type</button></div>
</form>
</details>
</section>
<section class="card" id="data">
<h2>Your data</h2>
<ul class="plain links">
<li><a href="/api/v1/export.csv">Download every event as a spreadsheet (CSV)</a></li>
<li><a href="/api/v1/export.json">Download a full backup (JSON)</a></li>
<li><a href="/docs">API documentation</a> <span class="muted small">for scripts and the firmware</span></li>
</ul>
</section>
{% endblock %}