Clean up script & report lists

This commit is contained in:
jeremystretch 2021-11-12 14:44:14 -05:00
parent bb99c3e6f9
commit 1fed564c47
2 changed files with 149 additions and 171 deletions

View File

@ -3,108 +3,94 @@
{% block title %}Reports{% endblock %} {% block title %}Reports{% endblock %}
{% block content %} {% block tabs %}
<div class="row"> <ul class="nav nav-tabs px-3">
<div class="col col-md-9"> <li class="nav-item" role="presentation">
{% if reports %} <a class="nav-link active" role="tab">Reports</a>
{% for module, module_reports in reports %} </li>
<div class="card"> </ul>
<h5 class="card-header"><a name="module.{{ module }}"></a>{{ module|bettertitle }}</h5> {% endblock tabs %}
<div class="card-body">
<table class="table table-hover table-headings reports"> {% block content-wrapper %}
<thead> <div class="tab-content">
<tr> {% if reports %}
<th>Name</th> {% for module, module_reports in reports %}
<th>Status</th> <div class="card">
<th>Description</th> <h5 class="card-header">
<th class="text-end">Last Run</th> <a name="module.{{ module }}"></a>
<th></th> <i class="mdi mdi-file-document-outline"></i> {{ module|bettertitle }}
</tr> </h5>
</thead> <div class="card-body">
<tbody> <table class="table table-hover table-headings reports">
{% for report in module_reports %} <thead>
<tr> <tr>
<td> <th width="250">Name</th>
<a href="{% url 'extras:report' module=report.module name=report.class_name %}" id="{{ report.module }}.{{ report.class_name }}">{{ report.name }}</a> <th width="110">Status</th>
</td> <th>Description</th>
<td> <th width="150" class="text-end">Last Run</th>
{% include 'extras/inc/job_label.html' with result=report.result %} <th width="120"></th>
</td> </tr>
<td>{{ report.description|render_markdown|placeholder }}</td> </thead>
<td class="text-end"> <tbody>
{% if report.result %} {% for report in module_reports %}
<a href="{% url 'extras:report_result' job_result_pk=report.result.pk %}">{{ report.result.created|annotated_date }}</a> <tr>
{% else %} <td>
<span class="text-muted">Never</span> <a href="{% url 'extras:report' module=report.module name=report.class_name %}" id="{{ report.module }}.{{ report.class_name }}">{{ report.name }}</a>
{% endif %} </td>
</td> <td>
<td> {% include 'extras/inc/job_label.html' with result=report.result %}
{% if perms.extras.run_report %} </td>
<div class="float-end noprint"> <td>{{ report.description|render_markdown|placeholder }}</td>
<form action="{% url 'extras:report' module=report.module name=report.class_name %}" method="post"> <td class="text-end">
{% csrf_token %} {% if report.result %}
<button type="submit" name="_run" class="btn btn-primary btn-sm"> <a href="{% url 'extras:report_result' job_result_pk=report.result.pk %}">{{ report.result.created|annotated_date }}</a>
{% if report.result %} {% else %}
<i class="mdi mdi-replay"></i> Run Again <span class="text-muted">Never</span>
{% else %} {% endif %}
<i class="mdi mdi-play"></i> Run Report </td>
{% endif %} <td>
</button> {% if perms.extras.run_report %}
</form> <div class="float-end noprint">
</div> <form action="{% url 'extras:report' module=report.module name=report.class_name %}" method="post">
{% endif %} {% csrf_token %}
</td> <button type="submit" name="_run" class="btn btn-primary btn-sm" style="width: 110px">
</tr> {% if report.result %}
{% for method, stats in report.result.data.items %} <i class="mdi mdi-replay"></i> Run Again
<tr> {% else %}
<td colspan="4" class="method"> <i class="mdi mdi-play"></i> Run Report
{{ method }} {% endif %}
</td> </button>
<td class="text-end text-nowrap report-stats"> </form>
<span class="badge bg-success">{{ stats.success }}</span>
<span class="badge bg-info">{{ stats.info }}</span>
<span class="badge bg-warning">{{ stats.warning }}</span>
<span class="badge bg-danger">{{ stats.failure }}</span>
</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
</div> </div>
</div> {% endif %}
</td>
</tr>
{% for method, stats in report.result.data.items %}
<tr>
<td colspan="4" class="method">
<span class="ps-3">{{ method }}</span>
</td>
<td class="text-end text-nowrap report-stats">
<span class="badge bg-success">{{ stats.success }}</span>
<span class="badge bg-info">{{ stats.info }}</span>
<span class="badge bg-warning">{{ stats.warning }}</span>
<span class="badge bg-danger">{{ stats.failure }}</span>
</td>
</tr>
{% endfor %}
{% endfor %} {% endfor %}
{% else %} </tbody>
<div class="alert alert-info" role="alert"> </table>
<h4 class="alert-heading">No Reports Found</h4> </div>
Reports should be saved to <code>{{ settings.REPORTS_ROOT }}</code>.
<hr/>
<small>This path can be changed by setting <code>REPORTS_ROOT</code> in NetBox's configuration.</small>
</div>
{% endif %}
</div> </div>
<div class="col col-md-3"> {% endfor %}
{% if reports %} {% else %}
<div class="card"> <div class="alert alert-info" role="alert">
<div class="card-body"> <h4 class="alert-heading">No Reports Found</h4>
{% for module, module_reports in reports %} Reports should be saved to <code>{{ settings.REPORTS_ROOT }}</code>.
<h5>{{ module|bettertitle }}</h5> <hr/>
<div class="small mb-2"> <small>This path can be changed by setting <code>REPORTS_ROOT</code> in NetBox's configuration.</small>
<ul class="list-group list-group-flush"> </div>
{% for report in module_reports %} {% endif %}
<a href="#{{ report.module }}.{{ report.class_name }}" class="list-group-item"> </div>
<i class="mdi mdi-file-chart-outline"></i> {{ report.name }} {% endblock content-wrapper %}
<div class="float-end">
{% include 'extras/inc/job_label.html' with result=report.result %}
</div>
</a>
{% endfor %}
</ul>
</div>
{% endfor %}
</div>
</div>
{% endif %}
</div>
</div>
{% endblock %}

