{% extends '_base.html' %}
{% load helpers %}

{% block content %}
    <h1>{% block title %}Reports{% endblock %}</h1>
    <div class="row">
        <div class="col-md-9">
            {% for module, module_reports in reports %}
                <h3><a name="module.{{ module }}"></a>{{ module|bettertitle }}</h3>
                <table class="table table-hover table-headings reports">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Status</th>
                            <th>Description</th>
                            <th>Last Run</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for report in module_reports %}
                            <tr>
                                <td>
                                    <a href="{% url 'extras:report' name=report.full_name %}" name="report.{{ report.name }}"><strong>{{ report.name }}</strong></a>
                                </td>
                                <td>
                                    {% include 'extras/inc/report_label.html' %}
                                </td>
                                <td>{{ report.description|default:"" }}</td>
                                {% if report.result %}
                                    <td>{{ report.result.created }}</td>
                                {% else %}
                                    <td class="text-muted">Never</td>
                                {% endif %}
                            </tr>
                            {% for method, stats in report.result.data.items %}
                                <tr>
                                    <td colspan="3" class="method">
                                        {{ method }}
                                    </td>
                                    <td class="text-right stats">
                                        <label class="label label-success">{{ stats.success }}</label>
                                        <label class="label label-info">{{ stats.info }}</label>
                                        <label class="label label-warning">{{ stats.warning }}</label>
                                        <label class="label label-danger">{{ stats.failed }}</label>
                                    </td>
                                </tr>
                            {% endfor %}
                        {% endfor %}
                    </tbody>
                </table>
            {% endfor %}
        </div>
        <div class="col-md-3">
            <ul class="list-group">
                {% for module, module_reports in reports %}
                    <a href="#module.{{ module }}" class="list-group-item"><strong>{{ module|bettertitle }}</strong></a>
                    {% for report in module_reports %}
                        <a href="#report.{{ report.name }}" class="list-group-item">
                            {{ report.name }}
                            <div class="pull-right">
                                {% include 'extras/inc/report_label.html' %}
                            </div>
                        </a>
                    {% endfor %}
                {% endfor %}
            </ul>
        </div>
    </div>
{% endblock %}
