mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-17 04:58:16 -06:00
10587 pagination
This commit is contained in:
parent
ab9734a9d8
commit
44fa0cba18
@ -1154,7 +1154,7 @@ class ScriptResultView(TableMixin, generic.ObjectView):
|
|||||||
def get_table(self, job, request, bulk_actions=True):
|
def get_table(self, job, request, bulk_actions=True):
|
||||||
data = []
|
data = []
|
||||||
tests = None
|
tests = None
|
||||||
table_logs = table_tests = None
|
table = None
|
||||||
index = 0
|
index = 0
|
||||||
if job.data:
|
if job.data:
|
||||||
if 'log' in job.data:
|
if 'log' in job.data:
|
||||||
@ -1171,8 +1171,8 @@ class ScriptResultView(TableMixin, generic.ObjectView):
|
|||||||
}
|
}
|
||||||
data.append(result)
|
data.append(result)
|
||||||
|
|
||||||
table_logs = ScriptResultsTable(data, user=request.user)
|
table = ScriptResultsTable(data, user=request.user)
|
||||||
table_logs.configure(request)
|
table.configure(request)
|
||||||
else:
|
else:
|
||||||
tests = job.data
|
tests = job.data
|
||||||
|
|
||||||
@ -1192,24 +1192,22 @@ class ScriptResultView(TableMixin, generic.ObjectView):
|
|||||||
}
|
}
|
||||||
data.append(result)
|
data.append(result)
|
||||||
|
|
||||||
table_tests = ReportResultsTable(data, user=request.user)
|
table = ReportResultsTable(data, user=request.user)
|
||||||
table_tests.configure(request)
|
table.configure(request)
|
||||||
|
|
||||||
return table_logs, table_tests
|
return table
|
||||||
|
|
||||||
def get(self, request, **kwargs):
|
def get(self, request, **kwargs):
|
||||||
job = get_object_or_404(Job.objects.all(), pk=kwargs.get('job_pk'))
|
job = get_object_or_404(Job.objects.all(), pk=kwargs.get('job_pk'))
|
||||||
table_logs = table_tests = None
|
table_logs = table_tests = None
|
||||||
|
|
||||||
if job.completed:
|
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 = {
|
context = {
|
||||||
'script': job.object,
|
'script': job.object,
|
||||||
'job': job,
|
'job': job,
|
||||||
'table_logs': table_logs,
|
'table': table,
|
||||||
'table_tests': table_tests,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if job.data and 'log' in job.data:
|
if job.data and 'log' in job.data:
|
||||||
|
@ -18,29 +18,7 @@
|
|||||||
<span id="pending-result-label">{% badge job.get_status_display job.get_status_color %}</span>
|
<span id="pending-result-label">{% badge job.get_status_display job.get_status_color %}</span>
|
||||||
</p>
|
</p>
|
||||||
{% if job.completed %}
|
{% if job.completed %}
|
||||||
|
{% if tests %}
|
||||||
{% 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 %}
|
|
||||||
{# Summary of test methods #}
|
{# Summary of test methods #}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h5 class="card-header">{% trans "Test Summary" %}</h5>
|
<h5 class="card-header">{% trans "Test Summary" %}</h5>
|
||||||
@ -58,15 +36,29 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{# Detailed results for individual tests #}
|
{% if table %}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="table-responsive" id="object_list">
|
<div class="table-responsive" id="object_list">
|
||||||
<h5 class="card-header">{% trans "Test Details" %}</h5>
|
<h5 class="card-header">{% trans "Log" %}</h5>
|
||||||
{% include 'htmx/table.html' with table=table_tests %}
|
{% include 'htmx/table.html' %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% 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 %}
|
{% elif job.started %}
|
||||||
{% include 'extras/inc/result_pending.html' %}
|
{% include 'extras/inc/result_pending.html' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -32,28 +32,74 @@
|
|||||||
{% block tabs %}
|
{% block tabs %}
|
||||||
<ul class="nav nav-tabs" role="tablist">
|
<ul class="nav nav-tabs" role="tablist">
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
<a href="#log" role="tab" data-bs-toggle="tab" class="nav-link active">{% trans "Log" %}</a>
|
<a href="#results" role="tab" data-bs-toggle="tab" class="nav-link active">{% trans "Results" %}</a>
|
||||||
</li>
|
|
||||||
<li class="nav-item" role="presentation">
|
|
||||||
<a href="#source" role="tab" data-bs-toggle="tab" class="nav-link">{% trans "Source" %}</a>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div role="tabpanel" class="tab-pane active" id="log">
|
{# Object list tab #}
|
||||||
<div class="row">
|
<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 %}>
|
<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' %}
|
{% include 'extras/htmx/script_result.html' %}
|
||||||
</div>
|
</div>
|
||||||
|
{# /Objects table #}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div role="tabpanel" class="tab-pane" id="source">
|
{# /Object list tab #}
|
||||||
<p><code>{{ script.filename }}</code></p>
|
|
||||||
<pre class="block">{{ script.source }}</pre>
|
{# 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>
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{# /Filters tab #}
|
||||||
|
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
||||||
{% block modals %}
|
{% block modals %}
|
||||||
{% include 'inc/htmx_modal.html' %}
|
{% table_config_form table table_name="ObjectTable" %}
|
||||||
{% endblock modals %}
|
{% endblock modals %}
|
||||||
|
Loading…
Reference in New Issue
Block a user