connections.html 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. {# Filtro para usuarios válidos (se mantiene igual) #} {% set valid_users = {}
  2. %} {% for user, connections in grouped_connections.items() %} {% if user and
  3. user != "-" and user != "Anónimo" %} {% set _ = valid_users.update({user:
  4. connections}) %} {% endif %} {% endfor %} {# Tarjetas de estadísticas con iconos
  5. Font Awesome #}
  6. <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-6">
  7. <!-- Tarjeta Usuarios Activos -->
  8. <div class="bg-white p-4 rounded-lg shadow flex items-center">
  9. <div
  10. class="w-12 h-12 rounded-full bg-blue-100 flex items-center justify-center mr-3"
  11. >
  12. <i class="fas fa-users text-blue-500"></i>
  13. </div>
  14. <div>
  15. <p class="text-gray-500 text-sm">Usuarios Activos</p>
  16. <p class="text-xl font-bold">{{ valid_users|length }}</p>
  17. </div>
  18. </div>
  19. <!-- Tarjeta Conexiones Totales -->
  20. <div class="bg-white p-4 rounded-lg shadow flex items-center">
  21. <div
  22. class="w-12 h-12 rounded-full bg-green-100 flex items-center justify-center mr-3"
  23. >
  24. <i class="fas fa-exchange-alt text-green-500"></i>
  25. </div>
  26. <div>
  27. <p class="text-gray-500 text-sm">Conexiones Totales</p>
  28. <p class="text-xl font-bold">
  29. {% set total = namespace(value=0) %} {% for connections in
  30. valid_users.values() %} {% set total.value = total.value +
  31. connections|length %} {% endfor %} {{ total.value }}
  32. </p>
  33. </div>
  34. </div>
  35. </div>
  36. {# Lista de usuarios y conexiones #} {% for user, connections in
  37. valid_users.items() %}
  38. <div class="bg-white rounded-lg shadow-md mb-6 overflow-hidden">
  39. <!-- Encabezado de usuario con iconos FA -->
  40. <div
  41. class="p-4 border-b flex flex-col sm:flex-row sm:items-center sm:justify-between"
  42. >
  43. <div class="flex items-center mb-2 sm:mb-0">
  44. <div
  45. class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center mr-3"
  46. >
  47. <i class="fas fa-user text-blue-600"></i>
  48. </div>
  49. <h2 class="text-lg font-bold">{{ user }}</h2>
  50. </div>
  51. <div class="flex flex-wrap gap-3">
  52. <div class="flex items-center text-sm text-gray-600">
  53. <i class="fas fa-link mr-1 text-blue-500"></i>
  54. <span>{{ connections|length }} conexiones</span>
  55. </div>
  56. {% set total_data = namespace(value=0) %} {% set total_requests =
  57. namespace(value=0) %} {% for connection in connections %} {% if
  58. connection.fd_total != "N/A" %} {% set total_data.value = total_data.value
  59. + connection.fd_total %} {% endif %} {% set total_requests.value =
  60. total_requests.value + connection.nrequests %} {% endfor %}
  61. <div class="flex items-center text-sm text-gray-600">
  62. <i class="fas fa-database mr-1 text-green-500"></i>
  63. <span>{{ (total_data.value / 1024 / 1024)|round(2) }} MB</span>
  64. </div>
  65. <div class="flex items-center text-sm text-gray-600">
  66. <i class="fas fa-bullhorn mr-1 text-purple-500"></i>
  67. <span>{{ total_requests.value }} solicitudes</span>
  68. </div>
  69. </div>
  70. </div>
  71. <!-- Tabla de conexiones - Columna "Dir. Local" eliminada -->
  72. <div class="overflow-x-auto">
  73. <table class="min-w-full divide-y divide-gray-200">
  74. <thead class="bg-gray-50">
  75. <tr>
  76. <th
  77. class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
  78. >
  79. Tiempo
  80. </th>
  81. <th
  82. class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
  83. >
  84. Método
  85. </th>
  86. <th
  87. class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
  88. >
  89. URL
  90. </th>
  91. <th
  92. class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
  93. >
  94. Datos
  95. </th>
  96. <th
  97. class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
  98. >
  99. Delay Pool
  100. </th>
  101. <th
  102. class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
  103. >
  104. Solicitudes
  105. </th>
  106. <th
  107. class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
  108. >
  109. Dir. Remota
  110. </th>
  111. </tr>
  112. </thead>
  113. <tbody class="divide-y divide-gray-200">
  114. {% for connection in connections %}
  115. <tr class="hover:bg-gray-50">
  116. <!-- Tiempo -->
  117. <td class="px-4 py-3 whitespace-nowrap text-sm">
  118. {% set seconds = connection.elapsed_time|float %} {% if seconds >=
  119. 3600 %} {{ "%.2f"|format(seconds/3600) }} horas {% elif seconds >=
  120. 60 %} {{ "%.2f"|format(seconds/60) }} min {% else %} {{
  121. "%.2f"|format(seconds) }} seg {% endif %}
  122. </td>
  123. <!-- Método con estilos mejorados -->
  124. <td class="px-4 py-3 whitespace-nowrap">
  125. <span
  126. class="px-2 py-1 rounded-full text-xs font-semibold {% if connection.logType|lower == 'get' %}bg-green-100 text-green-800 {% elif connection.logType|lower == 'post' %}bg-blue-100 text-blue-800 {% elif connection.logType|lower == 'connect' %}bg-yellow-100 text-yellow-800 {% else %}bg-gray-100 text-gray-800{% endif %}"
  127. >
  128. {{ connection.logType }}
  129. </span>
  130. </td>
  131. <!-- URL con truncado mejorado -->
  132. <td class="px-4 py-3 max-w-xs">
  133. <div class="truncate text-sm" title="{{ connection.uri }}">
  134. {{ connection.uri }}
  135. </div>
  136. </td>
  137. <!-- Datos -->
  138. <td class="px-4 py-3 whitespace-nowrap text-sm">
  139. {% if connection.fd_total != "N/A" %} {{ (connection.fd_total / 1024
  140. /1024)|round(2) }} MB {% else %} N/A {% endif %}
  141. </td>
  142. <!-- Delay Pool con estilos -->
  143. <td class="px-4 py-3 whitespace-nowrap">
  144. {% if connection.delay_pool != "N/A" %}
  145. <span
  146. class="px-2 py-1 rounded-full text-xs font-semibold bg-indigo-100 text-indigo-800"
  147. >
  148. Pool {{ connection.delay_pool }}
  149. </span>
  150. {% else %}
  151. <span class="text-sm text-gray-500">N/A</span>
  152. {% endif %}
  153. </td>
  154. <!-- Solicitudes -->
  155. <td class="px-4 py-3 whitespace-nowrap text-sm font-medium">
  156. {{ connection.nrequests }}
  157. </td>
  158. <!-- Dir. Remota (única columna de IP) -->
  159. <td class="px-4 py-3 whitespace-nowrap text-sm font-mono">
  160. {{ connection.remote }}
  161. </td>
  162. </tr>
  163. {% endfor %}
  164. </tbody>
  165. </table>
  166. </div>
  167. </div>
  168. {% endfor %}