Veiko Aasa 8775137546
diagnostics: Improve exception handling in app diagnostics
Fixes the problem when the app throws an error when running diagnostics,
the app's diagnostics page shows an html 500 error and on the diagnostics
app page, only an excpetion message is shown without other apps diagnostics.
(I encountered this when the network app diagnostics threw an exception
because of a particular network configuration.)

Tests performed:
- Checked that an app diagnostics page and the diagnostics app shows
all info correctly.
- Modified the networks app diagnostics code so that it throws an exception.
Checked that the app diagnostics page shows an exception message and
the diagnostics module shows all the apps and the networks app section
shows an exception message.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
[sunil: Re-add removed relevant comment]
[sunil: Remove ability to dismiss the exception message, not much gain for user]
[sunil: Remove unnecessary redundant if condition in template]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2020-12-13 15:21:52 -08:00

54 lines
1.5 KiB
HTML

{% extends 'app.html' %}
{% comment %}
# SPDX-License-Identifier: AGPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% load static %}
{% block configuration %}
{% if not is_running %}
<form class="form form-run-diagnostics" method="post"
action="{% url 'diagnostics:index' %}">
{% csrf_token %}
<input type="submit" class="btn btn-primary"
value="{% trans "Run Diagnostics" %}"/>
</form>
{% else %}
<p>{% trans "Diagnostics test is currently running" %}</p>
<div class="progress">
<div class="progress-bar progress-bar-striped active"
role="progressbar" aria-valuemin="0" aria-valuemax="100"
aria-valuenow="{{ results.progress_percentage }}"
style="width: {{ results.progress_percentage }}%">
{{ results.progress_percentage }}%
</div>
</div>
{% endif %}
{% if results %}
<h3>{% trans "Results" %}</h3>
{% for app_id, app_data in results.results.items %}
<h4>
{% blocktrans with app_name=app_data.name %}
App: {{app_name}}
{% endblocktrans %}
</h4>
{% if app_data.diagnosis %}
{% include "diagnostics_results.html" with results=app_data.diagnosis %}
{% elif app_data.exception %}
<div class="alert alert-danger" role="alert">
{{ app_data.exception }}
</div>
{% else %}
<p><span class="fa fa-hourglass-o"></span></p>
{% endif %}
{% endfor %}
{% endif %}
{% endblock %}