| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
- <div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-6">
- <h1 class="text-3xl font-bold text-gray-800 mb-4 md:mb-0">
- <svg class="h-8 w-8 inline-block mr-2 text-red-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <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"/>
- </svg>
- Actividad en Sitios Bloqueados
- </h1>
-
- <div class="bg-gray-100 px-4 py-2 rounded-lg shadow-sm">
- <span class="text-sm font-medium text-gray-600">
- Página {{ pagination.page }} de {{ pagination.total_pages }}
- </span>
- </div>
- </div>
- <div class="bg-white rounded-lg shadow-md overflow-hidden">
- <div class="px-6 py-4 border-b border-gray-200 bg-gray-50 flex flex-col sm:flex-row justify-between items-center">
- <div class="mb-2 sm:mb-0">
- <span class="text-sm font-medium text-gray-600">
- Total de registros:
- <span class="font-bold text-red-600">{{ pagination.total }}</span>
- </span>
- </div>
- <div class="flex items-center">
- <span class="text-sm font-medium text-gray-600 mr-2">Mostrar:</span>
- <select id="per_page" class="border rounded px-2 py-1 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
- onchange="window.location.href = updateQueryParam('per_page', this.value)">
- <option value="20" {% if pagination.per_page == 20 %}selected{% endif %}>20</option>
- <option value="50" {% if pagination.per_page == 50 %}selected{% endif %}>50</option>
- <option value="100" {% if pagination.per_page == 100 %}selected{% endif %}>100</option>
- </select>
- </div>
- </div>
- <div class="divide-y divide-gray-200">
- {% for user, items in results | groupby('usuario') %}
- {% set user_items = items | list %}
- <div class="user-group">
- <div class="px-6 py-4 bg-white">
- <div class="flex flex-col sm:flex-row sm:justify-between sm:items-center">
- <div class="flex items-center mb-2 sm:mb-0">
- <svg class="h-6 w-6 mr-3 text-blue-500 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <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"/>
- </svg>
- <h2 class="text-lg font-semibold text-gray-800">{{ user }}</h2>
- </div>
- <div class="flex-shrink-0">
- <span class="px-3 py-1 bg-red-100 text-red-800 text-xs font-bold rounded-full">
- {{ user_items | length }} Intentos Bloqueados
- </span>
- </div>
- </div>
- </div>
- <div class="px-6 py-4 border-t border-gray-200 bg-gray-50/50">
- <div class="space-y-2">
- {# Bloque para agrupar manualmente por dominio principal #}
- {% set grouped_by_domain = {} %}
- {% for item in user_items %}
- {% set url_lower = item.url | lower %}
- {% set parent_domain = 'unknown' %}
- {% if 'facebook.com' in url_lower or 'fb.com' in url_lower %} {% set parent_domain = 'facebook.com' %}
- {% elif 'instagram.com' in url_lower %} {% set parent_domain = 'instagram.com' %}
- {% elif 'youtube.com' in url_lower or 'ytimg.com' in url_lower %} {% set parent_domain = 'youtube.com' %}
- {% elif 'twitter.com' in url_lower or 'x.com' in url_lower %} {% set parent_domain = 'twitter.com' %}
- {% elif 'tiktok.com' in url_lower %} {% set parent_domain = 'tiktok.com' %}
- {% elif 'whatsapp.com' in url_lower %} {% set parent_domain = 'whatsapp.com' %}
- {% elif 'netflix.com' in url_lower %} {% set parent_domain = 'netflix.com' %}
- {% else %}
- {% set domain_parts = item.url.split('/')[0].split('.') %}
- {% if domain_parts | length >= 2 %}
- {% set parent_domain = domain_parts[-2] + '.' + domain_parts[-1] %}
- {% else %}
- {% set parent_domain = item.url.split('/')[0] %}
- {% endif %}
- {% endif %}
- {% set current_items = grouped_by_domain.get(parent_domain, []) %}
- {% set _ = current_items.append(item) %}
- {% set _ = grouped_by_domain.update({parent_domain: current_items}) %}
- {% endfor %}
- {# Iterar sobre los dominios agrupados y mostrarlos en filas sin icono #}
- {% for domain, domain_items in grouped_by_domain.items() | sort %}
- {% set count = domain_items | length %}
- {% set all_urls = (domain_items | map(attribute='url') | unique | list) | join('\n') %}
- <div class="flex items-center p-2 bg-white rounded-md shadow-sm" title="URLs reales:\n{{ all_urls }}">
- <p class="flex-grow font-mono text-sm text-gray-800 truncate pr-4">{{ domain }}</p>
- <span class="flex-shrink-0 px-2.5 py-0.5 text-xs font-bold text-red-800 bg-red-100 rounded-full">
- {{ count }}
- </span>
- </div>
- {% endfor %}
- </div>
- </div>
- </div>
- {% else %}
- <div class="px-6 py-12 text-center">
- <svg class="mx-auto h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
- <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" />
- </svg>
- <h3 class="mt-2 text-sm font-medium text-gray-900">No se encontraron registros</h3>
- <p class="mt-1 text-sm text-gray-500">No hay actividad en sitios bloqueados para mostrar.</p>
- </div>
- {% endfor %}
- </div>
- <div class="px-6 py-4 border-t border-gray-200 bg-gray-50">
- <div class="flex flex-col sm:flex-row justify-between items-center">
- <span class="text-sm text-gray-600 mb-2 sm:mb-0">
- Mostrando {{ (results | groupby('usuario') | list) | length }} grupos de usuarios en esta página.
- </span>
- <div class="flex space-x-2">
- <a href="{{ url_for('blacklist_logs', page=pagination.page-1, per_page=pagination.per_page) }}"
- 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 %}">
- Anterior
- </a>
- <a href="{{ url_for('blacklist_logs', page=pagination.page+1, per_page=pagination.per_page) }}"
- 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 %}">
- Siguiente
- </a>
- </div>
- </div>
- </div>
- </div>
- </div>
- <script>
- function updateQueryParam(param, value) {
- const url = new URL(window.location.href);
- url.searchParams.set(param, value);
- url.searchParams.set('page', '1');
- return url.toString();
- }
- </script>
|