Explorar o código

Clean up script & report lists

jeremystretch %!s(int64=4) %!d(string=hai) anos
pai
achega
1fed564c47
Modificáronse 2 ficheiros con 149 adicións e 171 borrados
  1. 88 102
      netbox/templates/extras/report_list.html
  2. 61 69
      netbox/templates/extras/script_list.html

+ 88 - 102
netbox/templates/extras/report_list.html

@@ -3,108 +3,94 @@
 
 {% block title %}Reports{% endblock %}
 
-{% block content %}
-    <div class="row">
-        <div class="col col-md-9">
-            {% if reports %}
-                {% for module, module_reports in reports %}
-                    <div class="card">
-                        <h5 class="card-header"><a name="module.{{ module }}"></a>{{ module|bettertitle }}</h5>
-                        <div class="card-body">
-                            <table class="table table-hover table-headings reports">
-                                <thead>
-                                    <tr>
-                                        <th>Name</th>
-                                        <th>Status</th>
-                                        <th>Description</th>
-                                        <th class="text-end">Last Run</th>
-                                        <th></th>
-                                    </tr>
-                                </thead>
-                                <tbody>
-                                    {% for report in module_reports %}
-                                        <tr>
-                                            <td>
-                                                <a href="{% url 'extras:report' module=report.module name=report.class_name %}" id="{{ report.module }}.{{ report.class_name }}">{{ report.name }}</a>
-                                            </td>
-                                            <td>
-                                                {% include 'extras/inc/job_label.html' with result=report.result %}
-                                            </td>
-                                            <td>{{ report.description|render_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>
-                                                {% else %}
-                                                    <span class="text-muted">Never</span>
-                                                {% 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">
-                                                            {% 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>
-                                        </tr>
-                                        {% for method, stats in report.result.data.items %}
-                                            <tr>
-                                                <td colspan="4" class="method">
-                                                    {{ method }}
-                                                </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 %}
-                                </tbody>
-                            </table>
+{% block tabs %}
+  <ul class="nav nav-tabs px-3">
+    <li class="nav-item" role="presentation">
+      <a class="nav-link active" role="tab">Reports</a>
+    </li>
+  </ul>
+{% endblock tabs %}
+
+{% block content-wrapper %}
+  <div class="tab-content">
+    {% if reports %}
+      {% for module, module_reports in reports %}
+        <div class="card">
+          <h5 class="card-header">
+            <a name="module.{{ module }}"></a>
+            <i class="mdi mdi-file-document-outline"></i> {{ module|bettertitle }}
+          </h5>
+          <div class="card-body">
+            <table class="table table-hover table-headings reports">
+              <thead>
+                <tr>
+                  <th width="250">Name</th>
+                  <th width="110">Status</th>
+                  <th>Description</th>
+                  <th width="150" class="text-end">Last Run</th>
+                  <th width="120"></th>
+                </tr>
+              </thead>
+              <tbody>
+                {% for report in module_reports %}
+                  <tr>
+                    <td>
+                      <a href="{% url 'extras:report' module=report.module name=report.class_name %}" id="{{ report.module }}.{{ report.class_name }}">{{ report.name }}</a>
+                    </td>
+                    <td>
+                      {% include 'extras/inc/job_label.html' with result=report.result %}
+                    </td>
+                    <td>{{ report.description|render_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>
+                      {% else %}
+                        <span class="text-muted">Never</span>
+                      {% 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>
-                    </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 %}
-            {% else %}
-                <div class="alert alert-info" role="alert">
-                    <h4 class="alert-heading">No Reports Found</h4>
-                    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 class="col col-md-3">
-            {% if reports %}
-                <div class="card">
-                    <div class="card-body">
-                        {% for module, module_reports in reports %}
-                        <h5>{{ module|bettertitle }}</h5>
-                        <div class="small mb-2">
-                            <ul class="list-group list-group-flush">
-                                {% for report in module_reports %}
-                                <a href="#{{ report.module }}.{{ report.class_name }}" class="list-group-item">
-                                    <i class="mdi mdi-file-chart-outline"></i> {{ report.name }}
-                                    <div class="float-end">
-                                        {% include 'extras/inc/job_label.html' with result=report.result %}
-                                    </div>
-                                </a>
-                                {% endfor %}
-                            </ul>
-                        </div>
-                    {% endfor %}
-                    </div>
-                </div>
-            {% endif %}
+              </tbody>
+            </table>
+          </div>
         </div>
-    </div>
-{% endblock %}
+      {% endfor %}
+    {% else %}
+      <div class="alert alert-info" role="alert">
+        <h4 class="alert-heading">No Reports Found</h4>
+        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>
+{% endblock content-wrapper %}

+ 61 - 69
netbox/templates/extras/script_list.html

@@ -3,74 +3,66 @@
 
 {% block title %}Scripts{% endblock %}
 
-{% block content %}
-    <div class="row">
-        <div class="col col-md-9">
-            {% if scripts %}
-                {% for module, module_scripts in scripts.items %}
-                    <h3><a name="module.{{ module }}"></a>{{ module|bettertitle }}</h3>
-                    <table class="table table-hover table-headings reports">
-                        <thead>
-                            <tr>
-                                <th>Name</th>
-                                <th>Status</th>
-                                <th>Description</th>
-                                <th class="text-end">Last Run</th>
-                            </tr>
-                        </thead>
-                        <tbody>
-                            {% for class_name, script in module_scripts.items %}
-                                <tr>
-                                    <td>
-                                        <a href="{% url 'extras:script' module=script.module name=class_name %}" name="script.{{ class_name }}">{{ script }}</a>
-                                    </td>
-                                    <td>
-                                        {% include 'extras/inc/job_label.html' with result=script.result %}
-                                    </td>
-                                    <td>{{ script.Meta.description|render_markdown }}</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 %}
-                        </tbody>
-                    </table>
+{% block tabs %}
+  <ul class="nav nav-tabs px-3">
+    <li class="nav-item" role="presentation">
+      <a class="nav-link active" role="tab">Scripts</a>
+    </li>
+  </ul>
+{% endblock tabs %}
+
+{% block content-wrapper %}
+  <div class="tab-content">
+    {% if scripts %}
+      {% for module, module_scripts in scripts.items %}
+        <div class="card">
+          <h5 class="card-header">
+            <a name="module.{{ module }}"></a>
+            <i class="mdi mdi-file-document-outline"></i> {{ module|bettertitle }}
+          </h5>
+          <div class="card-body">
+            <table class="table table-hover table-headings reports">
+              <thead>
+                <tr>
+                  <th width="250">Name</th>
+                  <th width="110">Status</th>
+                  <th>Description</th>
+                  <th class="text-end">Last Run</th>
+                </tr>
+              </thead>
+              <tbody>
+                {% for class_name, script in module_scripts.items %}
+                  <tr>
+                    <td>
+                      <a href="{% url 'extras:script' module=script.module name=class_name %}" name="script.{{ class_name }}">{{ script }}</a>
+                    </td>
+                    <td>
+                      {% include 'extras/inc/job_label.html' with result=script.result %}
+                    </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 %}
-            {% else %}
-                <div class="alert alert-info">
-                    <h4 class="alert-heading">No Scripts Found</h4>
-                    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 class="col col-md-3">
-            {% if scripts %}
-                <div class="card">
-                    <div class="card-body">
-                        {% for module, module_scripts in scripts.items %}
-                        <h5>{{ module|bettertitle }}</h5>
-                        <div class="small mb-2">
-                            <ul class="list-group list-group-flush">
-                                {% for class_name, script in module_scripts.items %}
-                                    <a href="#script.{{ class_name }}" class="list-group-item">
-                                        <i class="mdi mdi-file-chart-outline"></i> {{ script.name }}
-                                        <div class="float-end">
-                                            {% include 'extras/inc/job_label.html' with result=script.result %}
-                                        </div>
-                                    </a>
-                                {% endfor %}
-                            </ul>
-                        </div>
-                        {% endfor %}
-                    </div>
-                </div>
-            {% endif %}
+              </tbody>
+            </table>
+          </div>
         </div>
-    </div>
-{% endblock %}
+      {% endfor %}
+    {% else %}
+      <div class="alert alert-info">
+        <h4 class="alert-heading">No Scripts Found</h4>
+        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>
+{% endblock content-wrapper %}