{% extends "page.html" %}

{% block title %}
{{ _('Status') }}
{% endblock %}

{% block breadcrumb_content %}
<li class="active">
    <a class="active"
       href="{{ h.url_for('status.index') }}">Status</a>
</li>
{% endblock %}

{% macro report_grid(report_list) %}
<div class="status-grid">
    {% for item in report_list %}
    <div class="status-item status-item--{{ item.state }}">
        <span class="status-item-label">{{ item.label }}</span>
        <span class="status-item-value">{{ item.value }}</span>
        {% if item.help %}
        <div class="status-item-help">
            <i class="fas fa-info-circle fa-sm"></i>
            <div>{{ item.help }}</div>
        </div>
        {% endif %}
    </div>
    {% endfor %}
</div>
{% endmacro %}

{% block pre_primary %}
{% asset 'ckanext-status/main' %}
<article class="module">
    <div class="module-content">
        <h1 class="page-heading">Status</h1>
        <div class="status-subheading">
            <span class="status-updated">Last updated: {{ updated_at.strftime('%Y-%m-%d %H:%M:%S') }}</span>
            <button onclick="window.location.reload()" class="btn btn-primary">
                <i class="fas fa-refresh"></i> Refresh status</button>
        </div>

        <div class="status-message">
            {% if h.status_enable_html() %}
                {{ h.status_get_message()|safe }}
            {% else %}
                {{ h.status_get_message() }}
            {% endif %}
        </div>

        {{ report_grid(reports['_root']) }}

        {% for group, group_reports in reports.items() if group != '_root' %}
        <h2 class="status-group-title">{{ group }}</h2>
        {{ report_grid(group_reports) }}
        {% endfor %}
    </div>
</article>
{% endblock %}
