mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00

* Add condition to ScriptResultView.get function to generate a download file of job output if job is completed * Update template script_result.html adding a download button to trigger output download in ScriptResultView.get * Simplify conditional logic; tweak timestamp format --------- Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
78 lines
2.7 KiB
HTML
78 lines
2.7 KiB
HTML
{% load helpers %}
|
|
{% load log_levels %}
|
|
{% load i18n %}
|
|
|
|
<div class="htmx-container">
|
|
<p>
|
|
{% if job.started %}
|
|
{% trans "Started" %}: <strong>{{ job.started|isodatetime }}</strong>
|
|
{% elif job.scheduled %}
|
|
{% trans "Scheduled for" %}: <strong>{{ job.scheduled|isodatetime }}</strong>
|
|
{% else %}
|
|
{% trans "Created" %}: <strong>{{ job.created|isodatetime }}</strong>
|
|
{% endif %}
|
|
{% if job.completed %}
|
|
{% trans "Duration" %}: <strong>{{ job.duration }}</strong>
|
|
{% endif %}
|
|
<span id="pending-result-label">{% badge job.get_status_display job.get_status_color %}</span>
|
|
</p>
|
|
{% if job.completed %}
|
|
{% if tests %}
|
|
{# Summary of test methods #}
|
|
<div class="card">
|
|
<h2 class="card-header">{% trans "Test Summary" %}</h2>
|
|
<table class="table table-hover">
|
|
{% for test, data in tests.items %}
|
|
<tr>
|
|
<td class="font-monospace">{{ test }}</td>
|
|
<td class="text-end report-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 %}
|
|
</table>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if table %}
|
|
<div class="card">
|
|
<div class="table-responsive" id="object_list">
|
|
<h2 class="card-header">{% trans "Log" %}</h2>
|
|
<div class="htmx-container table-responsive"
|
|
hx-get="{% url 'extras:script_result' job_pk=job.pk %}?embedded=True&log=True&log_threshold={{log_threshold}}"
|
|
hx-target="this"
|
|
hx-trigger="load" hx-select=".htmx-container" hx-swap="outerHTML"
|
|
></div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{# Script output. Legacy reports will not have this. #}
|
|
{% if 'output' in job.data %}
|
|
<div class="card mb-3">
|
|
<h2 class="card-header d-flex justify-content-between">
|
|
{% trans "Output" %}
|
|
{% if job.completed %}
|
|
<div>
|
|
<a href="?export=output" class="btn btn-primary lh-1" role="button">
|
|
<i class="mdi mdi-download" aria-hidden="true"></i> {% trans "Download" %}
|
|
</a>
|
|
</div>
|
|
{% endif %}
|
|
</h2>
|
|
{% if job.data.output %}
|
|
<pre class="card-body font-monospace">{{ job.data.output }}</pre>
|
|
{% else %}
|
|
<div class="card-body text-muted">{% trans "None" %}</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% elif job.started %}
|
|
{% include 'extras/inc/result_pending.html' %}
|
|
{% endif %}
|
|
</div>
|