Skip to content

Commit 1fed564

Browse files
committed
Clean up script & report lists
1 parent bb99c3e commit 1fed564

File tree

2 files changed

+149
-171
lines changed

2 files changed

+149
-171
lines changed

netbox/templates/extras/report_list.html

Lines changed: 88 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -3,108 +3,94 @@
33

44
{% block title %}Reports{% endblock %}
55

6-
{% block content %}
7-
<div class="row">
8-
<div class="col col-md-9">
9-
{% if reports %}
10-
{% for module, module_reports in reports %}
11-
<div class="card">
12-
<h5 class="card-header"><a name="module.{{ module }}"></a>{{ module|bettertitle }}</h5>
13-
<div class="card-body">
14-
<table class="table table-hover table-headings reports">
15-
<thead>
16-
<tr>
17-
<th>Name</th>
18-
<th>Status</th>
19-
<th>Description</th>
20-
<th class="text-end">Last Run</th>
21-
<th></th>
22-
</tr>
23-
</thead>
24-
<tbody>
25-
{% for report in module_reports %}
26-
<tr>
27-
<td>
28-
<a href="{% url 'extras:report' module=report.module name=report.class_name %}" id="{{ report.module }}.{{ report.class_name }}">{{ report.name }}</a>
29-
</td>
30-
<td>
31-
{% include 'extras/inc/job_label.html' with result=report.result %}
32-
</td>
33-
<td>{{ report.description|render_markdown|placeholder }}</td>
34-
<td class="text-end">
35-
{% if report.result %}
36-
<a href="{% url 'extras:report_result' job_result_pk=report.result.pk %}">{{ report.result.created|annotated_date }}</a>
37-
{% else %}
38-
<span class="text-muted">Never</span>
39-
{% endif %}
40-
</td>
41-
<td>
42-
{% if perms.extras.run_report %}
43-
<div class="float-end noprint">
44-
<form action="{% url 'extras:report' module=report.module name=report.class_name %}" method="post">
45-
{% csrf_token %}
46-
<button type="submit" name="_run" class="btn btn-primary btn-sm">
47-
{% if report.result %}
48-
<i class="mdi mdi-replay"></i> Run Again
49-
{% else %}
50-
<i class="mdi mdi-play"></i> Run Report
51-
{% endif %}
52-
</button>
53-
</form>
54-
</div>
55-
{% endif %}
56-
</td>
57-
</tr>
58-
{% for method, stats in report.result.data.items %}
59-
<tr>
60-
<td colspan="4" class="method">
61-
{{ method }}
62-
</td>
63-
<td class="text-end text-nowrap report-stats">
64-
<span class="badge bg-success">{{ stats.success }}</span>
65-
<span class="badge bg-info">{{ stats.info }}</span>
66-
<span class="badge bg-warning">{{ stats.warning }}</span>
67-
<span class="badge bg-danger">{{ stats.failure }}</span>
68-
</td>
69-
</tr>
70-
{% endfor %}
71-
{% endfor %}
72-
</tbody>
73-
</table>
6+
{% block tabs %}
7+
<ul class="nav nav-tabs px-3">
8+
<li class="nav-item" role="presentation">
9+
<a class="nav-link active" role="tab">Reports</a>
10+
</li>
11+
</ul>
12+
{% endblock tabs %}
13+
14+
{% block content-wrapper %}
15+
<div class="tab-content">
16+
{% if reports %}
17+
{% for module, module_reports in reports %}
18+
<div class="card">
19+
<h5 class="card-header">
20+
<a name="module.{{ module }}"></a>
21+
<i class="mdi mdi-file-document-outline"></i> {{ module|bettertitle }}
22+
</h5>
23+
<div class="card-body">
24+
<table class="table table-hover table-headings reports">
25+
<thead>
26+
<tr>
27+
<th width="250">Name</th>
28+
<th width="110">Status</th>
29+
<th>Description</th>
30+
<th width="150" class="text-end">Last Run</th>
31+
<th width="120"></th>
32+
</tr>
33+
</thead>
34+
<tbody>
35+
{% for report in module_reports %}
36+
<tr>
37+
<td>
38+
<a href="{% url 'extras:report' module=report.module name=report.class_name %}" id="{{ report.module }}.{{ report.class_name }}">{{ report.name }}</a>
39+
</td>
40+
<td>
41+
{% include 'extras/inc/job_label.html' with result=report.result %}
42+
</td>
43+
<td>{{ report.description|render_markdown|placeholder }}</td>
44+
<td class="text-end">
45+
{% if report.result %}
46+
<a href="{% url 'extras:report_result' job_result_pk=report.result.pk %}">{{ report.result.created|annotated_date }}</a>
47+
{% else %}
48+
<span class="text-muted">Never</span>
49+
{% endif %}
50+
</td>
51+
<td>
52+
{% if perms.extras.run_report %}
53+
<div class="float-end noprint">
54+
<form action="{% url 'extras:report' module=report.module name=report.class_name %}" method="post">
55+
{% csrf_token %}
56+
<button type="submit" name="_run" class="btn btn-primary btn-sm" style="width: 110px">
57+
{% if report.result %}
58+
<i class="mdi mdi-replay"></i> Run Again
59+
{% else %}
60+
<i class="mdi mdi-play"></i> Run Report
61+
{% endif %}
62+
</button>
63+
</form>
7464
</div>
75-
</div>
65+
{% endif %}
66+
</td>
67+
</tr>
68+
{% for method, stats in report.result.data.items %}
69+
<tr>
70+
<td colspan="4" class="method">
71+
<span class="ps-3">{{ method }}</span>
72+
</td>
73+
<td class="text-end text-nowrap report-stats">
74+
<span class="badge bg-success">{{ stats.success }}</span>
75+
<span class="badge bg-info">{{ stats.info }}</span>
76+
<span class="badge bg-warning">{{ stats.warning }}</span>
77+
<span class="badge bg-danger">{{ stats.failure }}</span>
78+
</td>
79+
</tr>
80+
{% endfor %}
7681
{% endfor %}
77-
{% else %}
78-
<div class="alert alert-info" role="alert">
79-
<h4 class="alert-heading">No Reports Found</h4>
80-
Reports should be saved to <code>{{ settings.REPORTS_ROOT }}</code>.
81-
<hr/>
82-
<small>This path can be changed by setting <code>REPORTS_ROOT</code> in NetBox's configuration.</small>
83-
</div>
84-
{% endif %}
85-
</div>
86-
<div class="col col-md-3">
87-
{% if reports %}
88-
<div class="card">
89-
<div class="card-body">
90-
{% for module, module_reports in reports %}
91-
<h5>{{ module|bettertitle }}</h5>
92-
<div class="small mb-2">
93-
<ul class="list-group list-group-flush">
94-
{% for report in module_reports %}
95-
<a href="#{{ report.module }}.{{ report.class_name }}" class="list-group-item">
96-
<i class="mdi mdi-file-chart-outline"></i> {{ report.name }}
97-
<div class="float-end">
98-
{% include 'extras/inc/job_label.html' with result=report.result %}
99-
</div>
100-
</a>
101-
{% endfor %}
102-
</ul>
103-
</div>
104-
{% endfor %}
105-
</div>
106-
</div>
107-
{% endif %}
82+
</tbody>
83+
</table>
84+
</div>
10885
</div>
109-
</div>
110-
{% endblock %}
86+
{% endfor %}
87+
{% else %}
88+
<div class="alert alert-info" role="alert">
89+
<h4 class="alert-heading">No Reports Found</h4>
90+
Reports should be saved to <code>{{ settings.REPORTS_ROOT }}</code>.
91+
<hr/>
92+
<small>This path can be changed by setting <code>REPORTS_ROOT</code> in NetBox's configuration.</small>
93+
</div>
94+
{% endif %}
95+
</div>
96+
{% endblock content-wrapper %}

