reports.html 4.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. {% extends 'layouts/base.html' %}
  2. {% block header_actions %}
  3. <div class="flex flex-col xs:flex-row items-stretch xs:items-center gap-2 w-full xs:w-auto">
  4. <div class="bg-white p-3 rounded-lg shadow-sm border border-gray-200 hover:shadow-lg transition-shadow duration-200 flex-shrink-0">
  5. <div class="reports-date-picker flex items-center gap-2">
  6. <div class="flex items-center justify-center w-6 h-6 bg-indigo-50 rounded-md">
  7. <svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3 text-indigo-600" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
  8. <path stroke-linecap="round" stroke-linejoin="round" d="M8 7V3m8 4V3M3 11h18M5 21h14a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2z"/>
  9. </svg>
  10. </div>
  11. <input
  12. id="reports-date"
  13. type="date"
  14. aria-label="{{ _('Fecha del reporte') }}"
  15. class="w-28 xs:w-32 rounded-md border border-gray-300 bg-white px-2 py-1 text-sm text-gray-900 placeholder-gray-500 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500 transition-colors duration-200"
  16. />
  17. <button
  18. id="reports-go"
  19. class="inline-flex items-center justify-center px-2 py-1 border border-transparent text-xs xs:text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed"
  20. >
  21. <svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
  22. <path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
  23. </svg>
  24. {{ _("Ver") }}
  25. </button>
  26. <button
  27. id="reports-export-pdf"
  28. class="inline-flex items-center justify-center px-2 py-1 border border-transparent text-xs xs:text-sm font-medium rounded-md text-white bg-emerald-600 hover:bg-emerald-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-emerald-500 transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed"
  29. >
  30. <svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
  31. <path stroke-linecap="round" stroke-linejoin="round" d="M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2" />
  32. <path stroke-linecap="round" stroke-linejoin="round" d="M7 10l5 5 5-5" />
  33. <path stroke-linecap="round" stroke-linejoin="round" d="M12 15V3" />
  34. </svg>
  35. {{ _("PDF") }}
  36. </button>
  37. </div>
  38. </div>
  39. </div>
  40. {% endblock header_actions %}
  41. {% block styles %}
  42. <script src="{{ url_for('static', filename='js/tailwindcss.js') }}"></script>
  43. {% endblock styles %}
  44. {% block content %}
  45. {% include 'partials/graph_reports.html' %}
  46. {% endblock content %}
  47. {% block scripts %}
  48. <script src="{{ url_for('static', filename='js/chart.js') }}"></script>
  49. <script src="{{ url_for('static', filename='js/chartjs-plugin-datalabels.js') }}"></script>
  50. {# Chart data injected as JSON so inline Jinja expressions are evaluated server-side
  51. and all JS behaviour lives in the external reports-charts.js file. #}
  52. <script type="application/json" id="chart-data">
  53. {
  54. "usersActivity": {
  55. "labels": {{ metrics.top_users_by_activity | map(attribute='username') | list | tojson | safe }},
  56. "data": {{ metrics.top_users_by_activity | map(attribute='total_visits') | list | tojson | safe }}
  57. },
  58. "usersData": {
  59. "labels": {{ metrics.top_users_by_data_transferred | map(attribute='username') | list | tojson | safe }},
  60. "data": {{ metrics.top_users_by_data_transferred | map(attribute='total_data_bytes') | map('divide', 1048576) | list | tojson | safe }}
  61. },
  62. "httpCodes": {
  63. "labels": {{ metrics.http_response_distribution_chart.labels | tojson | safe }},
  64. "data": {{ metrics.http_response_distribution_chart.data | tojson | safe }},
  65. "colors": {{ metrics.http_response_distribution_chart.colors | tojson | safe }}
  66. },
  67. "countries": {
  68. "labels": {{ metrics.top_countries_by_visits | map(attribute='country') | list | tojson | safe }},
  69. "data": {{ metrics.top_countries_by_visits | map(attribute='total_requests') | list | tojson | safe }}
  70. }
  71. }
  72. </script>
  73. <script src="{{ url_for('static', filename='js/reports-datepicker.js') }}"></script>
  74. <script src="{{ url_for('static', filename='js/reports-charts.js') }}"></script>
  75. {% endblock scripts %}