From 44fa0cba1820ead192e954479c1bc79428272b75 Mon Sep 17 00:00:00 2001
From: Arthur
Date: Mon, 4 Mar 2024 13:13:35 -0800
Subject: [PATCH] 10587 pagination
---
netbox/extras/views.py | 18 ++---
.../templates/extras/htmx/script_result.html | 50 ++++++-------
netbox/templates/extras/script_result.html | 74 +++++++++++++++----
3 files changed, 89 insertions(+), 53 deletions(-)
diff --git a/netbox/extras/views.py b/netbox/extras/views.py
index 2a55135e5..25bac5f1d 100644
--- a/netbox/extras/views.py
+++ b/netbox/extras/views.py
@@ -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:
diff --git a/netbox/templates/extras/htmx/script_result.html b/netbox/templates/extras/htmx/script_result.html
index 965e2d614..e532e07e1 100644
--- a/netbox/templates/extras/htmx/script_result.html
+++ b/netbox/templates/extras/htmx/script_result.html
@@ -18,29 +18,7 @@
{% badge job.get_status_display job.get_status_color %}
{% if job.completed %}
-
- {% if table.logs and not table_tests %}
-
-
-
- {% include 'htmx/table.html' with table=table_logs %}
-
-
- {% endif %}
-
- {# Script output. Legacy reports will not have this. #}
- {% if 'output' in job.data %}
-
-
- {% if job.data.output %}
-
{{ job.data.output }}
- {% else %}
-
{% trans "None" %}
- {% endif %}
-
- {% endif %}
-
- {% if table_tests %}
+ {% if tests %}
{# Summary of test methods #}
@@ -58,15 +36,29 @@
{% endfor %}
+ {% endif %}
- {# Detailed results for individual tests #}
-
-
-
- {% include 'htmx/table.html' with table=table_tests %}
-
+ {% if table %}
+
+
+
+ {% include 'htmx/table.html' %}
+
+
+ {% endif %}
+
+ {# Script output. Legacy reports will not have this. #}
+ {% if 'output' in job.data %}
+
+
+ {% if job.data.output %}
+
{{ job.data.output }}
+ {% else %}
+
{% trans "None" %}
+ {% endif %}
{% endif %}
+
{% elif job.started %}
{% include 'extras/inc/result_pending.html' %}
{% endif %}
diff --git a/netbox/templates/extras/script_result.html b/netbox/templates/extras/script_result.html
index 8f6d817c7..030e73903 100644
--- a/netbox/templates/extras/script_result.html
+++ b/netbox/templates/extras/script_result.html
@@ -32,28 +32,74 @@
{% block tabs %}
{% endblock %}
{% block content %}
-
-
-
- {% include 'extras/htmx/script_result.html' %}
+ {# Object list tab #}
+
+
+ {# Object table controls #}
+
+
+ {% if request.user.is_authenticated %}
+
+
+
+ {% endif %}
+
+
+
-
-
-
{{ script.filename }}
-
{{ script.source }}
-
+ {# /Object list tab #}
+
+ {# Filters tab #}
+ {% if filter_form %}
+
+ {% include 'inc/filter_list.html' %}
+
+ {% endif %}
+ {# /Filters tab #}
+
{% endblock content %}
{% block modals %}
- {% include 'inc/htmx_modal.html' %}
+ {% table_config_form table table_name="ObjectTable" %}
{% endblock modals %}