feat: Version 1.11.0 - Mejoras en auditoría, SLA, frontend y correcciones de sincronización

- Refactorización de endpoints de auditoría y helpers
- Mejoras en esquemas de auditoría (audit.py)
- Correcciones en endpoint SLA
- Actualizaciones en múltiples rutas del frontend interno:
  layout, tickets, usuarios, tenants, categorías, sistemas,
  SLA (at-risk, violations), auditoría (main + security), login, perfil
- Actualización de tailwind.config.js
- Eliminación de docs de versiones anteriores (CAMBIOS_v1.10.0, v1.8.0, OPTIMIZACIONES)
- Nuevos scripts de prueba: generate_security_test_data.py, generate_sla_test_data.py
- Script de prueba de sincronización crítica (test_critical_sync.ps1)
- README actualizado en scripts/
This commit is contained in:
2026-02-20 10:53:53 -07:00
parent 517297e89a
commit ceea67eb2b
32 changed files with 5715 additions and 3324 deletions

View File

@@ -312,7 +312,7 @@
<div class="flex gap-5 px-4 py-5 mx-auto max-w-full sm:px-6 lg:px-8">
<aside class="w-60 flex-shrink-0 space-y-4">
<div class="bg-white rounded-lg shadow border border-gray-200 overflow-hidden">
<div class="bg-indigo-600 px-4 py-3">
<div class="bg-blue-700 px-4 py-3">
<h2 class="text-sm font-semibold text-white tracking-wide">Organización</h2>
</div>
<ul class="divide-y divide-gray-100">
@@ -320,7 +320,7 @@
<button
class="w-full text-left px-4 py-2.5 flex items-center justify-between text-sm transition-colors
{filterTenantId === ''
? 'bg-indigo-50 text-indigo-700 font-semibold'
? 'bg-blue-50 text-blue-700 font-semibold'
: 'text-gray-700 hover:bg-gray-50'}"
on:click={() => {
filterTenantId = '';
@@ -338,7 +338,7 @@
<button
class="w-full text-left px-4 py-2.5 flex items-center justify-between text-sm transition-colors
{filterTenantId === tenant.id
? 'bg-indigo-50 text-indigo-700 font-semibold'
? 'bg-blue-50 text-blue-700 font-semibold'
: 'text-gray-700 hover:bg-gray-50'}"
on:click={() => {
filterTenantId = tenant.id;
@@ -347,7 +347,7 @@
>
<span class="truncate pr-1">{tenant.name}</span>
<span
class="text-xs bg-indigo-100 text-indigo-600 rounded-full px-2 py-0.5 font-medium flex-shrink-0"
class="text-xs bg-gray-100 text-blue-700 rounded-full px-2 py-0.5 font-medium flex-shrink-0 border border-gray-200"
>
{tenantCounts[tenant.id] ?? 0}
</span>
@@ -366,7 +366,7 @@
<select
bind:value={filterStatus}
on:change={() => (categoryPages = {})}
class="block w-full rounded-md border-gray-300 text-sm focus:border-indigo-500 focus:ring-indigo-500 border px-2 py-1.5"
class="block w-full rounded-md border-gray-300 text-sm focus:border-blue-500 focus:ring-blue-500 border px-2 py-1.5"
>
<option value="">Todos</option>
{#each STATUSES as s}
@@ -380,7 +380,7 @@
<select
bind:value={filterPriority}
on:change={() => (categoryPages = {})}
class="block w-full rounded-md border-gray-300 text-sm focus:border-indigo-500 focus:ring-indigo-500 border px-2 py-1.5"
class="block w-full rounded-md border-gray-300 text-sm focus:border-blue-500 focus:ring-blue-500 border px-2 py-1.5"
>
<option value="">Todas</option>
{#each PRIORITIES as p}
@@ -398,7 +398,7 @@
searchQuery = '';
categoryPages = {};
}}
class="w-full text-xs text-indigo-600 hover:text-indigo-800 font-medium text-center pt-1"
class="w-full text-xs text-blue-700 hover:text-blue-800 font-medium text-center pt-1"
>
Limpiar filtros
</button>
@@ -430,107 +430,44 @@
</div>
<button
on:click={openCreateModal}
class="inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-indigo-600 rounded-md shadow-sm hover:bg-indigo-700 transition-colors"
class="inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-blue-700 rounded-md shadow-sm hover:bg-blue-800 transition-colors"
>
+ Nuevo Ticket
</button>
</div>
<div class="grid grid-cols-4 gap-3">
<div class="bg-white rounded-xl border border-gray-200 shadow-sm p-4 flex items-center gap-3">
<div class="bg-gray-100 rounded-lg p-2">
<svg class="h-5 w-5 text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"
/>
</svg>
</div>
<div>
<p class="text-xs text-gray-500 font-medium">Total</p>
<p class="text-2xl font-bold text-gray-900">{kpiTotal}</p>
</div>
<div class="bg-white rounded-xl border border-gray-200 shadow-sm p-4">
<p class="text-xs text-gray-500 font-medium">Total</p>
<p class="text-2xl font-bold text-gray-900">{kpiTotal}</p>
</div>
<div class="bg-white rounded-xl border border-red-200 shadow-sm p-4 flex items-center gap-3">
<div class="bg-red-50 rounded-lg p-2">
<svg class="h-5 w-5 text-red-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 9v2m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"
/>
</svg>
</div>
<div>
<p class="text-xs text-red-500 font-medium">Urgentes</p>
<p class="text-2xl font-bold text-red-600">{kpiUrgent}</p>
</div>
<div class="bg-white rounded-xl border border-red-200 shadow-sm p-4">
<p class="text-xs text-red-500 font-medium">Urgentes</p>
<p class="text-2xl font-bold text-red-600">{kpiUrgent}</p>
</div>
<div class="bg-white rounded-xl border border-blue-200 shadow-sm p-4 flex items-center gap-3">
<div class="bg-blue-50 rounded-lg p-2">
<svg class="h-5 w-5 text-blue-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M13 10V3L4 14h7v7l9-11h-7z"
/>
</svg>
</div>
<div>
<p class="text-xs text-blue-500 font-medium">Activos</p>
<p class="text-2xl font-bold text-blue-600">{kpiActive}</p>
</div>
<div class="bg-white rounded-xl border border-blue-200 shadow-sm p-4">
<p class="text-xs text-blue-500 font-medium">Activos</p>
<p class="text-2xl font-bold text-blue-600">{kpiActive}</p>
</div>
<div
class="bg-white rounded-xl border border-green-200 shadow-sm p-4 flex items-center gap-3"
>
<div class="bg-green-50 rounded-lg p-2">
<svg class="h-5 w-5 text-green-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
/>
</svg>
</div>
<div>
<p class="text-xs text-green-500 font-medium">Resueltos</p>
<p class="text-2xl font-bold text-green-600">{kpiResolved}</p>
</div>
<div class="bg-white rounded-xl border border-green-200 shadow-sm p-4">
<p class="text-xs text-green-500 font-medium">Resueltos</p>
<p class="text-2xl font-bold text-green-600">{kpiResolved}</p>
</div>
</div>
<div class="relative">
<svg
class="pointer-events-none absolute left-3 top-2.5 h-4 w-4 text-gray-400"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M21 21l-4.35-4.35M17 11A6 6 0 1 1 5 11a6 6 0 0 1 12 0z"
/>
</svg>
<input
type="text"
placeholder="Buscar por número, asunto, usuario..."
bind:value={searchQuery}
on:input={() => (categoryPages = {})}
class="w-full pl-9 pr-3 py-2 text-sm border border-gray-300 rounded-lg focus:ring-indigo-500 focus:border-indigo-500"
class="w-full pl-9 pr-3 py-2 text-sm border border-gray-300 rounded-lg focus:ring-blue-500 focus:border-blue-500"
/>
</div>
{#if isLoading}
<div class="flex justify-center items-center py-16 text-gray-400 text-sm">
<svg class="animate-spin h-5 w-5 mr-2 text-indigo-500" fill="none" viewBox="0 0 24 24">
<svg class="animate-spin h-5 w-5 mr-2 text-blue-600" fill="none" viewBox="0 0 24 24">
<circle
class="opacity-25"
cx="12"
@@ -568,45 +505,32 @@
/>
<span class="font-semibold text-gray-800 text-sm">{group.name}</span>
<span
class="text-xs bg-indigo-100 text-indigo-700 font-medium rounded-full px-2 py-0.5"
class="text-xs bg-gray-100 text-blue-700 font-medium rounded-full px-2 py-0.5 border border-gray-200"
>
{group.tickets.length}
</span>
{#if group.urgCount > 0}
<span
class="text-xs bg-red-100 text-red-700 font-semibold rounded-full px-2 py-0.5"
class="text-xs bg-gray-50 text-red-700 font-semibold rounded-full px-2 py-0.5 border border-red-200"
>
? {group.urgCount} urgente{group.urgCount > 1 ? 's' : ''}
{group.urgCount} urgente{group.urgCount > 1 ? 's' : ''}
</span>
{/if}
{#if group.highCount > 0}
<span
class="text-xs bg-orange-100 text-orange-700 font-medium rounded-full px-2 py-0.5"
class="text-xs bg-gray-50 text-orange-700 font-medium rounded-full px-2 py-0.5 border border-orange-200"
>
? {group.highCount} alta{group.highCount > 1 ? 's' : ''}
{group.highCount} alta{group.highCount > 1 ? 's' : ''}
</span>
{/if}
{#if group.closedCount > 0}
<span
class="text-xs bg-gray-100 text-gray-500 font-medium rounded-full px-2 py-0.5"
>
? {group.closedCount} cerrado{group.closedCount > 1 ? 's' : ''}
{group.closedCount} cerrado{group.closedCount > 1 ? 's' : ''}
</span>
{/if}
</div>
<svg
class="h-4 w-4 text-gray-400 transition-transform {isCollapsed ? '' : 'rotate-180'}"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M19 9l-7 7-7-7"
/>
</svg>
</button>
{#if !isCollapsed}
@@ -653,7 +577,7 @@
<tr
class="cursor-pointer transition-all {rowBorderClass(ticket)} {isClosed
? 'opacity-55 hover:opacity-80 bg-gray-50/50'
: 'hover:bg-indigo-50/60'}"
: 'hover:bg-blue-50/60'}"
on:click={() => goto(`/tickets/${ticket.id}`)}
>
<td
@@ -709,7 +633,7 @@
<td class="px-4 py-2.5 whitespace-nowrap text-right">
<button
on:click|stopPropagation={() => openEditModal(ticket)}
class="text-indigo-600 hover:text-indigo-900 font-medium mr-2"
class="text-blue-700 hover:text-blue-900 font-medium mr-2"
>Editar</button
>
<button
@@ -745,7 +669,7 @@
on:click={() => setPage(catId, p)}
class="px-2.5 py-1 rounded text-xs border font-medium transition-colors
{p === page
? 'bg-indigo-600 border-indigo-600 text-white'
? 'bg-blue-700 border-blue-700 text-white'
: 'border-gray-300 text-gray-600 hover:bg-gray-100'}">{p}</button
>
{/each}
@@ -776,7 +700,7 @@
type="text"
bind:value={formData.subject}
required
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm border p-2"
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 sm:text-sm border p-2"
placeholder="Breve descripción del problema"
/>
</div>
@@ -786,7 +710,7 @@
bind:value={formData.description}
required
rows="4"
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm border p-2"
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 sm:text-sm border p-2"
placeholder="Describe el problema en detalle..."
/>
</div>
@@ -830,7 +754,7 @@
<div class="sm:grid sm:grid-cols-2 sm:gap-3 mt-5">
<button
type="submit"
class="w-full justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-indigo-600 text-sm font-medium text-white hover:bg-indigo-700 sm:col-start-2"
class="w-full justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-700 text-sm font-medium text-white hover:bg-blue-800 sm:col-start-2"
>
Crear Ticket
</button>
@@ -896,7 +820,7 @@
<div class="sm:grid sm:grid-cols-2 sm:gap-3 mt-5">
<button
type="submit"
class="w-full justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-indigo-600 text-sm font-medium text-white hover:bg-indigo-700 sm:col-start-2"
class="w-full justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-700 text-sm font-medium text-white hover:bg-blue-800 sm:col-start-2"
>
Guardar Cambios
</button>
@@ -913,20 +837,7 @@
<Modal open={showDeleteModal} title="Eliminar Ticket" on:close={() => (showDeleteModal = false)}>
<div class="space-y-4">
<div class="bg-red-50 border border-red-200 rounded-md p-4 flex gap-3">
<svg
class="h-5 w-5 text-red-400 mt-0.5 flex-shrink-0"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
/>
</svg>
<div class="bg-red-50 border border-red-200 rounded-md p-4">
<div>
<h3 class="text-sm font-medium text-red-800">¿Eliminar este ticket?</h3>
<p class="text-sm text-red-700 mt-1">

View File

@@ -143,16 +143,14 @@
<div class="px-4 py-8 mx-auto max-w-7xl sm:px-6 lg:px-8">
{#if isLoading}
<div class="text-center py-12">
<div class="inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-indigo-600" />
<div class="inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-blue-700" />
<p class="mt-2 text-gray-600">Cargando ticket...</p>
</div>
{:else if ticket}
<!-- Breadcrumb -->
<div class="flex items-center space-x-2 text-sm text-gray-500 mb-6">
<a href="/tickets" class="hover:text-indigo-600">Tickets</a>
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
</svg>
<a href="/tickets" class="hover:text-blue-700">Tickets</a>
<span>/</span>
<span>#{ticket.ticket_number || ticket.id.substring(0, 8)}</span>
</div>
@@ -222,21 +220,9 @@
>
<div class="flex items-center space-x-3">
<div
class="w-10 h-10 bg-indigo-100 rounded-lg flex items-center justify-center flex-shrink-0"
class="w-10 h-10 bg-gray-100 rounded-lg flex items-center justify-center flex-shrink-0"
>
<svg
class="w-5 h-5 text-indigo-600"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"
/>
</svg>
<span class="text-xs font-bold text-blue-700">ADJ</span>
</div>
<div class="flex-1 min-w-0">
<p class="text-sm font-medium text-gray-900 truncate">
@@ -255,17 +241,10 @@
</div>
<button
on:click={() => handleDownloadAttachment(attachment)}
class="inline-flex items-center p-2 text-sm font-medium text-indigo-600 hover:bg-indigo-50 rounded-md transition-colors"
class="inline-flex items-center px-2 py-2 text-sm font-medium text-blue-700 hover:bg-blue-50 rounded-md transition-colors"
title="Descargar {attachment.original_filename}"
>
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 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>
Descargar
</button>
</div>
{/each}
@@ -289,15 +268,15 @@
{#each comments as comment}
<div class="flex space-x-3">
<div
class="w-8 h-8 bg-indigo-100 rounded-full flex items-center justify-center flex-shrink-0"
class="w-8 h-8 bg-gray-100 rounded-full flex items-center justify-center flex-shrink-0"
>
<span class="text-indigo-600 text-xs font-medium">
<span class="text-blue-700 text-xs font-medium">
{comment.author_name
? comment.author_name
.split(' ')
.map(n => n[0])
.join('')
: '??'}
: 'U'}
</span>
</div>
<div class="flex-1 min-w-0">
@@ -309,7 +288,7 @@
{formatDate(comment.created_at)}
</span>
{#if comment.is_internal}
<span class="bg-red-100 text-red-700 text-xs px-2 py-0.5 rounded">
<span class="bg-gray-50 text-red-700 text-xs px-2 py-0.5 rounded border border-red-200">
Interno
</span>
{/if}
@@ -328,7 +307,7 @@
<form on:submit|preventDefault={handleAddComment} class="space-y-4">
<textarea
rows="4"
class="block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm border p-2"
class="block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 sm:text-sm border p-2"
placeholder="Escribe tu comentario o respuesta..."
bind:value={newComment}
disabled={isSubmittingComment}
@@ -337,7 +316,7 @@
<div class="flex justify-end">
<button
type="submit"
class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:opacity-50"
class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-700 hover:bg-blue-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50"
disabled={isSubmittingComment || !newComment.trim()}
>
{#if isSubmittingComment}
@@ -398,7 +377,7 @@
<!-- SLA Information -->
{#if ticket.sla_response_due || ticket.sla_resolution_due}
<div class="pt-4 border-t border-gray-200">
<h4 class="text-sm font-semibold text-gray-900 mb-3">⏱️ SLA (Acuerdos de Nivel de Servicio)</h4>
<h4 class="text-sm font-semibold text-gray-900 mb-3">SLA (Acuerdos de Nivel de Servicio)</h4>
{#if ticket.sla_response_due}
<div class="mb-3">
@@ -406,16 +385,16 @@
<dd class="text-sm text-gray-900 mt-1">
{formatDate(ticket.sla_response_due)}
{#if new Date(ticket.sla_response_due) < new Date() && !ticket.sla_response_met}
<span class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-red-100 text-red-800">
⚠️ Vencido
<span class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-50 text-red-700 border border-red-200">
Vencido
</span>
{:else if ticket.sla_response_met}
<span class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800">
Cumplido
<span class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-50 text-green-700 border border-green-200">
Cumplido
</span>
{:else}
<span class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-800">
En plazo
<span class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-50 text-blue-700 border border-blue-200">
En plazo
</span>
{/if}
</dd>
@@ -428,16 +407,16 @@
<dd class="text-sm text-gray-900 mt-1">
{formatDate(ticket.sla_resolution_due)}
{#if new Date(ticket.sla_resolution_due) < new Date() && !ticket.sla_resolution_met}
<span class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-red-100 text-red-800">
⚠️ Vencido
<span class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-50 text-red-700 border border-red-200">
Vencido
</span>
{:else if ticket.sla_resolution_met}
<span class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800">
Cumplido
<span class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-50 text-green-700 border border-green-200">
Cumplido
</span>
{:else}
<span class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-800">
En plazo
<span class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-50 text-blue-700 border border-blue-200">
En plazo
</span>
{/if}
</dd>