{% extends "base.html" %}
{% block title %}<h2>{{ task }}</h2>{% endblock title %}
{% block content %}
<code>{{ description }}</code>
<table role="grid">
    <thead>
        <tr>
            <th>Submitted at</th>
            <th>Status</th>
            <th>Severity</th>
            <th>Context</th>
        </tr>
    </thead>
    <tbody>
        {% for result in results %}
        <tr id="{{ result.id }}">
            <td>
                <a href="{{ url_for('get_result_view', result_id=result.id) }}" title="See details of result {{ result.id }}">
                    {{ result.submitted_at }}
                </a>
            </td>
            <td>{{ result.status }}</td>
            <td>{{ result.severity }}</td>
            <td>
                {% if result.status != error %}
                {{ result.context }}
                {% else %}
                <dl>
                    {% if result.context["error_message"] %}
                    <dt>Error message</dt>
                    <dd>{{ result.context["error_message"] }}</dd>
                    {% endif %}
                    <dt>Error type</dt>
                    <dd>{{ result.context["error_type"] }}</dd>
                    <dt>Error details</dt>
                    <dd>
                        <details>
                            <summary>{{ result.context["error_details"] | truncate(120, False, "…") }} (click to expand)</summary>
                            <pre><code>{{ result.context["error_details"] | replace("\n", "<br>") | safe }}</code></pre>
                        </details>
                    </dd>
                </dl>
                {% endif %}
            </td>
        </tr>
        {% endfor %}
    </tbody>
</table>
{% endblock content %}
