black_list.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
  2. <div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-6">
  3. <h1 class="text-3xl font-bold text-gray-800 mb-4 md:mb-0">
  4. <svg class="h-8 w-8 inline-block mr-2 text-red-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  5. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"/>
  6. </svg>
  7. Actividad en Sitios Bloqueados
  8. </h1>
  9. <div class="bg-gray-100 px-4 py-2 rounded-lg shadow-sm">
  10. <span class="text-sm font-medium text-gray-600">
  11. Página {{ pagination.page }} de {{ pagination.total_pages }}
  12. </span>
  13. </div>
  14. </div>
  15. <div class="bg-white rounded-lg shadow-md overflow-hidden">
  16. <div class="px-6 py-4 border-b border-gray-200 bg-gray-50 flex flex-col sm:flex-row justify-between items-center">
  17. <div class="mb-2 sm:mb-0">
  18. <span class="text-sm font-medium text-gray-600">
  19. Total de registros:
  20. <span class="font-bold text-red-600">{{ pagination.total }}</span>
  21. </span>
  22. </div>
  23. <div class="flex items-center">
  24. <span class="text-sm font-medium text-gray-600 mr-2">Mostrar:</span>
  25. <select id="per_page" class="border rounded px-2 py-1 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
  26. onchange="window.location.href = updateQueryParam('per_page', this.value)">
  27. <option value="20" {% if pagination.per_page == 20 %}selected{% endif %}>20</option>
  28. <option value="50" {% if pagination.per_page == 50 %}selected{% endif %}>50</option>
  29. <option value="100" {% if pagination.per_page == 100 %}selected{% endif %}>100</option>
  30. </select>
  31. </div>
  32. </div>
  33. <div class="divide-y divide-gray-200">
  34. {% for user, items in results | groupby('usuario') %}
  35. {% set user_items = items | list %}
  36. <div class="user-group">
  37. <div class="px-6 py-4 bg-white">
  38. <div class="flex flex-col sm:flex-row sm:justify-between sm:items-center">
  39. <div class="flex items-center mb-2 sm:mb-0">
  40. <svg class="h-6 w-6 mr-3 text-blue-500 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  41. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>
  42. </svg>
  43. <h2 class="text-lg font-semibold text-gray-800">{{ user }}</h2>
  44. </div>
  45. <div class="flex-shrink-0">
  46. <span class="px-3 py-1 bg-red-100 text-red-800 text-xs font-bold rounded-full">
  47. {{ user_items | length }} Intentos Bloqueados
  48. </span>
  49. </div>
  50. </div>
  51. </div>
  52. <div class="px-6 py-4 border-t border-gray-200 bg-gray-50/50">
  53. <div class="space-y-2">
  54. {# Bloque para agrupar manualmente por dominio principal #}
  55. {% set grouped_by_domain = {} %}
  56. {% for item in user_items %}
  57. {% set url_lower = item.url | lower %}
  58. {% set parent_domain = 'unknown' %}
  59. {% if 'facebook.com' in url_lower or 'fb.com' in url_lower %} {% set parent_domain = 'facebook.com' %}
  60. {% elif 'instagram.com' in url_lower %} {% set parent_domain = 'instagram.com' %}
  61. {% elif 'youtube.com' in url_lower or 'ytimg.com' in url_lower %} {% set parent_domain = 'youtube.com' %}
  62. {% elif 'twitter.com' in url_lower or 'x.com' in url_lower %} {% set parent_domain = 'twitter.com' %}
  63. {% elif 'tiktok.com' in url_lower %} {% set parent_domain = 'tiktok.com' %}
  64. {% elif 'whatsapp.com' in url_lower %} {% set parent_domain = 'whatsapp.com' %}
  65. {% elif 'netflix.com' in url_lower %} {% set parent_domain = 'netflix.com' %}
  66. {% else %}
  67. {% set domain_parts = item.url.split('/')[0].split('.') %}
  68. {% if domain_parts | length >= 2 %}
  69. {% set parent_domain = domain_parts[-2] + '.' + domain_parts[-1] %}
  70. {% else %}
  71. {% set parent_domain = item.url.split('/')[0] %}
  72. {% endif %}
  73. {% endif %}
  74. {% set current_items = grouped_by_domain.get(parent_domain, []) %}
  75. {% set _ = current_items.append(item) %}
  76. {% set _ = grouped_by_domain.update({parent_domain: current_items}) %}
  77. {% endfor %}
  78. {# Iterar sobre los dominios agrupados y mostrarlos en filas sin icono #}
  79. {% for domain, domain_items in grouped_by_domain.items() | sort %}
  80. {% set count = domain_items | length %}
  81. {% set all_urls = (domain_items | map(attribute='url') | unique | list) | join('\n') %}
  82. <div class="flex items-center p-2 bg-white rounded-md shadow-sm" title="URLs reales:\n{{ all_urls }}">
  83. <p class="flex-grow font-mono text-sm text-gray-800 truncate pr-4">{{ domain }}</p>
  84. <span class="flex-shrink-0 px-2.5 py-0.5 text-xs font-bold text-red-800 bg-red-100 rounded-full">
  85. {{ count }}
  86. </span>
  87. </div>
  88. {% endfor %}
  89. </div>
  90. </div>
  91. </div>
  92. {% else %}
  93. <div class="px-6 py-12 text-center">
  94. <svg class="mx-auto h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
  95. <path vector-effect="non-scaling-stroke" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
  96. </svg>
  97. <h3 class="mt-2 text-sm font-medium text-gray-900">No se encontraron registros</h3>
  98. <p class="mt-1 text-sm text-gray-500">No hay actividad en sitios bloqueados para mostrar.</p>
  99. </div>
  100. {% endfor %}
  101. </div>
  102. <div class="px-6 py-4 border-t border-gray-200 bg-gray-50">
  103. <div class="flex flex-col sm:flex-row justify-between items-center">
  104. <span class="text-sm text-gray-600 mb-2 sm:mb-0">
  105. Mostrando {{ (results | groupby('usuario') | list) | length }} grupos de usuarios en esta página.
  106. </span>
  107. <div class="flex space-x-2">
  108. <a href="{{ url_for('blacklist_logs', page=pagination.page-1, per_page=pagination.per_page) }}"
  109. class="px-4 py-2 bg-white border rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 {% if pagination.page == 1 %}opacity-50 cursor-not-allowed{% endif %}">
  110. Anterior
  111. </a>
  112. <a href="{{ url_for('blacklist_logs', page=pagination.page+1, per_page=pagination.per_page) }}"
  113. class="px-4 py-2 bg-white border rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 {% if pagination.page >= pagination.total_pages %}opacity-50 cursor-not-allowed{% endif %}">
  114. Siguiente
  115. </a>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. </div>
  121. <script>
  122. function updateQueryParam(param, value) {
  123. const url = new URL(window.location.href);
  124. url.searchParams.set(param, value);
  125. url.searchParams.set('page', '1');
  126. return url.toString();
  127. }
  128. </script>