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.
|
Return a specific report from within a module.
|
||||||
"""
|
"""
|
||||||
module = ReportModule.objects.get(file_path=f'{module_name}.py')
|
module = ReportModule.objects.get(file_path=f'{module_name}.py')
|
||||||
return module.scripts.get(report_name)
|
return module.reports.get(report_name)
|
||||||
|
|
||||||
|
|
||||||
@job('default')
|
@job('default')
|
||||||
|
@ -826,13 +826,6 @@ class ReportListView(ContentTypePermissionRequiredMixin, View):
|
|||||||
).order_by('name', '-created').distinct('name').defer('data')
|
).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', {
|
return render(request, 'extras/report_list.html', {
|
||||||
'model': ScriptModule,
|
'model': ScriptModule,
|
||||||
'report_modules': report_modules,
|
'report_modules': report_modules,
|
||||||
@ -971,10 +964,6 @@ class ScriptListView(ContentTypePermissionRequiredMixin, View):
|
|||||||
).order_by('name', '-created').distinct('name').defer('data')
|
).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', {
|
return render(request, 'extras/script_list.html', {
|
||||||
'model': ScriptModule,
|
'model': ScriptModule,
|
||||||
'script_modules': script_modules,
|
'script_modules': script_modules,
|
||||||
|
@ -44,7 +44,8 @@
|
|||||||
<th width="250">Name</th>
|
<th width="250">Name</th>
|
||||||
<th width="110">Status</th>
|
<th width="110">Status</th>
|
||||||
<th>Description</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>
|
<th width="120"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -58,29 +59,35 @@
|
|||||||
{% include 'extras/inc/job_label.html' with result=report.result %}
|
{% include 'extras/inc/job_label.html' with result=report.result %}
|
||||||
</td>
|
</td>
|
||||||
<td>{{ report.description|markdown|placeholder }}</td>
|
<td>{{ report.description|markdown|placeholder }}</td>
|
||||||
<td class="text-end">
|
{% with last_result=job_results|get_key:report.full_name %}
|
||||||
{% if report.result %}
|
{% if last_result %}
|
||||||
<a href="{% url 'extras:report_result' job_result_pk=report.result.pk %}">{{ report.result.created|annotated_date }}</a>
|
<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 %}
|
{% else %}
|
||||||
<span class="text-muted">Never</span>
|
<td class="text-muted">Never</td>
|
||||||
|
<td>{{ ''|placeholder }}</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
<td>
|
||||||
<td>
|
{% if perms.extras.run_report %}
|
||||||
{% if perms.extras.run_report %}
|
<div class="float-end noprint">
|
||||||
<div class="float-end noprint">
|
<form action="{% url 'extras:report' module=report.module name=report.class_name %}" method="post">
|
||||||
<form action="{% url 'extras:report' module=report.module name=report.class_name %}" method="post">
|
{% csrf_token %}
|
||||||
{% csrf_token %}
|
<button type="submit" name="_run" class="btn btn-primary btn-sm" style="width: 110px">
|
||||||
<button type="submit" name="_run" class="btn btn-primary btn-sm" style="width: 110px">
|
{% if last_result %}
|
||||||
{% if report.result %}
|
<i class="mdi mdi-replay"></i> Run Again
|
||||||
<i class="mdi mdi-replay"></i> Run Again
|
{% else %}
|
||||||
{% else %}
|
<i class="mdi mdi-play"></i> Run Report
|
||||||
<i class="mdi mdi-play"></i> Run Report
|
{% endif %}
|
||||||
{% endif %}
|
</button>
|
||||||
</button>
|
</form>
|
||||||
</form>
|
</div>
|
||||||
</div>
|
{% endif %}
|
||||||
{% endif %}
|
</td>
|
||||||
</td>
|
{% endwith %}
|
||||||
</tr>
|
</tr>
|
||||||
{% for method, stats in report.result.data.items %}
|
{% for method, stats in report.result.data.items %}
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -43,7 +43,8 @@
|
|||||||
<th width="250">Name</th>
|
<th width="250">Name</th>
|
||||||
<th width="110">Status</th>
|
<th width="110">Status</th>
|
||||||
<th>Description</th>
|
<th>Description</th>
|
||||||
<th class="text-end">Last Run</th>
|
<th>Last Run</th>
|
||||||
|
<th class="text-end">Status</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -58,13 +59,19 @@
|
|||||||
<td>
|
<td>
|
||||||
{{ script_class.Meta.description|markdown|placeholder }}
|
{{ script_class.Meta.description|markdown|placeholder }}
|
||||||
</td>
|
</td>
|
||||||
{% if script_class.result %}
|
{% with last_result=job_results|get_key:script_class.full_name %}
|
||||||
<td class="text-end">
|
{% if last_result %}
|
||||||
<a href="{% url 'extras:script_result' job_result_pk=script_class.result.pk %}">{{ script_class.result.created|annotated_date }}</a>
|
<td>
|
||||||
</td>
|
<a href="{% url 'extras:script_result' job_result_pk=last_result.pk %}">{{ last_result.created|annotated_date }}</a>
|
||||||
{% else %}
|
</td>
|
||||||
<td class="text-end text-muted">Never</td>
|
<td class="text-end">
|
||||||
{% endif %}
|
{% 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>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
Loading…
Reference in New Issue
Block a user