{% load vantage vantage_list i18n %}{% comment %} One dashboard card. A switch on `card.kind` and nothing else: every widget arrived here as plain data from vantage.dashboards, so this template computes nothing and can render a card whose Python failed just as happily as one whose Python worked. The error branch comes first and is deliberately per-card. A dashboard aggregates other people's queries; the one that 500s because a single custom aggregate broke is the one nobody leaves open on a second monitor. {% endcomment %}
{% if card.error %}

{{ card.label }}

{% translate "This card could not be computed." %}

{{ card.error }}

{% elif card.kind == "stat" %} {% if card.url %} {% include "vantage/partials/stat_card.html" with stat=card.stat %} {% else %} {% include "vantage/partials/stat_card.html" with stat=card.stat %} {% endif %} {% elif card.kind == "chart" %} {% comment %} The same markup the list page's analytics strip uses, so a chart looks identical wherever it appears and there is one place to change how charts are drawn. {% endcomment %}

{{ card.label }}

{% if card.chart.bucket %}{% blocktranslate with bucket=card.chart.bucket %}by {{ bucket }}{% endblocktranslate %}{% endif %}
{% if card.chart.error %}

{{ card.chart.error }}

{% elif card.chart.empty %}

{% translate "No data yet." %}

{% else %} {% chart_svg card.chart %} {% if card.chart.kind == "donut" or card.chart.kind == "bar" %}
    {% for label in card.chart.labels|slice:":6" %}
  • {{ label }}
  • {% endfor %}
{% elif card.chart.labels %}
{{ card.chart.labels|first }} {{ card.chart.labels|last }}
{% endif %} {% endif %}
{% elif card.kind == "table" %}

{{ card.label }}

{% if card.url %} {% translate "View all" %} {% endif %}
{% if card.rows %}
{% for column in card.columns %}{% endfor %} {% for row in card.rows %} {% for cell in row.cells %} {% endfor %} {% endfor %}
{{ column }}
{% if cell.is_link and row.url %} {% include "vantage/partials/cell_link.html" with url=row.url record=row.obj %} {% else %}{{ cell.value }}{% endif %}
{% else %}

{% translate "Nothing here yet." %}

{% endif %}
{% elif card.kind == "list" %}

{{ card.label }}

{% if card.items %}
{% for item in card.items %}
{% if item.url %}{{ item.label }} {% else %}{{ item.label }}{% endif %}
{{ item.value }}
{% endfor %}
{% else %}

{% translate "Nothing here yet." %}

{% endif %}
{% elif card.kind == "template" %} {% comment %} Already rendered to a string in Python, so a template that raises becomes an error card rather than an exception escaping mid-page. {% endcomment %} {{ card.html }} {% else %}

{{ card.label }}

{{ card.html }}
{% endif %}