Clean up template

This commit is contained in:
Jeremy Stretch 2024-02-07 09:04:20 -05:00
parent 5939e1d440
commit c5916af1d0

View File

@ -20,6 +20,7 @@
{% block content %} {% block content %}
{% for module in script_modules %} {% for module in script_modules %}
{% include 'inc/sync_warning.html' with object=module %}
<div class="card"> <div class="card">
<h5 class="card-header justify-content-between" id="module{{ module.pk }}"> <h5 class="card-header justify-content-between" id="module{{ module.pk }}">
<div> <div>
@ -31,97 +32,96 @@
</a> </a>
{% endif %} {% endif %}
</h5> </h5>
<div class="card-body"> {% if module.scripts %}
{% include 'inc/sync_warning.html' with object=module %} <table class="table table-hover scripts">
{% if module.scripts %} <thead>
<table class="table table-hover scripts"> <tr>
<thead> <th>{% trans "Name" %}</th>
<tr> <th>{% trans "Description" %}</th>
<th width="250">{% trans "Name" %}</th> <th>{% trans "Last Run" %}</th>
<th>{% trans "Description" %}</th> <th>{% trans "Status" %}</th>
<th>{% trans "Last Run" %}</th> <th></th>
<th>{% trans "Status" %}</th> </tr>
<th width="120"></th> </thead>
</tr> <tbody>
</thead> {% with jobs=module.get_latest_jobs %}
<tbody> {% for script_name, script in module.scripts.items %}
{% with jobs=module.get_latest_jobs %} {% with last_job=jobs|get_key:script.class_name %}
{% for script_name, script in module.scripts.items %} <tr>
{% with last_job=jobs|get_key:script.class_name %} <td>
<tr> <a href="{% url 'extras:script' module=module.python_name name=script.class_name %}" id="{{ script.module }}.{{ script.class_name }}">{{ script.name }}</a>
</td>
<td>{{ script.description|markdown|placeholder }}</td>
{% if last_job %}
<td> <td>
<a href="{% url 'extras:script' module=module.python_name name=script.class_name %}" id="{{ script.module }}.{{ script.class_name }}">{{ script.name }}</a> <a href="{% url 'extras:script_result' job_pk=last_job.pk %}">{{ last_job.created|annotated_date }}</a>
</td> </td>
<td>{{ script.description|markdown|placeholder }}</td>
{% if last_job %}
<td>
<a href="{% url 'extras:script_result' job_pk=last_job.pk %}">{{ last_job.created|annotated_date }}</a>
</td>
<td>
{% badge last_job.get_status_display last_job.get_status_color %}
</td>
{% else %}
<td class="text-muted">{% trans "Never" %}</td>
<td>{{ ''|placeholder }}</td>
{% endif %}
<td> <td>
{% if perms.extras.run_script %} {% badge last_job.get_status_display last_job.get_status_color %}
<div class="float-end d-print-none">
<form action="{% url 'extras:script' module=script.module name=script.class_name %}" method="post">
{% csrf_token %}
<button type="submit" name="_run" class="btn btn-primary" style="width: 110px">
{% if last_job %}
<i class="mdi mdi-replay"></i> {% trans "Run Again" %}
{% else %}
<i class="mdi mdi-play"></i> {% trans "Run Script" %}
{% endif %}
</button>
</form>
</div>
{% endif %}
</td> </td>
</tr> {% else %}
{% if last_job.data.logs %} <td class="text-muted">{% trans "Never" %}</td>
{% for method, stats in last_job.data.logs.items %} <td>{{ ''|placeholder }}</td>
<tr>
<td colspan="4" class="method">
<span class="ps-3">{{ method }}</span>
</td>
<td class="text-end text-nowrap script-stats">
<span class="badge text-bg-success">{{ stats.success }}</span>
<span class="badge text-bg-info">{{ stats.info }}</span>
<span class="badge text-bg-warning">{{ stats.warning }}</span>
<span class="badge text-bg-danger">{{ stats.failure }}</span>
</td>
</tr>
{% endfor %}
{% elif not last_job.data.log %}
{# legacy #}
{% for method, stats in last_job.data.items %}
<tr>
<td colspan="4" class="method">
<span class="ps-3">{{ method }}</span>
</td>
<td class="text-end text-nowrap report-stats">
<span class="badge bg-success">{{ stats.success }}</span>
<span class="badge bg-info">{{ stats.info }}</span>
<span class="badge bg-warning">{{ stats.warning }}</span>
<span class="badge bg-danger">{{ stats.failure }}</span>
</td>
</tr>
{% endfor %}
{% endif %} {% endif %}
{% endwith %} <td>
{% endfor %} {% if perms.extras.run_script %}
{% endwith %} <div class="float-end d-print-none">
</tbody> <form action="{% url 'extras:script' module=script.module name=script.class_name %}" method="post">
</table> {% csrf_token %}
{% else %} <button type="submit" name="_run" class="btn btn-primary btn-sm">
{% if last_job %}
<i class="mdi mdi-replay"></i> {% trans "Run Again" %}
{% else %}
<i class="mdi mdi-play"></i> {% trans "Run Script" %}
{% endif %}
</button>
</form>
</div>
{% endif %}
</td>
</tr>
{% if last_job %}
{% for test_name, data in last_job.data.tests.items %}
<tr>
<td colspan="4" class="method">
<span class="ps-3">{{ test_name }}</span>
</td>
<td class="text-end text-nowrap script-stats">
<span class="badge text-bg-success">{{ data.success }}</span>
<span class="badge text-bg-info">{{ data.info }}</span>
<span class="badge text-bg-warning">{{ data.warning }}</span>
<span class="badge text-bg-danger">{{ data.failure }}</span>
</td>
</tr>
{% endfor %}
{% elif not last_job.data.log %}
{# legacy #}
{% for method, stats in last_job.data.items %}
<tr>
<td colspan="4" class="method">
<span class="ps-3">{{ method }}</span>
</td>
<td class="text-end text-nowrap report-stats">
<span class="badge bg-success">{{ stats.success }}</span>
<span class="badge bg-info">{{ stats.info }}</span>
<span class="badge bg-warning">{{ stats.warning }}</span>
<span class="badge bg-danger">{{ stats.failure }}</span>
</td>
</tr>
{% endfor %}
{% endif %}
{% endwith %}
{% endfor %}
{% endwith %}
</tbody>
</table>
{% else %}
<div class="card-body">
<div class="alert alert-warning" role="alert"> <div class="alert alert-warning" role="alert">
<i class="mdi mdi-alert"></i> Could not load scripts from {{ module.name }} <i class="mdi mdi-alert"></i> Could not load scripts from {{ module.name }}
</div> </div>
{% endif %} </div>
</div> {% endif %}
</div> </div>
{% empty %} {% empty %}
<div class="alert alert-info" role="alert"> <div class="alert alert-info" role="alert">