netbox/templates/extras/script_list.html

Lines changed: 61 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -3,74 +3,66 @@
33

44
{% block title %}Scripts{% endblock %}
55

6-
{% block content %}
7-
<div class="row">
8-
<div class="col col-md-9">
9-
{% if scripts %}
10-
{% for module, module_scripts in scripts.items %}
11-
<h3><a name="module.{{ module }}"></a>{{ module|bettertitle }}</h3>
12-
<table class="table table-hover table-headings reports">
13-
<thead>
14-
<tr>
15-
<th>Name</th>
16-
<th>Status</th>
17-
<th>Description</th>
18-
<th class="text-end">Last Run</th>
19-
</tr>
20-
</thead>
21-
<tbody>
22-
{% for class_name, script in module_scripts.items %}
23-
<tr>
24-
<td>
25-
<a href="{% url 'extras:script' module=script.module name=class_name %}" name="script.{{ class_name }}">{{ script }}</a>
26-
</td>
27-
<td>
28-
{% include 'extras/inc/job_label.html' with result=script.result %}
29-
</td>
30-
<td>{{ script.Meta.description|render_markdown }}</td>
31-
{% if script.result %}
32-
<td class="text-end">
33-
<a href="{% url 'extras:script_result' job_result_pk=script.result.pk %}">{{ script.result.created|annotated_date }}</a>
34-
</td>
35-
{% else %}
36-
<td class="text-end text-muted">Never</td>
37-
{% endif %}
38-
</tr>
39-
{% endfor %}
40-
</tbody>
41-
</table>
6+
{% block tabs %}
7+
<ul class="nav nav-tabs px-3">
8+
<li class="nav-item" role="presentation">
9+
<a class="nav-link active" role="tab">Scripts</a>
10+
</li>
11+
</ul>
12+
{% endblock tabs %}
13+
14+
{% block content-wrapper %}
15+
<div class="tab-content">
16+
{% if scripts %}
17+
{% for module, module_scripts in scripts.items %}
18+
<div class="card">
19+
<h5 class="card-header">
20+
<a name="module.{{ module }}"></a>
21+
<i class="mdi mdi-file-document-outline"></i> {{ module|bettertitle }}
22+
</h5>
23+
<div class="card-body">
24+
<table class="table table-hover table-headings reports">
25+
<thead>
26+
<tr>
27+
<th width="250">Name</th>
28+
<th width="110">Status</th>
29+
<th>Description</th>
30+
<th class="text-end">Last Run</th>
31+
</tr>
32+
</thead>
33+
<tbody>
34+
{% for class_name, script in module_scripts.items %}
35+
<tr>
36+
<td>
37+
<a href="{% url 'extras:script' module=script.module name=class_name %}" name="script.{{ class_name }}">{{ script }}</a>
38+
</td>
39+
<td>
40+
{% include 'extras/inc/job_label.html' with result=script.result %}
41+
</td>
42+
<td>
43+
{{ script.Meta.description|render_markdown|placeholder }}
44+
</td>
45+
{% if script.result %}
46+
<td class="text-end">
47+
<a href="{% url 'extras:script_result' job_result_pk=script.result.pk %}">{{ script.result.created|annotated_date }}</a>
48+
</td>
49+
{% else %}
50+
<td class="text-end text-muted">Never</td>
51+
{% endif %}
52+
</tr>
4253
{% endfor %}
43-
{% else %}
44-
<div class="alert alert-info">
45-
<h4 class="alert-heading">No Scripts Found</h4>
46-
Scripts should be saved to <code>{{ settings.SCRIPTS_ROOT }}</code>.
47-
<hr/>
48-
This path can be changed by setting <code>SCRIPTS_ROOT</code> in NetBox's configuration.
49-
</div>
50-
{% endif %}
51-
</div>
52-
<div class="col col-md-3">
53-
{% if scripts %}
54-
<div class="card">
55-
<div class="card-body">
56-
{% for module, module_scripts in scripts.items %}
57-
<h5>{{ module|bettertitle }}</h5>
58-
<div class="small mb-2">
59-
<ul class="list-group list-group-flush">
60-
{% for class_name, script in module_scripts.items %}
61-
<a href="#script.{{ class_name }}" class="list-group-item">
62-
<i class="mdi mdi-file-chart-outline"></i> {{ script.name }}
63-
<div class="float-end">
64-
{% include 'extras/inc/job_label.html' with result=script.result %}
65-
</div>
66-
</a>
67-
{% endfor %}
68-
</ul>
69-
</div>
70-
{% endfor %}
71-
</div>
72-
</div>
73-
{% endif %}
54+
</tbody>
55+
</table>
56+
</div>
7457
</div>
75-
</div>
76-
{% endblock %}
58+
{% endfor %}
59+
{% else %}
60+
<div class="alert alert-info">
61+
<h4 class="alert-heading">No Scripts Found</h4>
62+
Scripts should be saved to <code>{{ settings.SCRIPTS_ROOT }}</code>.
63+
<hr/>
64+
This path can be changed by setting <code>SCRIPTS_ROOT</code> in NetBox's configuration.
65+
</div>
66+
{% endif %}
67+
</div>
68+
{% endblock content-wrapper %}

0 commit comments

Comments
 (0)