|
|
@@ -0,0 +1,236 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="es">
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
+ <title>Dashboard de Navegación</title>
|
|
|
+ <script src="https://cdn.tailwindcss.com"></script>
|
|
|
+ <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
|
+ <script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@2.0.0"></script>
|
|
|
+</head>
|
|
|
+<body class="bg-gray-100">
|
|
|
+ <div class="container mx-auto px-4 py-8">
|
|
|
+ <header class="mb-8">
|
|
|
+ <h1 class="text-3xl font-bold text-gray-800">Dashboard de Navegación</h1>
|
|
|
+ <div class="flex flex-wrap justify-between mt-4">
|
|
|
+ <div class="bg-white p-4 rounded-lg shadow-md w-full md:w-auto mb-4 md:mb-0">
|
|
|
+ <h3 class="text-lg font-semibold text-gray-700">Usuarios Totales</h3>
|
|
|
+ <p class="text-2xl font-bold text-blue-600">{{ metrics.total_stats.total_users }}</p>
|
|
|
+ </div>
|
|
|
+ <div class="bg-white p-4 rounded-lg shadow-md w-full md:w-auto mb-4 md:mb-0">
|
|
|
+ <h3 class="text-lg font-semibold text-gray-700">Registros de Log</h3>
|
|
|
+ <p class="text-2xl font-bold text-green-600">{{ metrics.total_stats.total_log_entries }}</p>
|
|
|
+ </div>
|
|
|
+ <div class="bg-white p-4 rounded-lg shadow-md w-full md:w-auto mb-4 md:mb-0">
|
|
|
+ <h3 class="text-lg font-semibold text-gray-700">Datos Transmitidos</h3>
|
|
|
+ <p class="text-2xl font-bold text-purple-600">{{ "%.2f"|format(metrics.total_stats.total_data_transmitted / (1024**3)) }} GB</p>
|
|
|
+ </div>
|
|
|
+ <div class="bg-white p-4 rounded-lg shadow-md w-full md:w-auto">
|
|
|
+ <h3 class="text-lg font-semibold text-gray-700">Total Requests</h3>
|
|
|
+ <p class="text-2xl font-bold text-orange-600">{{ metrics.total_stats.total_requests }}</p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </header>
|
|
|
+
|
|
|
+ <div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8">
|
|
|
+ <div class="bg-white p-6 rounded-lg shadow-md">
|
|
|
+ <h2 class="text-xl font-bold mb-4 text-gray-800">Top 20 Usuarios por Actividad</h2>
|
|
|
+ <div class="h-80">
|
|
|
+ <canvas id="usersActivityChart"></canvas>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="bg-white p-6 rounded-lg shadow-md">
|
|
|
+ <h2 class="text-xl font-bold mb-4 text-gray-800">Top 20 Usuarios por Datos Transmitidos</h2>
|
|
|
+ <div class="h-80">
|
|
|
+ <canvas id="usersDataChart"></canvas>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="bg-white p-6 rounded-lg shadow-md mb-8">
|
|
|
+ <h2 class="text-xl font-bold mb-4 text-gray-800">Distribución de Códigos HTTP</h2>
|
|
|
+ <div class="h-96">
|
|
|
+ <canvas id="httpCodesChart"></canvas>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="bg-white p-6 rounded-lg shadow-md mb-8">
|
|
|
+ <h2 class="text-xl font-bold mb-4 text-gray-800">Top 20 Páginas Más Visitadas</h2>
|
|
|
+ <div class="overflow-x-auto">
|
|
|
+ <table class="min-w-full divide-y divide-gray-200">
|
|
|
+ <thead class="bg-gray-50">
|
|
|
+ <tr>
|
|
|
+ <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">URL</th>
|
|
|
+ <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Total Requests</th>
|
|
|
+ <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Visitas Únicas</th>
|
|
|
+ <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Datos Transmitidos</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody class="bg-white divide-y divide-gray-200">
|
|
|
+ {% for page in metrics.top_pages %}
|
|
|
+ <tr class="hover:bg-gray-50">
|
|
|
+ <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 truncate max-w-xs">{{ page.url }}</td>
|
|
|
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ page.total_requests }}</td>
|
|
|
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ page.unique_visits }}</td>
|
|
|
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ "%.2f"|format(page.total_data_bytes / (1024**2)) }} MB</td>
|
|
|
+ </tr>
|
|
|
+ {% endfor %}
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="bg-white p-6 rounded-lg shadow-md">
|
|
|
+ <h2 class="text-xl font-bold mb-4 text-gray-800">IPs Compartidas por Múltiples Usuarios</h2>
|
|
|
+ <div class="overflow-x-auto">
|
|
|
+ <table class="min-w-full divide-y divide-gray-200">
|
|
|
+ <thead class="bg-gray-50">
|
|
|
+ <tr>
|
|
|
+ <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">IP</th>
|
|
|
+ <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Número de Usuarios</th>
|
|
|
+ <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Usuarios</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody class="bg-white divide-y divide-gray-200">
|
|
|
+ {% for ip in metrics.users_per_ip %}
|
|
|
+ <tr class="hover:bg-gray-50">
|
|
|
+ <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">{{ ip.ip }}</td>
|
|
|
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ ip.user_count }}</td>
|
|
|
+ <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ ip.usernames }}</td>
|
|
|
+ </tr>
|
|
|
+ {% endfor %}
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <script>
|
|
|
+ const chartColors = [
|
|
|
+ '#3B82F6', '#10B981', '#F59E0B', '#EF4444', '#8B5CF6',
|
|
|
+ '#EC4899', '#14B8A6', '#F97316', '#64748B', '#84CC16',
|
|
|
+ '#06B6D4', '#D946EF', '#F43F5E', '#0EA5E9', '#22C55E',
|
|
|
+ '#EAB308', '#F43F5E', '#8B5CF6', '#EC4899', '#14B8A6'
|
|
|
+ ];
|
|
|
+
|
|
|
+ const usersActivityCtx = document.getElementById('usersActivityChart').getContext('2d');
|
|
|
+ new Chart(usersActivityCtx, {
|
|
|
+ type: 'bar',
|
|
|
+ data: {
|
|
|
+ labels: {{ metrics.top_users_by_activity | map(attribute='username') | list | tojson }},
|
|
|
+ datasets: [{
|
|
|
+ label: 'Visitas',
|
|
|
+ data: {{ metrics.top_users_by_activity | map(attribute='total_visits') | list | tojson }},
|
|
|
+ backgroundColor: chartColors,
|
|
|
+ borderColor: chartColors.map(color => color.replace('0.6', '1')),
|
|
|
+ borderWidth: 1
|
|
|
+ }]
|
|
|
+ },
|
|
|
+ options: {
|
|
|
+ responsive: true,
|
|
|
+ maintainAspectRatio: false,
|
|
|
+ plugins: {
|
|
|
+ legend: { display: false },
|
|
|
+ tooltip: { mode: 'index', intersect: false },
|
|
|
+ datalabels: { display: false }
|
|
|
+ },
|
|
|
+ scales: {
|
|
|
+ y: { beginAtZero: true, title: { display: true, text: 'Número de Visitas' } },
|
|
|
+ x: { ticks: { autoSkip: false } }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ const usersDataCtx = document.getElementById('usersDataChart').getContext('2d');
|
|
|
+ new Chart(usersDataCtx, {
|
|
|
+ type: 'bar',
|
|
|
+ data: {
|
|
|
+ labels: {{ metrics.top_users_by_data_transferred | map(attribute='username') | list | tojson }},
|
|
|
+ datasets: [{
|
|
|
+ label: 'Datos (MB)',
|
|
|
+ data: {{ metrics.top_users_by_data_transferred | map(attribute='total_data_bytes') |
|
|
|
+ map('divide', 1048576) | list | tojson }},
|
|
|
+ backgroundColor: chartColors,
|
|
|
+ borderColor: chartColors.map(color => color.replace('0.6', '1')),
|
|
|
+ borderWidth: 1
|
|
|
+ }]
|
|
|
+ },
|
|
|
+ options: {
|
|
|
+ responsive: true,
|
|
|
+ maintainAspectRatio: false,
|
|
|
+ plugins: {
|
|
|
+ legend: { display: false },
|
|
|
+ tooltip: {
|
|
|
+ mode: 'index',
|
|
|
+ intersect: false,
|
|
|
+ callbacks: {
|
|
|
+ label: function(context) {
|
|
|
+ return `${context.dataset.label}: ${context.raw.toFixed(2)} MB`;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ datalabels: { display: false }
|
|
|
+ },
|
|
|
+ scales: {
|
|
|
+ y: {
|
|
|
+ beginAtZero: true,
|
|
|
+ title: { display: true, text: 'Datos Transmitidos (MB)' }
|
|
|
+ },
|
|
|
+ x: { ticks: { autoSkip: false } }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ const httpCodesCtx = document.getElementById('httpCodesChart').getContext('2d');
|
|
|
+ new Chart(httpCodesCtx, {
|
|
|
+ type: 'pie',
|
|
|
+ data: {
|
|
|
+ labels: {{ metrics.http_response_distribution_chart.labels | tojson }},
|
|
|
+ datasets: [{
|
|
|
+ data: {{ metrics.http_response_distribution_chart.data | tojson }},
|
|
|
+ backgroundColor: {{ metrics.http_response_distribution_chart.colors | tojson }},
|
|
|
+ borderColor: '#fff',
|
|
|
+ borderWidth: 1
|
|
|
+ }]
|
|
|
+ },
|
|
|
+ options: {
|
|
|
+ responsive: true,
|
|
|
+ maintainAspectRatio: false,
|
|
|
+ plugins: {
|
|
|
+ legend: {
|
|
|
+ position: 'right',
|
|
|
+ labels: {
|
|
|
+ font: {
|
|
|
+ size: 12
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ tooltip: {
|
|
|
+ callbacks: {
|
|
|
+ label: function(context) {
|
|
|
+ const total = context.dataset.data.reduce((a, b) => a + b, 0);
|
|
|
+ const percentage = (context.raw / total * 100).toFixed(1);
|
|
|
+ return `${context.label}: ${context.raw} (${percentage}%)`;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ datalabels: {
|
|
|
+ formatter: (value, ctx) => {
|
|
|
+ const total = ctx.chart.data.datasets[0].data.reduce((a, b) => a + b, 0);
|
|
|
+ const percentage = (value / total * 100).toFixed(1);
|
|
|
+ return percentage > 3 ? `${percentage}%` : '';
|
|
|
+ },
|
|
|
+ color: '#fff',
|
|
|
+ font: {
|
|
|
+ weight: 'bold',
|
|
|
+ size: 12
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ plugins: [ChartDataLabels]
|
|
|
+ });
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+</html>
|