{#- ═══════════════════════════════════════════════════════ Shared fragments, in the service's own vocabulary. Every one of these obeys the two disciplines that get broken by reflex: nothing is enclosed in a border or a box, and every bar is drawn at the one shared width so any two percentages in the service compare directly. ═══════════════════════════════════════════════════════ -#} {#- A degraded service. Teletext's failure was a page that did not arrive, said in red where the content should have been — not a panel with an icon and a left border. -#} {% macro service_error(name, raw) %} {% endmacro %} {#- THE ONE RULER. Every bar in the service is drawn here and nowhere else, at --bar-cells wide, filled in whole cells. Pass a percentage; the macro rounds it to cells so a bar never ends mid-character. `tone` picks the colour by threshold. -#} {% macro bar(pct, tone='') %} {%- set p = [[pct | float(0), 0] | max, 100] | min -%} {%- set cells = 20 -%} {%- set filled = ((p / 100) * cells) | round(0, 'common') | int -%} {%- set cls = tone if tone else ('alert' if p >= 90 else ('warn' if p >= 75 else 'ok')) -%} {% endmacro %} {#- Direction of travel. Only ever called where the backend really carries a comparison — never to decorate a number that has no history behind it. -#} {% macro trend(now, reference, unit='') %} {%- if now is not none and reference is not none and reference > 0 -%} {%- set delta = ((now - reference) / reference) * 100 -%} {%- if delta > 12 -%} ▲ {%- elif delta < -12 -%} ▼ {%- else -%} ▬ {%- endif -%} {%- endif -%} {% endmacro %} {#- Disk temperature / spin state. A spun-down disk reports no usable temperature, so Standby replaces the reading rather than showing a stale or zero degree value. Colour carries the state; there is no badge shape to put it in. -#} {% macro disk_state(dk) %} {%- if dk.spinning == false -%} STANDBY {%- elif dk.temp is not none -%} {{ dk.temp }}°C {%- else -%} — {%- endif -%} {% endmacro %} {#- A title tile. Artwork is the only thing in this world not made of characters, so it sits as a flat rectangle on the grid with its label below — no frame, no rounding, no shadow. -#} {% macro tile(title, sub, poster, badge='', action='', target='') %}
{% if poster %} {% else %} {% endif %} {{ title }} {% if sub or badge %} {%- if badge %}{{ badge }}{% endif %} {%- if badge and sub %} {% endif %}{{ sub }} {% endif %} {% if action %} {% endif %}
{% endmacro %} {#- A list row: number, name, body, value. The index rows and every listing in the service share this one shape. -#} {% macro row(name, title, sub='', value='', tone='') %}
{% if name %}{{ name }}{% endif %} {{ title }} {% if sub %}{{ sub }}{% endif %} {% if value %}{{ value }}{% endif %}
{% endmacro %}