10587 pagination

This commit is contained in:
Arthur 2024-03-04 13:13:35 -08:00
parent ab9734a9d8
commit 44fa0cba18
3 changed files with 89 additions and 53 deletions

View File

@ -1154,7 +1154,7 @@ class ScriptResultView(TableMixin, generic.ObjectView):
def get_table(self, job, request, bulk_actions=True):
data = []
tests = None
table_logs = table_tests = None
table = None
index = 0
if job.data:
if 'log' in job.data:
@ -1171,8 +1171,8 @@ class ScriptResultView(TableMixin, generic.ObjectView):
}
data.append(result)
table_logs = ScriptResultsTable(data, user=request.user)
table_logs.configure(request)
table = ScriptResultsTable(data, user=request.user)
table.configure(request)
else:
tests = job.data
@ -1192,24 +1192,22 @@ class ScriptResultView(TableMixin, generic.ObjectView):
}
data.append(result)
table_tests = ReportResultsTable(data, user=request.user)
table_tests.configure(request)
table = ReportResultsTable(data, user=request.user)
table.configure(request)
return table_logs, table_tests
return table
def get(self, request, **kwargs):
job = get_object_or_404(Job.objects.all(), pk=kwargs.get('job_pk'))
table_logs = table_tests = None
if job.completed:
table_logs, table_tests = self.get_table(job, request, bulk_actions=False)
table = self.get_table(job, request, bulk_actions=False)
breakpoint()
context = {
'script': job.object,
'job': job,
'table_logs': table_logs,
'table_tests': table_tests,
'table': table,
}
if job.data and 'log' in job.data:

View File

@ -18,29 +18,7 @@
<span id="pending-result-label">{% badge job.get_status_display job.get_status_color %}</span>
</p>
{% if job.completed %}
{% if table.logs and not table_tests %}
<div class="card">
<div class="table-responsive" id="object_list">
<h5 class="card-header">{% trans "Log" %}</h5>
{% include 'htmx/table.html' with table=table_logs %}
</div>
</div>
{% endif %}
{# Script output. Legacy reports will not have this. #}
{% if 'output' in job.data %}
<div class="card mb-3">
<h5 class="card-header">{% trans "Output" %}</h5>
{% 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 %}
{% if table_tests %}
{% if tests %}
{# Summary of test methods #}
<div class="card">
<h5 class="card-header">{% trans "Test Summary" %}</h5>
@ -58,15 +36,29 @@
{% endfor %}
</table>
</div>
{% endif %}
{# Detailed results for individual tests #}
<div class="card">
<div class="table-responsive" id="object_list">
<h5 class="card-header">{% trans "Test Details" %}</h5>
{% include 'htmx/table.html' with table=table_tests %}
</div>
{% if table %}
<div class="card">
<div class="table-responsive" id="object_list">
<h5 class="card-header">{% trans "Log" %}</h5>
{% include 'htmx/table.html' %}
</div>
</div>
{% endif %}
{# Script output. Legacy reports will not have this. #}
{% if 'output' in job.data %}
<div class="card mb-3">
<h5 class="card-header">{% trans "Output" %}</h5>
{% 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 %}

View File

@ -32,28 +32,74 @@
{% block tabs %}
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item" role="presentation">
<a href="#log" role="tab" data-bs-toggle="tab" class="nav-link active">{% trans "Log" %}</a>
</li>
<li class="nav-item" role="presentation">
<a href="#source" role="tab" data-bs-toggle="tab" class="nav-link">{% trans "Source" %}</a>
<a href="#results" role="tab" data-bs-toggle="tab" class="nav-link active">{% trans "Results" %}</a>
</li>
</ul>
{% endblock %}
{% block content %}
<div role="tabpanel" class="tab-pane active" id="log">
<div class="row">
<div class="col col-md-12"{% if not job.completed %} hx-get="{% url 'extras:script_result' job_pk=job.pk %}" hx-trigger="load delay:0.5s, every 5s"{% endif %}>
{% include 'extras/htmx/script_result.html' %}
{# Object list tab #}
<div class="tab-pane show active" id="results" role="tabpanel" aria-labelledby="results-tab">
{# Object table controls #}
<div class="row mb-3">
<div class="col-auto ms-auto d-print-none">
{% if request.user.is_authenticated %}
<div class="table-configure input-group">
<button type="button" data-bs-toggle="modal" title="{% trans "Configure Table" %}" data-bs-target="#ObjectTable_config"
class="btn">
<i class="mdi mdi-cog"></i> {% trans "Configure Table" %}
</button>
</div>
{% endif %}
</div>
</div>
<form method="post" class="form form-horizontal">
{% csrf_token %}
{# "Select all" form #}
{% if table.paginator.num_pages > 1 %}
<div id="select-all-box" class="d-none card d-print-none">
<div class="form col-md-12">
<div class="card-body">
<div class="form-check">
<input type="checkbox" id="select-all" name="_all" class="form-check-input" />
<label for="select-all" class="form-check-label">
{% blocktrans trimmed with count=table.rows|length object_type_plural=table.data.verbose_name_plural %}
Select <strong>all {{ count }} {{ object_type_plural }}</strong> matching query
{% endblocktrans %}
</label>
</div>
</div>
</div>
</div>
{% endif %}
<div class="form form-horizontal">
{% csrf_token %}
<input type="hidden" name="return_url" value="{% if return_url %}{{ return_url }}{% else %}{{ request.path }}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}{% endif %}" />
{# Objects table #}
<div class="col col-md-12"{% if not job.completed %} hx-get="{% url 'extras:script_result' job_pk=job.pk %}" hx-trigger="load delay:0.5s, every 5s"{% endif %}>
{% include 'extras/htmx/script_result.html' %}
</div>
{# /Objects table #}
</div>
</form>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="source">
<p><code>{{ script.filename }}</code></p>
<pre class="block">{{ script.source }}</pre>
</div>
{# /Object list tab #}
{# Filters tab #}
{% if filter_form %}
<div class="tab-pane show" id="filters-form" role="tabpanel" aria-labelledby="filters-form-tab">
{% include 'inc/filter_list.html' %}
</div>
{% endif %}
{# /Filters tab #}
{% endblock content %}
{% block modals %}
{% include 'inc/htmx_modal.html' %}
{% table_config_form table table_name="ObjectTable" %}
{% endblock modals %}