diff --git a/netbox/extras/views.py b/netbox/extras/views.py index 532e32636..75591c6ae 100644 --- a/netbox/extras/views.py +++ b/netbox/extras/views.py @@ -1163,11 +1163,23 @@ class ScriptResultView(ContentTypePermissionRequiredMixin, View): module = job.object script = module.scripts[job.name]() + if 'logs' in job.data: + legacy_script = False + legacy_report = False + elif 'log' in job.data: + legacy_script = True + legacy_report = False + else: + legacy_script = False + legacy_report = True + # If this is an HTMX request, return only the result HTML if request.htmx: response = render(request, 'extras/htmx/script_result.html', { 'script': script, 'job': job, + 'legacy_script': legacy_script, + 'legacy_report': legacy_report, }) if job.completed or not job.started: response.status_code = 286 @@ -1176,6 +1188,8 @@ class ScriptResultView(ContentTypePermissionRequiredMixin, View): return render(request, 'extras/script_result.html', { 'script': script, 'job': job, + 'legacy_script': legacy_script, + 'legacy_report': legacy_report, }) diff --git a/netbox/templates/extras/htmx/legacy_report_result.html b/netbox/templates/extras/htmx/legacy_report_result.html new file mode 100644 index 000000000..e6b6caf73 --- /dev/null +++ b/netbox/templates/extras/htmx/legacy_report_result.html @@ -0,0 +1,81 @@ +{% load humanize %} +{% load helpers %} +{% load i18n %} + +
+ {% if job.started %} + {% trans "Started" %}: {{ job.started|annotated_date }} + {% elif job.scheduled %} + {% trans "Scheduled for" %}: {{ job.scheduled|annotated_date }} ({{ job.scheduled|naturaltime }}) + {% else %} + {% trans "Created" %}: {{ job.created|annotated_date }} + {% endif %} + {% if job.completed %} + {% trans "Duration" %}: {{ job.duration }} + {% endif %} + {% badge job.get_status_display job.get_status_color %} +
+{% if job.completed %} +{{ method }} | ++ {{ data.success }} + {{ data.info }} + {{ data.warning }} + {{ data.failure }} + | +
{% trans "Time" %} | +{% trans "Level" %} | +{% trans "Object" %} | +{% trans "Message" %} | +
---|---|---|---|
+ {{ method }} + | +|||
{{ time }} | ++ + | ++ {% if obj and url %} + {{ obj }} + {% elif obj %} + {{ obj }} + {% else %} + {{ ''|placeholder }} + {% endif %} + | +{{ message|markdown }} | +
+ {% if job.started %} + {% trans "Started" %}: {{ job.started|annotated_date }} + {% elif job.scheduled %} + {% trans "Scheduled for" %}: {{ job.scheduled|annotated_date }} ({{ job.scheduled|naturaltime }}) + {% else %} + {% trans "Created" %}: {{ job.created|annotated_date }} + {% endif %} + {% if job.completed %} + {% trans "Duration" %}: {{ job.duration }} + {% endif %} + {% badge job.get_status_display job.get_status_color %} +
+{% if job.completed %} +{% trans "Line" %} | +{% trans "Level" %} | +{% trans "Message" %} | +
---|---|---|
{{ forloop.counter }} | +{% log_level log.status %} | +{{ log.message|markdown }} | +
+ {% trans "No log output" %} + | +
{{ job.data.output }}+ {% else %} +
{% trans "None" %}
+ {% 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 985c58d63..02a01149c 100644 --- a/netbox/templates/extras/script_result.html +++ b/netbox/templates/extras/script_result.html @@ -44,7 +44,13 @@