{% import "components.html" as c with context %}
{% import "agent_form.html" as f with context %}
{# how the agent is doing, as its computer last said: whether it runs, and
for each channel whether it is up, who it is there, since when, when it
last heard anything, and what last went wrong #}
{% macro field(label) -%}
{{ caller() }}
{%- endmacro %}
{% if health is none %}
{{ c.empty(t.text("agents.no_status"), "monitor") }}
{% else %}
{# a computer gone offline says nothing now: its last beat is not how
the agent is #}
{% if selected.status == "offline" %}
{% call field("agent") %}{{ t.text("agents.health.offline") }}{% endcall %}
{% else %}
{% call field("agent") %}{{ t.text("agents.health." ~ ("running" if health.running else ("troubled" if health.status == "started" else "stopped"))) }}{% endcall %}
{% if health.status != "started" %}
{{ health.status }}
{% endif %}
{% for problem in health.problems %}
{{ problem }}
{% endfor %}
{% endif %}
{# what it used today, as the card by its face says #}
{% if usage %}