💄 — Better display of results’ error details

This commit is contained in:
Luc Didry 2024-09-26 11:43:34 +02:00
parent 0ed60508e9
commit 0058e05f15
No known key found for this signature in database
GPG key ID: EA868E12D0257E3C
4 changed files with 56 additions and 5 deletions

View file

@ -8,6 +8,7 @@
- ✨ — Add new check type: http-to-https (#61) - ✨ — Add new check type: http-to-https (#61)
- 👷 — Remove Unreleased section from CHANGELOG when publishing documentation - 👷 — Remove Unreleased section from CHANGELOG when publishing documentation
- 🩹 — Severity of ssl-certificate-expirations errors is now UNKNOWN (#60) - 🩹 — Severity of ssl-certificate-expirations errors is now UNKNOWN (#60)
- 💄 — Better display of results error details
## 0.4.1 ## 0.4.1

View file

@ -14,6 +14,7 @@ from passlib.context import CryptContext
from sqlalchemy import func from sqlalchemy import func
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
from argos.checks.base import Status
from argos.schemas import Config from argos.schemas import Config
from argos.server import queries from argos.server import queries
from argos.server.models import Result, Task, User from argos.server.models import Result, Task, User
@ -190,7 +191,7 @@ async def get_result_view(
"""Show the details of a result""" """Show the details of a result"""
result = db.query(Result).get(result_id) result = db.query(Result).get(result_id)
return templates.TemplateResponse( return templates.TemplateResponse(
"result.html", {"request": request, "result": result} "result.html", {"request": request, "result": result, "error": Status.ERROR}
) )
@ -220,6 +221,7 @@ async def get_task_results_view(
"results": results, "results": results,
"task": task, "task": task,
"description": description, "description": description,
"error": Status.ERROR,
}, },
) )

View file

@ -3,7 +3,11 @@
{% block content %} {% block content %}
<dl> <dl>
<dt>Task</dt> <dt>Task</dt>
<dd>{{ result.task }}</dd> <dd>
<a href="{{ url_for('get_task_results_view', task_id=result.task.id) }}">
{{ result.task }}
</a>
</dd>
<dt>Submitted at</dt> <dt>Submitted at</dt>
<dd>{{ result.submitted_at }}</dd> <dd>{{ result.submitted_at }}</dd>
<dt>Status</dt> <dt>Status</dt>
@ -11,6 +15,26 @@
<dt>Severity</dt> <dt>Severity</dt>
<dd>{{ result.severity }}</dd> <dd>{{ result.severity }}</dd>
<dt>Context</dt> <dt>Context</dt>
<dd>{{ result.context }}</dd> <dd>
{% 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 %}
</dd>
</dl> </dl>
{% endblock content %} {% endblock content %}

View file

@ -14,10 +14,34 @@
<tbody> <tbody>
{% for result in results %} {% for result in results %}
<tr id="{{ result.id }}"> <tr id="{{ result.id }}">
<td>{{ result.submitted_at }}</td> <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.status }}</td>
<td>{{ result.severity }}</td> <td>{{ result.severity }}</td>
<td>{{ result.context }}</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> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>