Fase 3 (islas): historiales de seguridad y transacciones en React/TSX

Tabla genérica reutilizable HistoryTable (columnas por data-columns, filas por
json_script) + entry history_table:
- security_history: intentos de conexión (username/status/ip/fecha). Se elimina la
  caja "actividad" duplicada. Las vistas pasan login_attempts_data serializable.
- trans_history: historial de transacciones (StripeLog) con transactions_data.

Datos embebidos con json_script (sin endpoint extra). Verificado: check OK, ambas
plantillas renderizan la isla con datos.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-12 21:52:20 +00:00
parent cefa30dabc
commit 230d401c75
7 changed files with 107 additions and 82 deletions
+7 -44
View File
@@ -11,53 +11,16 @@
</div>
</div>
<div class="box-content">
<div class="title-box-content"><h2>Historial de actividad</h2></div>
<div class="body-box-content centered">
<table class="max-center-table-aligned2">
<tbody>
{% if login_attempts %}
{% for attempt in login_attempts %}
<tr>
<td>{{ attempt.username }}</td> <!-- Agregado: Mostrar el nombre de usuario -->
<td>{{ attempt.timestamp|date:"d-m-Y H:i:s" }}</td>
<td>{{ attempt.status }}</td>
<td>{{ attempt.ip_address }}</td>
</tr>
{% endfor %}
{% else %}
<tr>
<td colspan="4" class="centered"><span>No hay actividad</span></td>
</tr>
{% endif %}
</tbody>
</table>
</div>
</div>
<div class="box-content">
<div class="title-box-content"><h2>Historial de conexiones</h2></div>
<div class="body-box-content centered">
<table class="max-center-table-aligned">
<thead>
<tr>
<th>Usuario</th>
<th>Estado</th>
<th>IP</th>
<th>Fecha</th>
</tr>
</thead>
<tbody>
{% for attempt in login_attempts %}
<tr>
<td>{{ attempt.username }}</td>
<td>{{ attempt.status }}</td>
<td>{{ attempt.ip_address }}</td>
<td>{{ attempt.timestamp|date:"d-m-Y H:i:s" }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% load django_vite %}
<!-- Isla React (Vite): tabla de intentos de conexión (últimos 20). -->
<div id="history-table-app"
data-columns='[{"key":"username","label":"Usuario"},{"key":"status","label":"Estado"},{"key":"ip_address","label":"IP"},{"key":"timestamp","label":"Fecha"}]'
data-empty-text="No hay actividad"></div>
{{ login_attempts_data|json_script:"history-table-data" }}
{% vite_asset 'src/entries/history_table.tsx' %}
</div>
</div>
</div>