[P2606] WebServer NGINX: plan actualizado, ficha nodo, HTTPS operativo
- P2606: Plan v1.1 EN EJECUCIÓN. Fases 1-3 completadas. - Ficha nodo srvv-nginx-rm.md. P2606 en adn/07_proyectos.md. - Incluye cambios acumulados de sesiones anteriores.
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
/// <reference types="vite/client" />
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
|
||||
const API_URL = import.meta.env.VITE_API_URL || '/bitacoras/api';
|
||||
|
||||
interface Nodo {
|
||||
id: number;
|
||||
nombre: string;
|
||||
ip: string;
|
||||
tipo: string;
|
||||
descripcion: string;
|
||||
}
|
||||
|
||||
interface Entrada {
|
||||
id: number;
|
||||
inicio: string;
|
||||
fin: string | null;
|
||||
descripcion: string;
|
||||
estado: string;
|
||||
modo: string;
|
||||
nodo_nombre: string;
|
||||
}
|
||||
|
||||
interface Gestion {
|
||||
id: number;
|
||||
tipo: string;
|
||||
detalle: string;
|
||||
estado: string;
|
||||
nodo_nombre: string;
|
||||
}
|
||||
|
||||
interface AmbitoInfo {
|
||||
id: number;
|
||||
nombre: string;
|
||||
descripcion: string;
|
||||
}
|
||||
|
||||
interface DashboardData {
|
||||
ambito: AmbitoInfo;
|
||||
nodos: Nodo[];
|
||||
entradas: Entrada[];
|
||||
gestion: Gestion[];
|
||||
}
|
||||
|
||||
export default function AmbitoDashboard({ id, onBack }: { id: number; onBack: () => void }) {
|
||||
const [data, setData] = useState<DashboardData | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchDashboard = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await fetch(`${API_URL}/ambitos/${id}/dashboard`);
|
||||
const json = await res.json();
|
||||
setData(json);
|
||||
} catch (err) {
|
||||
console.error('Error dashboard:', err);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
fetchDashboard();
|
||||
}, [id]);
|
||||
|
||||
if (loading) return <div className="loading-state">Cargando dashboard de ámbito...</div>;
|
||||
if (!data) return <div className="error-state">No se pudo cargar la información del ámbito.</div>;
|
||||
|
||||
const { ambito, nodos, entradas, gestion } = data;
|
||||
|
||||
return (
|
||||
<div className="ambito-dashboard fade-in">
|
||||
<div className="dashboard-header" style={{ marginBottom: '2rem', display: 'flex', alignItems: 'center', gap: '1rem' }}>
|
||||
<button className="btn btn-sm" onClick={onBack} style={{ background: 'var(--bg-card)', color: 'var(--text)' }}>
|
||||
<i className="fas fa-arrow-left"></i> Volver
|
||||
</button>
|
||||
<div>
|
||||
<h2 style={{ margin: 0, fontSize: '1.6rem', fontWeight: 700 }}>{ambito.nombre}</h2>
|
||||
<p style={{ margin: 0, color: 'var(--text-muted)', fontSize: '0.9rem' }}>{ambito.descripcion || 'Sin descripción'}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="dashboard-grid" style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '1.5rem' }}>
|
||||
{/* Columna Izquierda: Nodos y Gestión */}
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '1.5rem' }}>
|
||||
<div className="card">
|
||||
<div className="card-header"><i className="fas fa-server"></i> Nodos del Ámbito ({nodos.length})</div>
|
||||
<div style={{ padding: '1rem' }}>
|
||||
{nodos.length === 0 ? (
|
||||
<p style={{ color: 'var(--text-muted)', fontSize: '0.85rem' }}>No hay nodos asignados a este ámbito.</p>
|
||||
) : (
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '0.5rem' }}>
|
||||
{nodos.map(n => (
|
||||
<div key={n.id} className="badge" style={{ padding: '0.5rem 0.8rem', background: 'var(--bg-tag)', border: '1px solid var(--border)' }}>
|
||||
<div style={{ fontWeight: 600 }}>{n.nombre}</div>
|
||||
<div style={{ fontSize: '0.7rem', color: 'var(--text-muted)' }}>{n.ip || 'Sin IP'}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="card">
|
||||
<div className="card-header"><i className="fas fa-clipboard-list"></i> Gestión Pendiente ({gestion.length})</div>
|
||||
<div style={{ padding: '0' }}>
|
||||
{gestion.length === 0 ? (
|
||||
<p style={{ padding: '1rem', color: 'var(--text-muted)', fontSize: '0.85rem' }}>No hay tareas pendientes en este ámbito.</p>
|
||||
) : (
|
||||
<table className="table-ifde" style={{ fontSize: '0.85rem' }}>
|
||||
<tbody>
|
||||
{gestion.map(g => (
|
||||
<tr key={g.id}>
|
||||
<td style={{ width: '100px', fontWeight: 600 }}>{g.nodo_nombre}</td>
|
||||
<td>{g.detalle}</td>
|
||||
<td style={{ width: '40px', textAlign: 'center' }}>{g.estado}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Columna Derecha: Entradas Recientes */}
|
||||
<div className="card">
|
||||
<div className="card-header"><i className="fas fa-history"></i> Actividad Reciente</div>
|
||||
<div style={{ padding: '0' }}>
|
||||
{entradas.length === 0 ? (
|
||||
<p style={{ padding: '1rem', color: 'var(--text-muted)', fontSize: '0.85rem' }}>Sin actividad reciente.</p>
|
||||
) : (
|
||||
<table className="table-ifde" style={{ fontSize: '0.85rem' }}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>I</th>
|
||||
<th>F</th>
|
||||
<th>Nodo</th>
|
||||
<th>Descripción</th>
|
||||
<th>E</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{entradas.map(e => (
|
||||
<tr key={e.id}>
|
||||
<td className="col-time">{e.inicio?.substring(0, 5)}</td>
|
||||
<td className="col-time">{e.fin ? e.fin.substring(0, 5) : '—'}</td>
|
||||
<td style={{ fontWeight: 600, width: '100px' }}>{e.nodo_nombre}</td>
|
||||
<td>{e.descripcion.substring(0, 100)}{e.descripcion.length > 100 ? '...' : ''}</td>
|
||||
<td style={{ width: '40px', textAlign: 'center' }}>{e.estado}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user