mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 17:26:10 -06:00
Show results in report/script lists
This commit is contained in:
parent
107c46cb7a
commit
b2257b613e
@ -16,7 +16,7 @@ def get_report(module_name, report_name):
|
||||
Return a specific report from within a module.
|
||||
"""
|
||||
module = ReportModule.objects.get(file_path=f'{module_name}.py')
|
||||
return module.scripts.get(report_name)
|
||||
return module.reports.get(report_name)
|
||||
|
||||
|
||||
@job('default')
|
||||
|
@ -826,13 +826,6 @@ class ReportListView(ContentTypePermissionRequiredMixin, View):
|
||||
).order_by('name', '-created').distinct('name').defer('data')
|
||||
}
|
||||
|
||||
# for module, report_list in reports.items():
|
||||
# module_reports = []
|
||||
# for report in report_list.values():
|
||||
# report.result = results.get(report.full_name, None)
|
||||
# module_reports.append(report)
|
||||
# ret.append((module, module_reports))
|
||||
|
||||
return render(request, 'extras/report_list.html', {
|
||||
'model': ScriptModule,
|
||||
'report_modules': report_modules,
|
||||
@ -971,10 +964,6 @@ class ScriptListView(ContentTypePermissionRequiredMixin, View):
|
||||
).order_by('name', '-created').distinct('name').defer('data')
|
||||
}
|
||||
|
||||
# for _scripts in scripts.values():
|
||||
# for script in _scripts.values():
|
||||
# script.result = results.get(script.full_name)
|
||||
|
||||
return render(request, 'extras/script_list.html', {
|
||||
'model': ScriptModule,
|
||||
'script_modules': script_modules,
|
||||
|
@ -44,7 +44,8 @@
|
||||
<th width="250">Name</th>
|
||||
<th width="110">Status</th>
|
||||
<th>Description</th>
|
||||
<th width="150" class="text-end">Last Run</th>
|
||||
<th>Last Run</th>
|
||||
<th>Last Status</th>
|
||||
<th width="120"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -58,29 +59,35 @@
|
||||
{% include 'extras/inc/job_label.html' with result=report.result %}
|
||||
</td>
|
||||
<td>{{ report.description|markdown|placeholder }}</td>
|
||||
<td class="text-end">
|
||||
{% if report.result %}
|
||||
<a href="{% url 'extras:report_result' job_result_pk=report.result.pk %}">{{ report.result.created|annotated_date }}</a>
|
||||
{% with last_result=job_results|get_key:report.full_name %}
|
||||
{% if last_result %}
|
||||
<td>
|
||||
<a href="{% url 'extras:report_result' job_result_pk=last_result.pk %}">{{ last_result.created|annotated_date }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{% badge last_result.get_status_display last_result.get_status_color %}
|
||||
</td>
|
||||
{% else %}
|
||||
<span class="text-muted">Never</span>
|
||||
<td class="text-muted">Never</td>
|
||||
<td>{{ ''|placeholder }}</td>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if perms.extras.run_report %}
|
||||
<div class="float-end noprint">
|
||||
<form action="{% url 'extras:report' module=report.module name=report.class_name %}" method="post">
|
||||
{% csrf_token %}
|
||||
<button type="submit" name="_run" class="btn btn-primary btn-sm" style="width: 110px">
|
||||
{% if report.result %}
|
||||
<i class="mdi mdi-replay"></i> Run Again
|
||||
{% else %}
|
||||
<i class="mdi mdi-play"></i> Run Report
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if perms.extras.run_report %}
|
||||
<div class="float-end noprint">
|
||||
<form action="{% url 'extras:report' module=report.module name=report.class_name %}" method="post">
|
||||
{% csrf_token %}
|
||||
<button type="submit" name="_run" class="btn btn-primary btn-sm" style="width: 110px">
|
||||
{% if last_result %}
|
||||
<i class="mdi mdi-replay"></i> Run Again
|
||||
{% else %}
|
||||
<i class="mdi mdi-play"></i> Run Report
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endwith %}
|
||||
</tr>
|
||||
{% for method, stats in report.result.data.items %}
|
||||
<tr>
|
||||
|
@ -43,7 +43,8 @@
|
||||
<th width="250">Name</th>
|
||||
<th width="110">Status</th>
|
||||
<th>Description</th>
|
||||
<th class="text-end">Last Run</th>
|
||||
<th>Last Run</th>
|
||||
<th class="text-end">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -58,13 +59,19 @@
|
||||
<td>
|
||||
{{ script_class.Meta.description|markdown|placeholder }}
|
||||
</td>
|
||||
{% if script_class.result %}
|
||||
<td class="text-end">
|
||||
<a href="{% url 'extras:script_result' job_result_pk=script_class.result.pk %}">{{ script_class.result.created|annotated_date }}</a>
|
||||
</td>
|
||||
{% else %}
|
||||
<td class="text-end text-muted">Never</td>
|
||||
{% endif %}
|
||||
{% with last_result=job_results|get_key:script_class.full_name %}
|
||||
{% if last_result %}
|
||||
<td>
|
||||
<a href="{% url 'extras:script_result' job_result_pk=last_result.pk %}">{{ last_result.created|annotated_date }}</a>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
{% badge last_result.get_status_display last_result.get_status_color %}
|
||||
</td>
|
||||
{% else %}
|
||||
<td class="text-muted">Never</td>
|
||||
<td class="text-end">{{ ''|placeholder }}</td>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
Loading…
Reference in New Issue
Block a user