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 %} -
-
-
{% trans "Log" %}
- {% include 'htmx/table.html' with table=table_logs %} -
-
- {% endif %} - - {# Script output. Legacy reports will not have this. #} - {% if 'output' in job.data %} -
-
{% trans "Output" %}
- {% if job.data.output %} -
{{ job.data.output }}
- {% else %} -
{% trans "None" %}
- {% endif %} -
- {% endif %} - - {% if table_tests %} + {% if tests %} {# Summary of test methods #}
{% trans "Test Summary" %}
@@ -58,15 +36,29 @@ {% endfor %}
+ {% endif %} - {# Detailed results for individual tests #} -
-
-
{% trans "Test Details" %}
- {% include 'htmx/table.html' with table=table_tests %} -
+ {% if table %} +
+
+
{% trans "Log" %}
+ {% include 'htmx/table.html' %} +
+
+ {% endif %} + + {# Script output. Legacy reports will not have this. #} + {% if 'output' in job.data %} +
+
{% trans "Output" %}
+ {% 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 %} +
+ +
+ {% csrf_token %} + {# "Select all" form #} + {% if table.paginator.num_pages > 1 %} +
+
+
+
+ + +
+
+
+
+ {% endif %} + +
+ {% csrf_token %} + + + {# Objects table #} +
+ {% include 'extras/htmx/script_result.html' %} +
+ {# /Objects table #} + +
+
-
-
-

{{ 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 %}