logs.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. {% set response_groups = [
  2. {'key': 'informational', 'icon': 'fa-info-circle', 'color': 'text-blue-500', 'label': _('Respuestas informativas (100–199)')},
  3. {'key': 'successful', 'icon': 'fa-circle-check', 'color': 'text-green-500', 'label': _('Respuestas exitosas (200–299)')},
  4. {'key': 'redirection', 'icon': 'fa-arrow-right', 'color': 'text-yellow-500', 'label': _('Mensajes de redirección (300–399)')},
  5. {'key': 'clientError', 'icon': 'fa-circle-xmark', 'color': 'text-red-500', 'label': _('Respuestas de error del cliente (400–499)')},
  6. {'key': 'serverError', 'icon': 'fa-triangle-exclamation', 'color': 'text-orange-400', 'label': _('Respuestas de error del servidor (500–599)')},
  7. {'key': 'unknown', 'icon': 'fa-question', 'color': 'text-gray-500', 'label': _('Otros')},
  8. ] %}
  9. <div class="w-full space-y-6">
  10. <div class="users-container grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4 max-w-screen-xl mx-auto px-4" id="users-container">
  11. {% if users %}
  12. {% for user in users %}
  13. <div class="user-card group bg-[#f0f2f5] text-center overflow-hidden relative rounded-lg shadow-md w-full max-w-[320px] mx-auto pt-[25px] pb-[70px]" data-username="{{ user.username|lower }}">
  14. <div class="avatar-wrapper relative inline-block h-[100px] w-[100px] mb-[15px] z-[1]">
  15. <div class="avatar-effect absolute w-full h-0 bottom-[135%] left-0 rounded-full bg-[#1369ce] opacity-90 scale-[3] transition-all duration-300 ease-linear z-0 group-hover:h-full"></div>
  16. <div class="avatar-background absolute inset-0 rounded-full bg-[#1369ce] z-[1]"></div>
  17. <div class="avatar w-full h-full rounded-full bg-slate-200 flex items-center justify-center text-[2.5rem] text-slate-500 relative transition-all duration-900 ease-in-out group-hover:shadow-[0_0_0_10px_#f7f5ec] group-hover:scale-[0.7] z-[2]">
  18. <i class="fas fa-user"></i>
  19. </div>
  20. </div>
  21. <div class="user-info mt-[-15px] mb-4 px-[15px]">
  22. <h3 class="username font-semibold text-[1.2rem] text-[#1369ce] mb-0">{{ user.username }}</h3>
  23. <h4 class="ip-address text-[0.9rem] text-gray-500">{{ user.ip }}</h4>
  24. </div>
  25. <div class="card-action px-[15px] mt-[2px] relative z-[2]">
  26. <button class="activity-button w-full bg-[#1369ce] text-white font-bold py-2 rounded-md cursor-pointer transition-all duration-300 text-sm hover:bg-[#0d5bb5] hover:-translate-y-0.5 shadow-md" onclick="window.openLogsModal({{ loop.index0 }})">
  27. {{ _('ACTIVIDAD') }}
  28. </button>
  29. </div>
  30. <ul class="card-footer absolute bottom-[-80px] left-0 w-full px-4 py-3 bg-[#1369ce] text-white text-sm flex justify-between transition-all duration-500 ease-in-out group-hover:bottom-0 shadow-[0_-4px_6px_rgba(0,0,0,0.2)] z-[1]">
  31. <li class="flex flex-col items-center">
  32. <span class="label text-xs font-light uppercase tracking-wide">{{ _('Solicitudes') }}:</span>
  33. <span class="value font-semib">{{ user.total_requests }}</span>
  34. </li>
  35. <li class="flex flex-col items-center">
  36. <span class="label text-xs font-light uppercase tracking-wide">{{ _('Datos') }}:</span>
  37. <span class="value font-semib">{{ user.total_data|format_bytes }}</span>
  38. </li>
  39. </ul>
  40. </div>
  41. {% endfor %}
  42. {% else %}
  43. <div class="text-gray-500 text-center p-4 col-span-full">{{ _('No se encontraron datos') }}</div>
  44. {% endif %}
  45. </div>
  46. <div id="modals-container">
  47. {% for user in users %}
  48. <div class="logs-modal hidden fixed inset-0 bg-black bg-opacity-50 z-[1000] justify-center items-center transition-all duration-1000 ease-in-out opacity-0" id="logs-modal-{{ loop.index0 }}">
  49. <div class="modal-content bg-white p-8 rounded-2xl w-[95%] max-w-[650px] max-h-[85vh] overflow-auto shadow-[0_10px_30px_rgba(0,0,0,0.3)] transition-all duration-1000 ease-in-out relative">
  50. <button onclick="window.closeLogsModal({{ loop.index0 }})"
  51. class="close-btn absolute top-3 right-3 w-8 h-8 flex items-center justify-center bg-red-500 text-white rounded-full z-50 shadow-md transform transition-all duration-300 hover:bg-red-600 hover:scale-110 hover:rotate-90 hover:shadow-lg"
  52. title="{{ _('Cerrar') }}" aria-label="{{ _('Cerrar') }}">
  53. <i class="fas fa-times text-base"></i>
  54. </button>
  55. <div class="flex flex-col">
  56. <div class="flex justify-between items-center mb-4">
  57. <div class="flex items-center gap-2 min-w-0 flex-wrap">
  58. <h4 class="logs-title text-base text-gray-500 uppercase tracking-[1px] font-semibold whitespace-nowrap">
  59. {{ _('Actividad reciente -') }}
  60. </h4>
  61. <div class="flex items-center gap-2">
  62. <span class="username-highlight font-semibold truncate max-w-[120px] text-[#1369ce]">{{ user.username }}</span>
  63. <div id="searchBox-{{ loop.index0 }}" class="relative w-auto h-[38px] bg-white rounded-full transition-all duration-500 ease-in-out shadow-md flex items-center border border-gray-300">
  64. <div id="toggleBtn-{{ loop.index0 }}" class="log-search-toggle absolute left-0 top-0 w-[38px] h-[38px] flex items-center justify-center cursor-pointer z-10">
  65. <i class="fas fa-search text-blue-600 text-sm"></i>
  66. </div>
  67. <div id="inputWrapper-{{ loop.index0 }}" class="log-search-wrapper ml-[38px] w-0 h-[38px] flex items-center transition-[width] duration-500 ease-in-out overflow-hidden">
  68. <input id="mysearch-{{ loop.index0 }}" type="text" placeholder="{{ _('Buscar URL...') }}" class="log-search-input w-full text-xs px-2 py-1 bg-transparent outline-none opacity-0 transition-opacity duration-300 ease-linear min-w-[150px]" />
  69. </div>
  70. <button id="clearBtn-{{ loop.index0 }}" type="button" class="log-search-clear absolute right-2 h-full flex items-center justify-center opacity-0 transition-opacity duration-300 text-gray-400 hover:text-gray-700 text-sm" title="{{ _('Limpiar búsqueda') }}">
  71. <i class="fas fa-times text-lg leading-none"></i>
  72. </button>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. <div class="response-summary flex justify-end gap-4 items-center mb-4 flex-wrap">
  78. {% for group in response_groups %}
  79. {% set count = user.response_summary[group.key] %}
  80. {% if count > 0 %}
  81. <div class="filter-icon flex items-center gap-1 text-sm cursor-pointer transition-colors"
  82. data-filter-type="{{ group.key }}"
  83. data-active="true"
  84. data-color="{{ group.color }}"
  85. title="{{ group.label }}"
  86. onclick="window.toggleResponseFilter(this, {{ loop.index0 }})">
  87. <i class="fa-solid {{ group.icon }}"></i>
  88. <span>{{ count }}</span>
  89. </div>
  90. {% endif %}
  91. {% endfor %}
  92. </div>
  93. </div>
  94. <div class="logs-list mt-2 max-h-[60vh] overflow-y-auto">
  95. {% if user.grouped_logs %}
  96. <div class="log-entries-container grid gap-3">
  97. {% for log in user.grouped_logs %}
  98. <div class="log-entry relative group p-3 bg-white rounded-lg transition-all duration-300 ease-out shadow-md hover:shadow-2xl hover:-translate-y-1 hover:z-10{% if log.is_grouped %} grouped-log-entry{% endif %}"
  99. data-response-code="{{ log.response }}">
  100. <div class="wave-container absolute inset-0 overflow-hidden rounded-lg">
  101. <div class="wave absolute w-full h-full"></div>
  102. </div>
  103. <div class="relative z-10 grid grid-cols-[minmax(0,1fr)_auto] items-start gap-2">
  104. <div class="log-details-grid min-w-0">
  105. <div class="flex items-baseline gap-3">
  106. <span class="log-url text-sm font-medium text-gray-800 truncate">
  107. {{ log.url|truncate(55, True, '...') }}
  108. </span>
  109. {% if log.is_grouped %}
  110. <i class="fas fa-layer-group text-blue-500 ml-2 text-xs" title="{{ _('Solicitudes agrupadas') }}"></i>
  111. {% endif %}
  112. </div>
  113. <div class="mt-1 flex flex-wrap items-center gap-3 text-sm text-gray-600">
  114. <span class="response-badge {% if log.response >= 100 and log.response <= 199 %}bg-blue-400{% elif log.response >= 200 and log.response <= 299 %}bg-green-500{% elif log.response >= 300 and log.response <= 399 %}bg-yellow-400{% elif log.response >= 400 and log.response <= 499 %}bg-red-500{% elif log.response >= 500 and log.response <= 599 %}bg-orange-400{% else %}bg-gray-400{% endif %} inline-block px-2 py-[0.15rem] rounded-md text-[0.65rem] font-medium text-white">
  115. {{ log.response }}
  116. </span>
  117. <span class="log-meta flex items-center gap-1">
  118. <i class="fas fa-hashtag text-gray-400"></i>
  119. {{ log.request_count }} {{ _('reqs') }}
  120. </span>
  121. <span class="log-meta flex items-center gap-1">
  122. <i class="fas fa-database text-gray-400"></i>
  123. {{ log.data_transmitted|format_bytes }}
  124. </span>
  125. </div>
  126. </div>
  127. <div class="flex items-center gap-2 flex-shrink-0">
  128. <i class="fa-solid fa-up-right-from-square text-blue-600 hover:text-blue-800 cursor-pointer text-lg"
  129. title="{{ _('Abrir enlace') }}"
  130. onclick="window.open('{{ log.full_url }}', '_blank')"></i>
  131. </div>
  132. </div>
  133. </div>
  134. {% endfor %}
  135. </div>
  136. {% else %}
  137. <div class="no-logs text-gray-500 text-center py-8">{{ _('No hay actividad registrada') }}</div>
  138. {% endif %}
  139. <div class="no-results hidden text-center py-8 text-gray-500">{{ _('No se encontraron resultados') }}</div>
  140. </div>
  141. </div>
  142. </div>
  143. {% endfor %}
  144. </div>
  145. <div class="pagination-container flex justify-center items-center mt-12 gap-4">
  146. <a href="{{ url_for('logs.logs', date=selected_date, search=search_query, page=1) }}"
  147. aria-label="{{ _('First page') }}"
  148. class="pg-btn first w-12 h-12 flex items-center justify-center rounded-full bg-white text-blue-600 font-semibold shadow-md transition-all duration-200 ease-in-out text-xl hover:-translate-y-1 disabled:cursor-not-allowed disabled:opacity-50 disabled:transform-none {% if pagination.page <= 1 %}pointer-events-none opacity-50{% endif %}">
  149. <i class="fas fa-angle-double-left"></i>
  150. </a>
  151. <a href="{{ url_for('logs.logs', date=selected_date, search=search_query, page=pagination.page - 1) if pagination.page > 1 else '#' }}"
  152. aria-label="{{ _('Previous page') }}"
  153. class="pg-btn prev w-12 h-12 flex items-center justify-center rounded-full bg-white text-blue-600 font-semibold shadow-md transition-all duration-200 ease-in-out text-xl hover:-translate-y-1 disabled:cursor-not-allowed disabled:opacity-50 disabled:transform-none {% if pagination.page <= 1 %}pointer-events-none opacity-50{% endif %}">
  154. <i class="fas fa-angle-left"></i>
  155. </a>
  156. <div class="pagination flex gap-1">
  157. {% for page_number in pagination.page_range %}
  158. <a href="{{ url_for('logs.logs', date=selected_date, search=search_query, page=page_number) }}"
  159. class="pg-btn text-lg px-3 py-1 rounded-full shadow-md font-medium {% if page_number == pagination.page %}bg-blue-500 text-white{% else %}bg-gray-100 text-gray-800 hover:bg-gray-300{% endif %}">
  160. {{ page_number }}
  161. </a>
  162. {% endfor %}
  163. </div>
  164. <a href="{{ url_for('logs.logs', date=selected_date, search=search_query, page=pagination.page + 1) if pagination.page < pagination.total_pages else '#' }}"
  165. aria-label="{{ _('Next page') }}"
  166. class="pg-btn next w-12 h-12 flex items-center justify-center rounded-full bg-white text-blue-600 font-semibold shadow-md transition-all duration-200 ease-in-out text-xl hover:-translate-y-1 disabled:cursor-not-allowed disabled:opacity-50 disabled:transform-none {% if pagination.page >= pagination.total_pages %}pointer-events-none opacity-50{% endif %}">
  167. <i class="fas fa-angle-right"></i>
  168. </a>
  169. <a href="{{ url_for('logs.logs', date=selected_date, search=search_query, page=pagination.total_pages) }}"
  170. aria-label="{{ _('Last page') }}"
  171. class="pg-btn last w-12 h-12 flex items-center justify-center rounded-full bg-white text-blue-600 font-semibold shadow-md transition-all duration-200 ease-in-out text-xl hover:-translate-y-1 disabled:cursor-not-allowed disabled:opacity-50 disabled:transform-none {% if pagination.page >= pagination.total_pages %}pointer-events-none opacity-50{% endif %}">
  172. <i class="fas fa-angle-double-right"></i>
  173. </a>
  174. </div>
  175. </div>
  176. <div class="overlay fixed inset-0 bg-black bg-opacity-50 z-50 hidden transition-opacity duration-1000 ease-in-out opacity-0" id="overlay"></div>