{% extends "base.html" %} {% import "health/_parts.html" as hp with context %} {% import "health/_blk.html" as blk with context %} {% block title %}{{ {"overview": "Health", "body": "Body", "sleep": "Sleep", "heart": "Heart", "activity": "Activity"}[tab] }}{% endblock %} {% block head %}{{ hp.assets() }}{% endblock %} {% block main_attrs %} data-norefresh{% endblock %} {# Any health tab, drawn from its layout (blocks.py: an ordered list of {id, w}; the blocks are macros in _blocks.html): a few fixed parts, the shared range bar, the tiles row, the cards. Widths: --f = the share of the row (health.css: flex rows, exact with the gaps). Edit mode (⋮ ▸ Edit layout, layout.js): drag, resize, add (Overview), remove (Overview), save to /health/api/layout. #} {% macro dq(d) %}?d={{ d.isoformat() }}&r={{ V.sleep.range }}&g={{ V.sleep.grain }}{% endmacro %} {% block page %} {{ hp.head(tab, "bp" if tab == "heart" else "measure") }}
{# ---- fixed parts #} {% if tab in ("overview", "body") %}{{ hp.note() }}{% endif %} {% if tab == "activity" %}{% set p = V.activity.person %}{% if not (p.weight and p.age and p.height) %}
Calories need your weight (a measurement), height and birth date — Settings ▸ Health and the +.
{% endif %}{% endif %} {% if tab == "body" and not V.body.rows %}
No measurements yet. — a tape measure (waist, hips, neck) unlocks the body-fat formulas.
{% endif %} {% if tab == "sleep" %}{% set S = V.sleep %}{% if not S.night %}
No sleep data yet — it comes from the watch import.
{% else %}{% set t = S.night %}

{{ (t.day - t.day.resolution).strftime("%a %-d") }} → {{ t.day.strftime("%a %-d %b") }}{{ " " ~ t.day.year if t.day.year != v.today.year }}

{{ hp.night(t, S.hyp, S.goal) }}
{% endif %}{% endif %} {# ---- the range + grouping every tab shares (a cookie keeps them) #}

{{ v.ranges[v.range][0] }}{% if tab == "sleep" and V.sleep.night %} · {{ V.sleep.avg.n }} night{{ "s" if V.sleep.avg.n != 1 }}{% endif %}

{{ hp.ranges() }}
{% for it in items if B[it.id].kind == "tile" %}{{ blk.block(it) }}{% endfor %}
{% for it in items if B[it.id].kind == "card" %}{{ blk.block(it) }}{% endfor %}
{% endblock %} {% block scripts %}{{ hp.adder() }}{% endblock %}