Add reenviar button in /logs for failed envios
POST /logs/reenviar/{id} re-sends stored JSON to TNS and updates
status to 'success' in-place if it succeeds. Button appears only
on error rows with saved JSON; updates row color and badge without reload.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
3d848fbf2d
commit
cb3b327938
+37
-2
@@ -135,11 +135,17 @@
|
||||
</td>
|
||||
<td class="px-2 py-2.5 text-gray-400 whitespace-nowrap">{{ e.created_at[:16] if e.created_at else '-' }}</td>
|
||||
<td class="px-2 py-2.5 text-gray-400">{{ e.username or '-' }}</td>
|
||||
<td class="px-2 py-2.5">
|
||||
<td class="px-2 py-2.5 flex items-center gap-1.5">
|
||||
<button onclick="verDetalle({{ e.id }})"
|
||||
class="px-2 py-1 bg-gray-100 hover:bg-gray-200 text-gray-600 rounded" title="Ver detalle completo">
|
||||
class="px-2 py-1 bg-gray-100 hover:bg-gray-200 text-gray-600 rounded" title="Ver detalle">
|
||||
<i class="fas fa-eye"></i>
|
||||
</button>
|
||||
{% if e.status == 'error' and e.json_enviado %}
|
||||
<button onclick="reenviar({{ e.id }}, this)"
|
||||
class="px-2 py-1 bg-orange-100 hover:bg-orange-200 text-orange-700 rounded" title="Reenviar a TNS">
|
||||
<i class="fas fa-redo text-xs"></i>
|
||||
</button>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
@@ -204,6 +210,35 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
async function reenviar(id, btn) {
|
||||
btn.disabled = true;
|
||||
btn.innerHTML = '<i class="fas fa-spinner fa-spin text-xs"></i>';
|
||||
try {
|
||||
const resp = await fetch(`/logs/reenviar/${id}`, {method: 'POST', credentials: 'include'});
|
||||
const data = await resp.json();
|
||||
if (data.success) {
|
||||
showToast('Reenvío exitoso', 'success');
|
||||
const row = btn.closest('tr');
|
||||
row.classList.remove('bg-red-50/25');
|
||||
row.classList.add('bg-green-50/25');
|
||||
const badge = row.querySelector('td:nth-child(6) span');
|
||||
if (badge) {
|
||||
badge.textContent = '✓ OK';
|
||||
badge.className = 'px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-700';
|
||||
}
|
||||
btn.remove();
|
||||
} else {
|
||||
showToast(data.message || 'Error al reenviar', 'error');
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = '<i class="fas fa-redo text-xs"></i>';
|
||||
}
|
||||
} catch(e) {
|
||||
showToast('Error de conexión', 'error');
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = '<i class="fas fa-redo text-xs"></i>';
|
||||
}
|
||||
}
|
||||
|
||||
async function verDetalle(id) {
|
||||
const resp = await fetch(`/logs/detalle/${id}`, {credentials: 'include'});
|
||||
const data = await resp.json();
|
||||
|
||||
Reference in New Issue
Block a user