mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -06:00
Provide a default view for Report instances
This commit is contained in:
parent
1f905e72d9
commit
592ad18317
@ -146,12 +146,19 @@ class Report(object):
|
||||
return self.__module__
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
def class_name(self):
|
||||
return self.__class__.__name__
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""
|
||||
Override this attribute to set a custom display name.
|
||||
"""
|
||||
return self.class_name
|
||||
|
||||
@property
|
||||
def full_name(self):
|
||||
return '.'.join([self.__module__, self.__class__.__name__])
|
||||
return f'{self.module}.{self.class_name}'
|
||||
|
||||
def _log(self, obj, message, level=LogLevelChoices.LOG_DEFAULT):
|
||||
"""
|
||||
|
38
netbox/templates/extras/report.html
Normal file
38
netbox/templates/extras/report.html
Normal file
@ -0,0 +1,38 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load helpers %}
|
||||
|
||||
{% block title %}{{ report.name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row noprint">
|
||||
<div class="col-md-12">
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="{% url 'extras:report_list' %}">Reports</a></li>
|
||||
<li><a href="{% url 'extras:report_list' %}#module.{{ report.module }}">{{ report.module|bettertitle }}</a></li>
|
||||
<li>{{ report.name }}</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
{% if perms.extras.run_report %}
|
||||
<div class="pull-right noprint">
|
||||
<form action="{% url 'extras:report' module=report.module name=report.class_name %}" method="post">
|
||||
{% csrf_token %}
|
||||
{{ run_form }}
|
||||
<button type="submit" name="_run" class="btn btn-primary"><i class="fa fa-play"></i> Run Report</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
<h1>{{ report.name }}</h1>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{% if report.description %}
|
||||
<p class="lead">{{ report.description }}</p>
|
||||
{% endif %}
|
||||
{% if report.result %}
|
||||
<p>Last run: <a href="{% url 'extras:report_result' job_result_pk=report.result.pk %}">
|
||||
<strong>{{ report.result.created }}</strong>
|
||||
</a></p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -6,7 +6,7 @@
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
{% if reports %}
|
||||
{% for module, module_reports in reports %}
|
||||
{% for module, module_reports in reports %}
|
||||
<h3><a name="module.{{ module }}"></a>{{ module|bettertitle }}</h3>
|
||||
<table class="table table-hover table-headings reports">
|
||||
<thead>
|
||||
@ -21,17 +21,21 @@
|
||||
{% for report in module_reports %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{% url 'extras:report_result' job_result_pk=report.result.pk %}" name="report.{{ report.name }}"><strong>{{ report.name }}</strong></a>
|
||||
<a href="{% url 'extras:report' module=report.module name=report.class_name %}" id="{{ report.module }}.{{ report.class_name }}">
|
||||
<strong>{{ report.name }}</strong>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
{% include 'extras/inc/job_label.html' with result=report.result %}
|
||||
</td>
|
||||
<td>{{ report.description|default:"" }}</td>
|
||||
{% if report.result %}
|
||||
<td class="text-right">{{ report.result.created }}</td>
|
||||
{% else %}
|
||||
<td class="text-right text-muted">Never</td>
|
||||
{% endif %}
|
||||
<td>{{ report.description|placeholder }}</td>
|
||||
<td class="text-right">
|
||||
{% if report.result %}
|
||||
<a href="{% url 'extras:report_result' job_result_pk=report.result.pk %}">{{ report.result.created }}</a>
|
||||
{% else %}
|
||||
<span class="text-muted">Never</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% for method, stats in report.result.data.items %}
|
||||
<tr>
|
||||
@ -66,7 +70,7 @@
|
||||
</div>
|
||||
<ul class="list-group">
|
||||
{% for report in module_reports %}
|
||||
<a href="#report.{{ report.name }}" class="list-group-item">
|
||||
<a href="#{{ report.module }}.{{ report.class_name }}" class="list-group-item">
|
||||
<i class="fa fa-list-alt"></i> {{ report.name }}
|
||||
<div class="pull-right">
|
||||
{% include 'extras/inc/job_label.html' with result=report.result %}
|
||||
|
@ -14,7 +14,7 @@
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
{% if perms.extras.add_reportresult %}
|
||||
{% if perms.extras.run_report %}
|
||||
<div class="pull-right noprint">
|
||||
<form action="{% url 'extras:report' module=report.module name=report.name %}" method="post">
|
||||
{% csrf_token %}
|
||||
|
Loading…
Reference in New Issue
Block a user