report_list.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. {% extends 'base/layout.html' %}
  2. {% load buttons %}
  3. {% load helpers %}
  4. {% load perms %}
  5. {% block title %}Reports{% endblock %}
  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. {% block controls %}
  14. <div class="controls">
  15. <div class="control-group">
  16. {% block extra_controls %}{% endblock %}
  17. {% add_button model %}
  18. </div>
  19. </div>
  20. {% endblock controls %}
  21. {% block content-wrapper %}
  22. <div class="tab-content">
  23. {% for module in report_modules %}
  24. <div class="card">
  25. <h5 class="card-header" id="module{{ module.pk }}">
  26. {% if perms.extras.delete_reportmodule %}
  27. <div class="float-end">
  28. <a href="{% url 'extras:reportmodule_delete' pk=module.pk %}" class="btn btn-danger btn-sm">
  29. <i class="mdi mdi-trash-can-outline" aria-hidden="true"></i> Delete
  30. </a>
  31. </div>
  32. {% endif %}
  33. <i class="mdi mdi-file-document-outline"></i> {{ module }}
  34. </h5>
  35. <div class="card-body">
  36. {% include 'inc/sync_warning.html' with object=module %}
  37. {% if module.reports %}
  38. <table class="table table-hover table-headings reports">
  39. <thead>
  40. <tr>
  41. <th width="250">Name</th>
  42. <th>Description</th>
  43. <th>Last Run</th>
  44. <th>Status</th>
  45. <th width="120"></th>
  46. </tr>
  47. </thead>
  48. <tbody>
  49. {% with jobs=module.get_latest_jobs %}
  50. {% for report_name, report in module.reports.items %}
  51. {% with last_job=jobs|get_key:report.class_name %}
  52. <tr>
  53. <td>
  54. <a href="{% url 'extras:report' module=module.python_name name=report.class_name %}" id="{{ report.module }}.{{ report.class_name }}">{{ report.name }}</a>
  55. </td>
  56. <td>{{ report.description|markdown|placeholder }}</td>
  57. {% if last_job %}
  58. <td>
  59. <a href="{% url 'extras:report_result' job_pk=last_job.pk %}">{{ last_job.created|annotated_date }}</a>
  60. </td>
  61. <td>
  62. {% badge last_job.get_status_display last_job.get_status_color %}
  63. </td>
  64. {% else %}
  65. <td class="text-muted">Never</td>
  66. <td>{{ ''|placeholder }}</td>
  67. {% endif %}
  68. <td>
  69. {% if perms.extras.run_report %}
  70. <div class="float-end noprint">
  71. <form action="{% url 'extras:report' module=report.module name=report.class_name %}" method="post">
  72. {% csrf_token %}
  73. <button type="submit" name="_run" class="btn btn-primary btn-sm" style="width: 110px">
  74. {% if last_job %}
  75. <i class="mdi mdi-replay"></i> Run Again
  76. {% else %}
  77. <i class="mdi mdi-play"></i> Run Report
  78. {% endif %}
  79. </button>
  80. </form>
  81. </div>
  82. {% endif %}
  83. </td>
  84. </tr>
  85. {% for method, stats in last_job.data.items %}
  86. <tr>
  87. <td colspan="4" class="method">
  88. <span class="ps-3">{{ method }}</span>
  89. </td>
  90. <td class="text-end text-nowrap report-stats">
  91. <span class="badge bg-success">{{ stats.success }}</span>
  92. <span class="badge bg-info">{{ stats.info }}</span>
  93. <span class="badge bg-warning">{{ stats.warning }}</span>
  94. <span class="badge bg-danger">{{ stats.failure }}</span>
  95. </td>
  96. </tr>
  97. {% endfor %}
  98. {% endwith %}
  99. {% endfor %}
  100. {% endwith %}
  101. </tbody>
  102. </table>
  103. {% else %}
  104. <div class="alert alert-warning" role="alert">
  105. <i class="mdi mdi-alert"></i> Could not load reports from {{ module.name }}
  106. </div>
  107. {% endif %}
  108. </div>
  109. </div>
  110. {% empty %}
  111. <div class="alert alert-info" role="alert">
  112. <h4 class="alert-heading">No Reports Found</h4>
  113. {% if perms.extras.add_reportmodule %}
  114. Get started by <a href="{% url 'extras:reportmodule_add' %}">creating a report</a> from an uploaded file or data source.
  115. {% endif %}
  116. </div>
  117. {% endfor %}
  118. </div>
  119. {% endblock content-wrapper %}