View File

@ -3,74 +3,66 @@
{% block title %}Scripts{% endblock %} {% block title %}Scripts{% endblock %}
{% block content %} {% block tabs %}
<div class="row"> <ul class="nav nav-tabs px-3">
<div class="col col-md-9"> <li class="nav-item" role="presentation">
{% if scripts %} <a class="nav-link active" role="tab">Scripts</a>
{% for module, module_scripts in scripts.items %} </li>
<h3><a name="module.{{ module }}"></a>{{ module|bettertitle }}</h3> </ul>
<table class="table table-hover table-headings reports"> {% endblock tabs %}
<thead>
<tr> {% block content-wrapper %}
<th>Name</th> <div class="tab-content">
<th>Status</th> {% if scripts %}
<th>Description</th> {% for module, module_scripts in scripts.items %}
<th class="text-end">Last Run</th> <div class="card">
</tr> <h5 class="card-header">
</thead> <a name="module.{{ module }}"></a>
<tbody> <i class="mdi mdi-file-document-outline"></i> {{ module|bettertitle }}
{% for class_name, script in module_scripts.items %} </h5>
<tr> <div class="card-body">
<td> <table class="table table-hover table-headings reports">
<a href="{% url 'extras:script' module=script.module name=class_name %}" name="script.{{ class_name }}">{{ script }}</a> <thead>
</td> <tr>
<td> <th width="250">Name</th>
{% include 'extras/inc/job_label.html' with result=script.result %} <th width="110">Status</th>
</td> <th>Description</th>
<td>{{ script.Meta.description|render_markdown }}</td> <th class="text-end">Last Run</th>
{% if script.result %} </tr>
<td class="text-end"> </thead>
<a href="{% url 'extras:script_result' job_result_pk=script.result.pk %}">{{ script.result.created|annotated_date }}</a> <tbody>
</td> {% for class_name, script in module_scripts.items %}
{% else %} <tr>
<td class="text-end text-muted">Never</td> <td>
{% endif %} <a href="{% url 'extras:script' module=script.module name=class_name %}" name="script.{{ class_name }}">{{ script }}</a>
</tr> </td>
{% endfor %} <td>
</tbody> {% include 'extras/inc/job_label.html' with result=script.result %}
</table> </td>
<td>
{{ script.Meta.description|render_markdown|placeholder }}
</td>
{% if script.result %}
<td class="text-end">
<a href="{% url 'extras:script_result' job_result_pk=script.result.pk %}">{{ script.result.created|annotated_date }}</a>
</td>
{% else %}
<td class="text-end text-muted">Never</td>
{% endif %}
</tr>
{% endfor %} {% endfor %}
{% else %} </tbody>
<div class="alert alert-info"> </table>
<h4 class="alert-heading">No Scripts Found</h4> </div>
Scripts should be saved to <code>{{ settings.SCRIPTS_ROOT }}</code>.
<hr/>
This path can be changed by setting <code>SCRIPTS_ROOT</code> in NetBox's configuration.
</div>
{% endif %}
</div> </div>
<div class="col col-md-3"> {% endfor %}
{% if scripts %} {% else %}
<div class="card"> <div class="alert alert-info">
<div class="card-body"> <h4 class="alert-heading">No Scripts Found</h4>
{% for module, module_scripts in scripts.items %} Scripts should be saved to <code>{{ settings.SCRIPTS_ROOT }}</code>.
<h5>{{ module|bettertitle }}</h5> <hr/>
<div class="small mb-2"> This path can be changed by setting <code>SCRIPTS_ROOT</code> in NetBox's configuration.
<ul class="list-group list-group-flush"> </div>
{% for class_name, script in module_scripts.items %} {% endif %}
<a href="#script.{{ class_name }}" class="list-group-item"> </div>
<i class="mdi mdi-file-chart-outline"></i> {{ script.name }} {% endblock content-wrapper %}
<div class="float-end">
{% include 'extras/inc/job_label.html' with result=script.result %}
</div>
</a>
{% endfor %}
</ul>
</div>
{% endfor %}
</div>
</div>
{% endif %}
</div>
</div>
{% endblock %}