feat(bitacoras): vista única ordenada por última actividad (efecto burbuja) y cambios pendientes de P270
Tests ADN / test (push) Canceled after 0s
Tests ADN / test (push) Canceled after 0s
Una sola tabla con todas las entradas del día ordenadas por updated_at, con el ámbito como etiqueta de cada fila (antes una sección por ámbito); /version incluye MAX(updated_at) para refrescar también cuando un evento recibe una viñeta (pedido del Operador 2026-10-13). Incluye los cambios de P270 que estaban en producción sin commitear: hijos de eventos, agrupado de repetidas y orden por updated_at en la API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: GEMMA <noreply@gemma.dtic>
This commit is contained in:
co-authored by
Claude Opus 5.5
GEMMA
parent
d106601946
commit
608d9fd79e
@@ -2,6 +2,7 @@
|
||||
import React, { useState, useEffect, useCallback } from 'react';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import rehypeRaw from 'rehype-raw';
|
||||
import ProyectoDashboard from './pages/ProyectoDashboard';
|
||||
import AmbitoDashboard from './pages/AmbitoDashboard';
|
||||
|
||||
@@ -20,6 +21,9 @@ interface Entrada {
|
||||
es_ia: boolean;
|
||||
nodo_nombre: string;
|
||||
nodo_ip: string;
|
||||
evento_padre_id?: number | null;
|
||||
hijos_count?: number;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
interface NodoGroup {
|
||||
@@ -97,6 +101,14 @@ function getInitialTab(): Tab {
|
||||
return 'bitacora';
|
||||
}
|
||||
|
||||
// ?ev=<id> — ver un solo evento sin ruido (pedido del Operador, P269).
|
||||
function getInitialEventoFiltro(): number | null {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const ev = params.get('ev');
|
||||
const n = ev ? parseInt(ev, 10) : NaN;
|
||||
return Number.isFinite(n) ? n : null;
|
||||
}
|
||||
|
||||
function App() {
|
||||
const [tab, setTab] = useState<Tab>(getInitialTab());
|
||||
|
||||
@@ -111,7 +123,20 @@ function App() {
|
||||
};
|
||||
window.history.replaceState(null, '', paths[t]);
|
||||
}, []);
|
||||
const [fecha, setFecha] = useState(new Date().toISOString().split('T')[0]);
|
||||
const [fecha, setFecha] = useState(() => { const d = new Date(); return `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,"0")}-${String(d.getDate()).padStart(2,"0")}`; });
|
||||
const [filtroEvento, setFiltroEvento] = useState<number | null>(getInitialEventoFiltro);
|
||||
const [eventoInput, setEventoInput] = useState<string>(() => { const ev = getInitialEventoFiltro(); return ev ? String(ev) : ''; });
|
||||
const aplicarFiltroEvento = React.useCallback(() => {
|
||||
const n = parseInt(eventoInput, 10);
|
||||
if (!Number.isFinite(n)) return;
|
||||
setFiltroEvento(n);
|
||||
window.history.replaceState(null, '', `/bitacoras/?ev=${n}`);
|
||||
}, [eventoInput]);
|
||||
const limpiarFiltroEvento = React.useCallback(() => {
|
||||
setFiltroEvento(null);
|
||||
setEventoInput('');
|
||||
window.history.replaceState(null, '', '/bitacoras/');
|
||||
}, []);
|
||||
const [bitacora, setBitacora] = useState<Bitacora | null>(null);
|
||||
const [nodos, setNodos] = useState<Nodo[]>([]);
|
||||
const [proyectos, setProyectos] = useState<{ id: number, codigo: string, nombre: string }[]>([]);
|
||||
@@ -139,6 +164,56 @@ function App() {
|
||||
const [editModo, setEditModo] = useState('');
|
||||
const [editEsIa, setEditEsIa] = useState(false);
|
||||
|
||||
// Edit mode toggle
|
||||
const [editMode, setEditMode] = useState(false);
|
||||
const [expandedParents, setExpandedParents] = useState<Set<number>>(new Set());
|
||||
const toggleParent = (id: number) => {
|
||||
setExpandedParents(prev => {
|
||||
const next = new Set(prev);
|
||||
next.has(id) ? next.delete(id) : next.add(id);
|
||||
return next;
|
||||
});
|
||||
};
|
||||
|
||||
// Agrupar heartbeats/entradas repetidas en una fila resumen colapsable
|
||||
// (P270/Fase1 Tarea 1, paso 2/2). Clave del grupo = id de la primera
|
||||
// entrada del grupo (la más reciente, dado el sort DESC de la tabla).
|
||||
const [expandedGrupos, setExpandedGrupos] = useState<Set<number>>(new Set());
|
||||
const toggleGrupo = (clave: number) => {
|
||||
setExpandedGrupos(prev => {
|
||||
const next = new Set(prev);
|
||||
next.has(clave) ? next.delete(clave) : next.add(clave);
|
||||
return next;
|
||||
});
|
||||
};
|
||||
// Transformación pura de datos (sin JSX): colapsa 3+ entradas consecutivas
|
||||
// (mismo prefijo de descripción + mismo nodo) en un único marcador de grupo.
|
||||
// No toca el array original ni el orden -- solo agrupa vecinos idénticos.
|
||||
const PREFIJO_LEN = 40;
|
||||
const agruparRepetidas = (entradas: any[]): any[] => {
|
||||
const salida: any[] = [];
|
||||
let i = 0;
|
||||
while (i < entradas.length) {
|
||||
const e = entradas[i];
|
||||
const prefijo = (e.descripcion || '').substring(0, PREFIJO_LEN);
|
||||
let j = i + 1;
|
||||
while (
|
||||
j < entradas.length &&
|
||||
(entradas[j].descripcion || '').substring(0, PREFIJO_LEN) === prefijo &&
|
||||
entradas[j].nodo_nombre === e.nodo_nombre
|
||||
) {
|
||||
j++;
|
||||
}
|
||||
if (j - i >= 3) {
|
||||
salida.push({ _grupo: true, clave: e.id, items: entradas.slice(i, j) });
|
||||
} else {
|
||||
for (let k = i; k < j; k++) salida.push(entradas[k]);
|
||||
}
|
||||
i = j;
|
||||
}
|
||||
return salida;
|
||||
};
|
||||
|
||||
// Confirm delete
|
||||
const [confirmDelete, setConfirmDelete] = useState<{ type: string; id: number; name: string } | null>(null);
|
||||
|
||||
@@ -183,6 +258,29 @@ function App() {
|
||||
|
||||
// === MARKDOWN COMPONENTS (MEMOIZED TO AVOID FLICKER) ===
|
||||
const markdownComponents = React.useMemo(() => ({
|
||||
// Tabla de latidos (P269, pedido del Operador) y cualquier otra tabla
|
||||
// markdown en una descripción — remark-gfm ya parsea el pipe-syntax,
|
||||
// esto solo le da estilo consistente con el resto de la UI.
|
||||
table: ({ node, ...props }: any) => (
|
||||
<table {...props} style={{ width: '100%', borderCollapse: 'collapse', margin: '0.4rem 0', fontSize: '0.85rem' }} />
|
||||
),
|
||||
th: ({ node, ...props }: any) => (
|
||||
<th {...props} style={{ background: 'rgba(102,126,234,0.15)', color: 'var(--primary)', padding: '0.35rem 0.6rem', textAlign: 'left', fontWeight: 600, borderBottom: '2px solid var(--border)' }} />
|
||||
),
|
||||
td: ({ node, ...props }: any) => (
|
||||
<td {...props} style={{ padding: '0.35rem 0.6rem', borderBottom: '1px solid var(--border)', verticalAlign: 'top' }} />
|
||||
),
|
||||
// Rail de timeline para las viñetas históricas (hallazgo #1 del
|
||||
// informe de diseño, P269): antes era texto corrido sin separación
|
||||
// visual entre hitos -- un borde izquierdo + espaciado consistente
|
||||
// ya ayuda a escanear sin necesitar reescribir el agrupamiento de
|
||||
// heartbeats repetidos (cambio más grande, deferido).
|
||||
ul: ({ node, ...props }: any) => (
|
||||
<ul {...props} style={{ listStyle: 'none', paddingLeft: '0.7rem', margin: '0.35rem 0' }} />
|
||||
),
|
||||
li: ({ node, ...props }: any) => (
|
||||
<li {...props} style={{ borderLeft: '2px solid var(--border)', paddingLeft: '0.6rem', marginBottom: '0.4rem', lineHeight: 1.5 }} />
|
||||
),
|
||||
a: ({ node, ...props }: any) => {
|
||||
const url = props.href || '';
|
||||
|
||||
@@ -277,19 +375,201 @@ function App() {
|
||||
}), []); // All deps (changeTab, setSelectedProyecto, openDocModal) are stable useCallbacks/setState
|
||||
|
||||
// === HELPERS ===
|
||||
// Líneas de latido (P269, pedido del Operador — modelo ev=18225): en vez
|
||||
// de texto libre "❤️ E3 [nombre] latido #46 — 24.5 min — <detalle>", se
|
||||
// muestran como fila de tabla ID | Estado | Resultado. Solo transforma
|
||||
// las líneas que matchean ese patrón exacto (emoji ❤️ + "latido #") —
|
||||
// el resto de la descripción (títulos, otras viñetas) queda intacto.
|
||||
const LATIDO_RE = /^(.+?)\s+latido\s+(#\d+\s*—\s*[\d.,]+\s*min)(?:\s*—\s*(.*))?$/;
|
||||
const parseLatidoLine = (linea: string) => {
|
||||
const idx = linea.indexOf('❤️');
|
||||
if (idx === -1) return null;
|
||||
const resto = linea.slice(idx + 2).trim();
|
||||
const m = resto.match(LATIDO_RE);
|
||||
if (!m) return null;
|
||||
const escapar = (s: string) => s.replace(/\|/g, '\\|');
|
||||
return { id: escapar(m[1].trim()), estado: escapar(`latido ${m[2].trim()}`), resultado: escapar((m[3] || '').trim()) };
|
||||
};
|
||||
const renderDescription = (text: string) => {
|
||||
if (!text) return '';
|
||||
|
||||
const lineas = text.split('\n');
|
||||
const filasLatido: { id: string; estado: string; resultado: string }[] = [];
|
||||
const otras: string[] = [];
|
||||
lineas.forEach(l => {
|
||||
const parsed = parseLatidoLine(l);
|
||||
if (parsed) filasLatido.push(parsed); else otras.push(l);
|
||||
});
|
||||
// Convierte saltos de línea simples en line breaks de Markdown (dos
|
||||
// espacios al final) -- SOLO en el texto libre, nunca dentro de la
|
||||
// tabla (el " \n" rompería la sintaxis de fila/separador de GFM).
|
||||
let normalized = otras.join('\n').replace(/\n/g, ' \n');
|
||||
if (filasLatido.length > 0) {
|
||||
const filas = filasLatido.map(f => `| ${f.id} | ${f.estado} | ${f.resultado} |`).join('\n');
|
||||
const tabla = `| ID | Estado | Resultado |\n|---|---|---|\n${filas}`;
|
||||
normalized = normalized.trim() ? `${normalized}\n\n${tabla}` : tabla;
|
||||
}
|
||||
return (
|
||||
<ReactMarkdown
|
||||
remarkPlugins={MARKDOWN_PLUGINS}
|
||||
<ReactMarkdown
|
||||
remarkPlugins={MARKDOWN_PLUGINS} rehypePlugins={[rehypeRaw]}
|
||||
components={markdownComponents as any}
|
||||
>
|
||||
{text}
|
||||
{normalized}
|
||||
</ReactMarkdown>
|
||||
);
|
||||
};
|
||||
|
||||
// Extraída de la tabla de entradas (P270/Fase1 Tarea 1, paso 1/2 -- ver
|
||||
// aprendizaje del plan): MISMO contenido que estaba inline en el .flatMap
|
||||
// de la tabla, sin cambios de comportamiento. entradasHermanas es el
|
||||
// array de entradas del mismo ámbito, para resolver los hijos expandidos.
|
||||
const renderFilaEntrada = (e: any, entradasHermanas: any[]): JSX.Element[] => {
|
||||
if (editId === e.id) {
|
||||
/* ==== FILA EN EDICIÓN ==== */
|
||||
return [
|
||||
<tr key={e.id} style={{ background: 'rgba(102, 126, 234, 0.1)' }}>
|
||||
<td style={{ color: 'var(--text-muted)', fontSize: '0.8rem' }}>{e.id}</td>
|
||||
<td>
|
||||
<div style={{ display: 'flex', gap: '0.3rem', alignItems: 'center' }}>
|
||||
<input type="time" value={editInicio?.substring(0,5)} onChange={ev => setEditInicio(ev.target.value)} className="edit-input" step="1" style={{ width: '75px' }} title="Inicio" />
|
||||
<span style={{ color: 'var(--text-muted)' }}>→</span>
|
||||
<input type="time" value={editFin?.substring(0,5)} onChange={ev => setEditFin(ev.target.value)} className="edit-input" step="1" style={{ width: '75px' }} title="Fin" />
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" value={editDesc} onChange={ev => setEditDesc(ev.target.value)} className="edit-input" style={{ width: '100%' }} />
|
||||
<label style={{ fontSize: '0.75rem', color: 'var(--text-secondary)', display: 'flex', alignItems: 'center', gap: '0.2rem', marginTop: '0.3rem' }}>
|
||||
<input type="checkbox" checked={editEsIa} onChange={ev => setEditEsIa(ev.target.checked)} /> IA
|
||||
</label>
|
||||
</td>
|
||||
<td style={{ textAlign: 'center', fontSize: '0.8rem', fontWeight: 600, color: 'var(--text-secondary)' }}>{e.nodo_nombre}</td>
|
||||
<td style={{ textAlign: 'center' }}>
|
||||
<select value={editModo} onChange={ev => setEditModo(ev.target.value)} className="edit-input" style={{ width: '45px', padding: '0.35rem 0.2rem' }}>
|
||||
<option value="P">P</option><option value="R">R</option><option value="S">S</option>
|
||||
</select>
|
||||
</td>
|
||||
<td style={{ textAlign: 'center' }}>
|
||||
<select value={editEstado} onChange={ev => setEditEstado(ev.target.value)} className="edit-input" style={{ width: '45px', padding: '0.35rem 0.2rem' }}>
|
||||
<option value="⏳">⏳</option><option value="✅">✅</option>
|
||||
<option value="⚠️">⚠️</option><option value="❌">❌</option><option value="👁️">👁️</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<div style={{ display: 'flex', gap: '0.2rem' }}>
|
||||
<button className="btn btn-sm btn-success" onClick={saveEdit} title="Guardar"><i className="fas fa-check"></i></button>
|
||||
<button className="btn btn-sm" onClick={cancelEdit} title="Cancelar" style={{ background: 'var(--bg-card)', color: 'var(--text-muted)' }}><i className="fas fa-times"></i></button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
];
|
||||
}
|
||||
return [
|
||||
<tr key={e.id}>
|
||||
<td style={{ color: 'var(--text-muted)', fontSize: '0.8rem' }}>
|
||||
{parseInt(String(e.hijos_count || '0')) > 0 ? (
|
||||
<span style={{ cursor: 'pointer', userSelect: 'none' }} onClick={() => toggleParent(e.id)}>
|
||||
{expandedParents.has(e.id) ? '▾' : '▸'} {e.id} <span style={{ fontSize: '0.65rem', color: 'var(--primary)' }}>({e.hijos_count})</span>
|
||||
</span>
|
||||
) : e.id}
|
||||
</td>
|
||||
<td className="col-time">
|
||||
<span style={{ fontSize: '0.75rem', fontWeight: 700, color: 'var(--text-muted)', marginRight: '2px' }}>{e.modo}</span>
|
||||
<span style={{ marginRight: '3px' }}>{e.estado}</span>
|
||||
{(() => {
|
||||
const inicio = e.inicio?.substring(0, 8) || '';
|
||||
const fin = e.fin ? e.fin.substring(0, 8) : null;
|
||||
|
||||
// Calcular duración si hay fin
|
||||
let duracion = '';
|
||||
if (inicio && fin) {
|
||||
try {
|
||||
const inicioT = new Date(`2000-01-01T${inicio}`);
|
||||
const finT = new Date(`2000-01-01T${fin}`);
|
||||
const secs = (finT.getTime() - inicioT.getTime()) / 1000;
|
||||
if (secs >= 0) {
|
||||
if (secs < 1) {
|
||||
duracion = `(${Math.round(secs * 1000)}ms)`;
|
||||
} else if (secs < 60) {
|
||||
duracion = `(${secs.toFixed(1)}s)`;
|
||||
} else {
|
||||
const mins = Math.floor(secs / 60);
|
||||
const remainingSecs = (secs % 60).toFixed(1);
|
||||
duracion = `(${mins}min ${remainingSecs}s)`;
|
||||
}
|
||||
}
|
||||
} catch (err) { /* ignore */ }
|
||||
}
|
||||
|
||||
if (fin) {
|
||||
return (
|
||||
<span style={{ fontSize: '0.85rem' }}>
|
||||
<span style={{ color: 'var(--text-secondary)' }}>I:</span> {inicio.substring(0, 5)} → <span style={{ color: 'var(--text-secondary)' }}>F:</span> {fin.substring(0, 5)} <span style={{ color: 'var(--primary)', fontWeight: 600 }}>{duracion}</span>
|
||||
</span>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<span style={{ fontSize: '0.85rem' }}>
|
||||
<span style={{ color: 'var(--text-secondary)' }}>I:</span> {inicio.substring(0, 5)} <span style={{ color: 'var(--warning)' }}>⏳ en proceso</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
})()}
|
||||
</td>
|
||||
<td className="col-desc">
|
||||
{e.es_ia && <span className="ia-tag">IA</span>}
|
||||
{e.doc_path && e.doc_path !== '{}' && e.doc_path.includes('/') && (() => {
|
||||
const parts = e.doc_path.split('/');
|
||||
const archivo = parts.pop() || '';
|
||||
const proyecto = parts.pop() || '';
|
||||
const label = archivo.replace('.md', '').replace(/_/g, ' ').split(' ')[0];
|
||||
return (
|
||||
<button
|
||||
className="plan-link-btn"
|
||||
onClick={(ev) => { ev.stopPropagation(); openDocModal(proyecto, archivo); }}
|
||||
title={`Ver ${archivo}`}
|
||||
>
|
||||
<i className="fas fa-file-alt"></i> {label}
|
||||
</button>
|
||||
);
|
||||
})()}
|
||||
{renderDescription(e.descripcion)}
|
||||
</td>
|
||||
<td style={{ textAlign: 'center', fontSize: '0.8rem', fontWeight: 600, color: 'var(--primary)', background: 'rgba(102, 126, 234, 0.05)' }}>
|
||||
{e.nodo_nombre}
|
||||
{e.ambito_nombre && <div style={{ fontSize: '0.65rem', fontWeight: 400, color: 'var(--text-muted)', marginTop: '0.15rem' }}>{e.ambito_nombre}</div>}
|
||||
</td>
|
||||
|
||||
{editMode && (<td>
|
||||
<div style={{ display: 'flex', gap: '0.2rem' }}>
|
||||
<button className="btn btn-sm" onClick={() => startEdit(e)} title="Editar"
|
||||
style={{ background: 'var(--info)', color: 'white' }}>
|
||||
<i className="fas fa-pen"></i>
|
||||
</button>
|
||||
<button className="btn btn-sm btn-danger" onClick={() => requestDeleteEntrada(e.id, e.descripcion)} title="Eliminar">
|
||||
<i className="fas fa-trash-alt"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>)}
|
||||
</tr>,
|
||||
// === HIJOS EXPANDIDOS ===
|
||||
...(expandedParents.has(e.id) ? entradasHermanas
|
||||
.filter(h => h.evento_padre_id === e.id)
|
||||
.sort((a, b) => a.inicio.localeCompare(b.inicio))
|
||||
.map(h => (
|
||||
<tr key={`child-${h.id}`} style={{ background: 'rgba(102,126,234,0.04)' }}>
|
||||
<td style={{ paddingLeft: '1.5rem', color: 'var(--text-muted)', fontSize: '0.75rem' }}>└ {h.id}</td>
|
||||
<td className="col-time" style={{ fontSize: '0.8rem' }}>
|
||||
<span style={{ fontSize: '0.7rem', fontWeight: 700, color: 'var(--text-muted)', marginRight: '2px' }}>{h.modo}</span>
|
||||
<span style={{ marginRight: '3px' }}>{h.estado}</span>
|
||||
{h.inicio?.substring(0,5)}{h.fin ? ` → ${h.fin.substring(0,5)}` : ''}
|
||||
</td>
|
||||
<td className="col-desc" style={{ fontSize: '0.85rem', opacity: 0.85 }}>{h.descripcion?.substring(0,80)}{(h.descripcion||'').length > 80 ? '...' : ''}</td>
|
||||
<td style={{ textAlign: 'center', fontSize: '0.75rem', color: 'var(--text-muted)' }}>{h.nodo_nombre}</td>
|
||||
{editMode && (<td></td>)}
|
||||
</tr>
|
||||
)) : [])
|
||||
];
|
||||
};
|
||||
|
||||
// === FETCH ===
|
||||
const fetchBitacora = useCallback(async () => {
|
||||
// Solo mostramos loading si es la primera carga (sin datos)
|
||||
@@ -397,7 +677,8 @@ function App() {
|
||||
};
|
||||
|
||||
// Auto-refresh inteligente: solo actualizar si hay cambios
|
||||
const [lastVersion, setLastVersion] = useState<{ max_id: number; count: number } | null>(null);
|
||||
// 'ultima' = MAX(updated_at): una viñeta nueva en un evento existente también refresca (efecto burbuja, 2026-10-13)
|
||||
const [lastVersion, setLastVersion] = useState<{ max_id: number; count: number; ultima?: string } | null>(null);
|
||||
|
||||
const fetchBitacoraVersion = useCallback(async () => {
|
||||
try {
|
||||
@@ -416,7 +697,7 @@ function App() {
|
||||
fetchGlobalStats();
|
||||
return;
|
||||
}
|
||||
if (!lastVersion || newVersion.max_id !== lastVersion.max_id || Number(newVersion.count) !== Number(lastVersion.count)) {
|
||||
if (!lastVersion || newVersion.max_id !== lastVersion.max_id || Number(newVersion.count) !== Number(lastVersion.count) || newVersion.ultima !== lastVersion.ultima) {
|
||||
setLastVersion(newVersion);
|
||||
fetchBitacora();
|
||||
fetchFechasActivas();
|
||||
@@ -464,7 +745,7 @@ function App() {
|
||||
const daysInMonth = new Date(year, month + 1, 0).getDate();
|
||||
const rows: { day: number; dateStr: string; active: boolean; selected: boolean; today: boolean }[][] = [];
|
||||
let row: typeof rows[0] = [];
|
||||
const todayStr = new Date().toISOString().split('T')[0];
|
||||
const todayStr = (() => { const d = new Date(); return `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,"0")}-${String(d.getDate()).padStart(2,"0")}`; })();
|
||||
// Fill blanks
|
||||
for (let i = 0; i < firstDay; i++) row.push({ day: 0, dateStr: '', active: false, selected: false, today: false });
|
||||
for (let d = 1; d <= daysInMonth; d++) {
|
||||
@@ -665,7 +946,7 @@ function App() {
|
||||
<div style={{ textAlign: 'center', padding: '2rem', color: 'var(--text-muted)' }}><i className="fas fa-spinner fa-spin fa-2x"></i></div>
|
||||
) : (
|
||||
<div className="doc-viewer-content">
|
||||
<ReactMarkdown remarkPlugins={MARKDOWN_PLUGINS} components={markdownComponents as any}>
|
||||
<ReactMarkdown remarkPlugins={MARKDOWN_PLUGINS} rehypePlugins={[rehypeRaw]} components={markdownComponents as any}>
|
||||
{docModal.content}
|
||||
</ReactMarkdown>
|
||||
</div>
|
||||
@@ -718,7 +999,7 @@ function App() {
|
||||
{/* Global Stats Row */}
|
||||
{/* Global Stats Row */}
|
||||
{globalStats.length > 0 && (
|
||||
<div style={{ display: 'flex', gap: '1rem', overflowX: 'auto', paddingBottom: '1rem', marginBottom: '1rem', borderBottom: '1px solid var(--border)' }}>
|
||||
<div className="ambitos-scroll" style={{ display: 'flex', gap: '1rem', overflowX: 'auto', paddingBottom: '1rem', marginBottom: '1rem', borderBottom: '1px solid var(--border)' }}>
|
||||
{globalStats.map((s, i) => (
|
||||
<div key={i} className="card" style={{ padding: '0.6rem 1rem', minWidth: '150px', flexShrink: 0 }}>
|
||||
<div style={{ fontSize: '0.7rem', color: 'var(--text-muted)', textTransform: 'uppercase', fontWeight: 600 }}>{s.nombre}</div>
|
||||
@@ -742,11 +1023,28 @@ function App() {
|
||||
<button className="btn btn-sm btn-primary" onClick={() => {
|
||||
const d = new Date(fecha + 'T12:00:00'); d.setDate(d.getDate() + 1); setFecha(d.toISOString().split('T')[0]);
|
||||
}}><i className="fas fa-chevron-right"></i></button>
|
||||
<button className="btn btn-sm" onClick={() => setFecha(new Date().toISOString().split('T')[0])}
|
||||
<button className="btn btn-sm" onClick={() => setFecha((() => { const d = new Date(); return `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,"0")}-${String(d.getDate()).padStart(2,"0")}`; })())}
|
||||
style={{ background: 'var(--bg-card)', color: 'var(--text-secondary)', border: '1px solid var(--border)' }}>
|
||||
<i className="fas fa-calendar-day"></i> Hoy
|
||||
</button>
|
||||
</div>
|
||||
{/* Grupo separado (hallazgo #9 del informe de diseño, P269): navegar
|
||||
por fecha y filtrar por evento puntual son dos ejes distintos --
|
||||
antes vivían pegados en la misma fila sin separación. */}
|
||||
<div className="date-selector" style={{ marginLeft: '0.75rem', paddingLeft: '0.75rem', borderLeft: '1px solid var(--border)' }}>
|
||||
<span style={{ fontSize: '0.75rem', color: 'var(--text-secondary)', fontWeight: 600, textTransform: 'uppercase', letterSpacing: '0.03em' }}>Evento:</span>
|
||||
<input
|
||||
type="number"
|
||||
placeholder="# id"
|
||||
value={eventoInput}
|
||||
onChange={e => setEventoInput(e.target.value)}
|
||||
onKeyDown={e => { if (e.key === 'Enter') aplicarFiltroEvento(); }}
|
||||
style={{ width: 90, background: 'var(--bg-card)', color: 'var(--text)', border: '1px solid var(--border)', borderRadius: 6, padding: '0.3rem 0.6rem' }}
|
||||
/>
|
||||
<button className="btn btn-sm btn-primary" onClick={aplicarFiltroEvento} title="Ver solo este evento">
|
||||
<i className="fas fa-search"></i> Ver
|
||||
</button>
|
||||
</div>
|
||||
{showCal && (
|
||||
<div className="mini-cal">
|
||||
<div className="mini-cal-header">
|
||||
@@ -799,8 +1097,17 @@ function App() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Edit Mode Toggle */}
|
||||
<div style={{ display: 'flex', justifyContent: 'flex-end', marginBottom: '0.5rem' }}>
|
||||
<button className={`btn btn-sm ${editMode ? 'btn-primary' : ''}`} onClick={() => setEditMode(v => !v)}
|
||||
style={!editMode ? { background: 'var(--bg-card)', color: 'var(--text-muted)', border: '1px solid var(--border)' } : {}}
|
||||
title={editMode ? 'Desactivar modo edición' : 'Activar modo edición'}>
|
||||
<i className={`fas fa-${editMode ? 'lock-open' : 'lock'}`}></i> {editMode ? 'Edición' : 'Solo lectura'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* =================== CONTROL DE GESTIÓN =================== */}
|
||||
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '1.5rem', marginBottom: '2rem' }}>
|
||||
{editMode && (<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '1.5rem', marginBottom: '2rem' }}>
|
||||
<div className="card">
|
||||
<div className="card-header" style={{ borderBottom: '1px solid var(--border)', display: 'flex', justifyContent: 'space-between' }}>
|
||||
<span><i className="fas fa-list-ul" style={{ color: '#fbbf24' }}></i> Pendientes</span>
|
||||
@@ -849,10 +1156,10 @@ function App() {
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>)}
|
||||
|
||||
{/* New Entry Form */}
|
||||
<div className="card" style={{ marginBottom: '2rem' }}>
|
||||
{editMode && (<div className="card" style={{ marginBottom: '2rem' }}>
|
||||
<div className="card-header"><i className="fas fa-plus-circle"></i> Nueva Entrada</div>
|
||||
<form className="form-inline" onSubmit={handleSubmit}>
|
||||
<input type="time" className="input-time" value={newInicio} onChange={e => setNewInicio(e.target.value)} placeholder="I" required step="1" />
|
||||
@@ -874,25 +1181,42 @@ function App() {
|
||||
</label>
|
||||
<button type="submit" className="btn btn-primary"><i className="fas fa-save"></i> Guardar</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>)}
|
||||
|
||||
{/* Filtro por evento único (?ev=<id>) — sin ruido */}
|
||||
{filtroEvento && (
|
||||
<div className="card" style={{ marginBottom: '1rem', padding: '0.6rem 1rem', display: 'flex', alignItems: 'center', gap: '0.6rem', background: 'var(--primary-soft, rgba(99,102,241,0.12))' }}>
|
||||
<i className="fas fa-filter" style={{ color: 'var(--primary)' }}></i>
|
||||
<span>Viendo solo el evento <strong>#{filtroEvento}</strong></span>
|
||||
<a
|
||||
href="#"
|
||||
style={{ marginLeft: 'auto' }}
|
||||
onClick={(ev) => { ev.preventDefault(); limpiarFiltroEvento(); }}
|
||||
>
|
||||
Ver todo <i className="fas fa-times"></i>
|
||||
</a>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Loading */}
|
||||
{loading && <div style={{ textAlign: 'center', padding: '2rem', color: 'var(--text-muted)' }}><i className="fas fa-spinner fa-spin fa-2x"></i></div>}
|
||||
|
||||
{/* Agrupar entradas por ÁMBITO en lugar de por nodo */}
|
||||
{/* Una sola lista ordenada por última actividad (efecto burbuja, Operador 2026-10-13): sin secciones por
|
||||
ámbito, el evento con actividad más reciente arriba; el ámbito va como etiqueta de cada fila. */}
|
||||
{(() => {
|
||||
// Agrupar por ámbito a nivel de cada entrada
|
||||
const porAmbito: Record<string, any> = {};
|
||||
bitacora?.nodos?.forEach(nodoGroup => {
|
||||
if (nodoGroup.resumen) {
|
||||
// Si el nodo tiene resumen genérico, lo guardamos en su primer ámbito disponible o "Global"
|
||||
const defaultAmbito = nodoGroup.entradas.length > 0 ? (nodoGroup.entradas[0].ambito_nombre || nodoGroup.ambito_nombre || 'Sin Ámbito') : 'Sin Ámbito';
|
||||
const defaultAmbito = 'Actividad del día';
|
||||
if (!porAmbito[defaultAmbito]) porAmbito[defaultAmbito] = { ambito: defaultAmbito, nodos: new Set(), entradas: [], resumenes: [] };
|
||||
porAmbito[defaultAmbito].resumenes.push({ nodo: nodoGroup.nodo, resumen: nodoGroup.resumen });
|
||||
}
|
||||
|
||||
nodoGroup.entradas.forEach(e => {
|
||||
const ambito = e.ambito_nombre || nodoGroup.ambito_nombre || 'Sin Ámbito';
|
||||
if (filtroEvento && e.id !== filtroEvento) return;
|
||||
const ambito = 'Actividad del día'; // grupo único (antes: uno por ámbito)
|
||||
if (!porAmbito[ambito]) {
|
||||
porAmbito[ambito] = {
|
||||
ambito: ambito,
|
||||
@@ -929,94 +1253,44 @@ function App() {
|
||||
))}
|
||||
|
||||
<div className="table-responsive">
|
||||
<table className="table-ifde">
|
||||
<table className="table-ifde tabla-entradas">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style={{ width: '40px', color: 'var(--text-muted)', fontSize: '0.85rem' }}>ID</th>
|
||||
<th className="col-time">I</th>
|
||||
<th className="col-time">F</th>
|
||||
<th className="col-time">DATA</th>
|
||||
<th className="col-desc">Descripción</th>
|
||||
<th style={{ width: '90px', textAlign: 'center' }}>Nodo</th>
|
||||
<th className="col-j-header" style={{ width: '35px', textAlign: 'center' }}>J</th>
|
||||
<th className="col-status">E</th>
|
||||
<th style={{ width: '80px' }}>Acc.</th>
|
||||
{editMode && <th style={{ width: '80px' }}>Acc.</th>}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{ambitoGroup.entradas.sort((a, b) => b.inicio.localeCompare(a.inicio)).map(e => (
|
||||
editId === e.id ? (
|
||||
/* ==== FILA EN EDICIÓN ==== */
|
||||
<tr key={e.id} style={{ background: 'rgba(102, 126, 234, 0.1)' }}>
|
||||
<td style={{ color: 'var(--text-muted)', fontSize: '0.8rem' }}>{e.id}</td>
|
||||
<td><input type="time" value={editInicio?.substring(0,5)} onChange={ev => setEditInicio(ev.target.value)} className="edit-input" step="1" /></td>
|
||||
<td><input type="time" value={editFin?.substring(0,5)} onChange={ev => setEditFin(ev.target.value)} className="edit-input" step="1" /></td>
|
||||
<td>
|
||||
<input type="text" value={editDesc} onChange={ev => setEditDesc(ev.target.value)} className="edit-input" style={{ width: '100%' }} />
|
||||
<label style={{ fontSize: '0.75rem', color: 'var(--text-secondary)', display: 'flex', alignItems: 'center', gap: '0.2rem', marginTop: '0.3rem' }}>
|
||||
<input type="checkbox" checked={editEsIa} onChange={ev => setEditEsIa(ev.target.checked)} /> IA
|
||||
</label>
|
||||
</td>
|
||||
<td style={{ textAlign: 'center', fontSize: '0.8rem', fontWeight: 600, color: 'var(--text-secondary)' }}>{e.nodo_nombre}</td>
|
||||
<td style={{ textAlign: 'center' }}>
|
||||
<select value={editModo} onChange={ev => setEditModo(ev.target.value)} className="edit-input" style={{ width: '45px', padding: '0.35rem 0.2rem' }}>
|
||||
<option value="P">P</option><option value="R">R</option><option value="S">S</option>
|
||||
</select>
|
||||
</td>
|
||||
<td style={{ textAlign: 'center' }}>
|
||||
<select value={editEstado} onChange={ev => setEditEstado(ev.target.value)} className="edit-input" style={{ width: '45px', padding: '0.35rem 0.2rem' }}>
|
||||
<option value="⏳">⏳</option><option value="✅">✅</option>
|
||||
<option value="⚠️">⚠️</option><option value="❌">❌</option><option value="👁️">👁️</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<div style={{ display: 'flex', gap: '0.2rem' }}>
|
||||
<button className="btn btn-sm btn-success" onClick={saveEdit} title="Guardar"><i className="fas fa-check"></i></button>
|
||||
<button className="btn btn-sm" onClick={cancelEdit} title="Cancelar" style={{ background: 'var(--bg-card)', color: 'var(--text-muted)' }}><i className="fas fa-times"></i></button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
) : (
|
||||
/* ==== FILA NORMAL ==== */
|
||||
<tr key={e.id}>
|
||||
<td style={{ color: 'var(--text-muted)', fontSize: '0.8rem' }}>{e.id}</td>
|
||||
<td className="col-time">{e.inicio?.substring(0, 5)}</td>
|
||||
<td className="col-time">{e.fin ? e.fin.substring(0, 5) : '—'}</td>
|
||||
<td className="col-desc">
|
||||
{e.es_ia && <span className="ia-tag">IA</span>}
|
||||
{e.doc_path && (() => {
|
||||
const parts = e.doc_path.split('/');
|
||||
const archivo = parts.pop() || '';
|
||||
const proyecto = parts.pop() || '';
|
||||
const label = archivo.replace('.md', '').replace(/_/g, ' ').split(' ')[0];
|
||||
return (
|
||||
<button
|
||||
className="plan-link-btn"
|
||||
onClick={(ev) => { ev.stopPropagation(); openDocModal(proyecto, archivo); }}
|
||||
title={`Ver ${archivo}`}
|
||||
>
|
||||
<i className="fas fa-file-alt"></i> {label}
|
||||
</button>
|
||||
);
|
||||
})()}
|
||||
{renderDescription(e.descripcion)}
|
||||
</td>
|
||||
<td style={{ textAlign: 'center', fontSize: '0.8rem', fontWeight: 600, color: 'var(--primary)', background: 'rgba(102, 126, 234, 0.05)' }}>{e.nodo_nombre}</td>
|
||||
<td style={{ textAlign: 'center', fontWeight: 600, color: 'var(--text-secondary)' }}>{e.modo}</td>
|
||||
<td className="col-status">{e.estado}</td>
|
||||
<td>
|
||||
<div style={{ display: 'flex', gap: '0.2rem' }}>
|
||||
<button className="btn btn-sm" onClick={() => startEdit(e)} title="Editar"
|
||||
style={{ background: 'var(--info)', color: 'white' }}>
|
||||
<i className="fas fa-pen"></i>
|
||||
</button>
|
||||
<button className="btn btn-sm btn-danger" onClick={() => requestDeleteEntrada(e.id, e.descripcion)} title="Eliminar">
|
||||
<i className="fas fa-trash-alt"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
))}
|
||||
{agruparRepetidas(ambitoGroup.entradas
|
||||
.filter(e => !e.evento_padre_id)
|
||||
.sort((a, b) => String(b.updated_at || b.inicio).localeCompare(String(a.updated_at || a.inicio))))
|
||||
.flatMap(item => {
|
||||
if (!item._grupo) return renderFilaEntrada(item, ambitoGroup.entradas);
|
||||
if (expandedGrupos.has(item.clave)) {
|
||||
return [
|
||||
<tr key={`grupo-${item.clave}-contraer`} style={{ background: 'rgba(102, 126, 234, 0.04)', cursor: 'pointer' }} onClick={() => toggleGrupo(item.clave)}>
|
||||
<td colSpan={editMode ? 5 : 4} style={{ color: 'var(--text-muted)', fontSize: '0.8rem' }}>
|
||||
<span style={{ color: 'var(--primary)' }}>▾</span> contraer {item.items.length} entradas repetidas
|
||||
</td>
|
||||
</tr>,
|
||||
...item.items.flatMap((e: any) => renderFilaEntrada(e, ambitoGroup.entradas))
|
||||
];
|
||||
}
|
||||
/* ==== FILA RESUMEN DE GRUPO (heartbeats/repetidas colapsadas) ==== */
|
||||
const primera = item.items[0];
|
||||
return [
|
||||
<tr key={`grupo-${item.clave}`} style={{ background: 'rgba(102, 126, 234, 0.04)', cursor: 'pointer' }} onClick={() => toggleGrupo(item.clave)}>
|
||||
<td colSpan={3} style={{ color: 'var(--text-muted)', fontSize: '0.85rem' }}>
|
||||
<span style={{ color: 'var(--primary)' }}>▸</span> 🔁 {primera.descripcion?.substring(0, PREFIJO_LEN)}… — {item.items.length} veces — última: {primera.inicio?.substring(0, 5)} — <span style={{ color: 'var(--primary)', textDecoration: 'underline' }}>ver historial</span>
|
||||
</td>
|
||||
<td style={{ textAlign: 'center', fontSize: '0.8rem', color: 'var(--primary)' }}>{primera.nodo_nombre}</td>
|
||||
{editMode && <td></td>}
|
||||
</tr>
|
||||
];
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -168,8 +168,8 @@ body {
|
||||
}
|
||||
|
||||
.table-ifde .col-time {
|
||||
width: 60px;
|
||||
font-size: 0.8rem;
|
||||
width: 180px;
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
@@ -538,6 +538,83 @@ body {
|
||||
}
|
||||
}
|
||||
|
||||
/* Barra de ámbitos (Global Stats Row) -- fade en el borde derecho como
|
||||
affordance de scroll horizontal (P270/Fase1 Tarea 4). Solo CSS, un
|
||||
className agregado al contenedor ya existente -- sin JS/estado nuevo. */
|
||||
.ambitos-scroll {
|
||||
-webkit-mask-image: linear-gradient(to right, black calc(100% - 32px), transparent 100%);
|
||||
mask-image: linear-gradient(to right, black calc(100% - 32px), transparent 100%);
|
||||
}
|
||||
|
||||
/* Tabla de entradas -> tarjetas apiladas en pantallas angostas (P270/Fase1
|
||||
Tarea 2/3). Solo CSS: reordena las mismas 4-5 columnas (ID/DATA/DESCRIPCION/
|
||||
NODO/[Acc.]) por posición via flex+order, sin tocar el JSX del render de
|
||||
filas -- ver aprendizaje P270/Fase1 sobre el riesgo de editar ese bloque.
|
||||
Selectores con hijo directo (>) SIEMPRE -- la columna DESCRIPCIÓN renderiza
|
||||
markdown con tablas propias anidadas (latidos); un selector descendiente
|
||||
(.tabla-entradas td) las alcanza también y rompe su layout interno. */
|
||||
@media (max-width: 600px) {
|
||||
.tabla-entradas > thead {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tabla-entradas,
|
||||
.tabla-entradas > tbody {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tabla-entradas > tbody > tr {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
gap: 0.3rem 0.6rem;
|
||||
padding: 0.6rem 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.tabla-entradas > tbody > tr > td {
|
||||
display: inline-flex;
|
||||
padding: 0 !important;
|
||||
border-bottom: none !important;
|
||||
width: auto !important;
|
||||
}
|
||||
|
||||
/* ID */
|
||||
.tabla-entradas > tbody > tr > td:nth-child(1) {
|
||||
order: 1;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
/* DATA (modo+estado+hora) */
|
||||
.tabla-entradas > tbody > tr > td:nth-child(2) {
|
||||
order: 2;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
/* NODO -- ancla a la derecha de la línea compacta, como tag */
|
||||
.tabla-entradas > tbody > tr > td:nth-child(4) {
|
||||
order: 3;
|
||||
margin-left: auto;
|
||||
font-size: 0.7rem;
|
||||
}
|
||||
|
||||
/* DESCRIPCIÓN -- línea propia a ancho completo, debajo */
|
||||
.tabla-entradas > tbody > tr > td:nth-child(3) {
|
||||
order: 4;
|
||||
flex: 1 1 100%;
|
||||
padding-top: 0.3rem !important;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Acc. (solo modo edición) -- línea propia al final */
|
||||
.tabla-entradas > tbody > tr > td:nth-child(5) {
|
||||
order: 5;
|
||||
flex: 1 1 100%;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
/* Modal de confirmación */
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
|
||||
Reference in New Issue
Block a user