|
@@ -19,6 +19,7 @@ import {
|
|
|
Github,
|
|
Github,
|
|
|
HardDrive,
|
|
HardDrive,
|
|
|
Heart,
|
|
Heart,
|
|
|
|
|
+ History,
|
|
|
KeyRound,
|
|
KeyRound,
|
|
|
LogOut,
|
|
LogOut,
|
|
|
MonitorSmartphone,
|
|
MonitorSmartphone,
|
|
@@ -43,6 +44,7 @@ import type { LucideIcon } from 'lucide-react'
|
|
|
import { HealthRing } from '@/components/HealthRing'
|
|
import { HealthRing } from '@/components/HealthRing'
|
|
|
import { SegmentedControl } from '@/components/SegmentedControl'
|
|
import { SegmentedControl } from '@/components/SegmentedControl'
|
|
|
import { TopologyOverridesManager } from '@/components/topology/TopologyOverridesManager'
|
|
import { TopologyOverridesManager } from '@/components/topology/TopologyOverridesManager'
|
|
|
|
|
+import { ReadinessPanel, type UpdateReadiness } from '@/components/UpdateReadiness'
|
|
|
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from '@/components/ui/alert-dialog'
|
|
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from '@/components/ui/alert-dialog'
|
|
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog'
|
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog'
|
|
|
import { Slider } from '@/components/ui/slider'
|
|
import { Slider } from '@/components/ui/slider'
|
|
@@ -52,6 +54,7 @@ import { useAuth } from '@/data/AuthContext'
|
|
|
import { getVapidKey, postPushSubscribe, postPushUnsubscribe, pushContext, urlBase64ToUint8Array } from '@/data/push'
|
|
import { getVapidKey, postPushSubscribe, postPushUnsubscribe, pushContext, urlBase64ToUint8Array } from '@/data/push'
|
|
|
import { useServicesVisibility } from '@/hooks/useServicesVisibility'
|
|
import { useServicesVisibility } from '@/hooks/useServicesVisibility'
|
|
|
import type { ServicesVisibility } from '@/hooks/useServicesVisibility'
|
|
import type { ServicesVisibility } from '@/hooks/useServicesVisibility'
|
|
|
|
|
+import { relTimeFromTs } from '@/i18n'
|
|
|
import { cn, exitDemo } from '@/lib/utils'
|
|
import { cn, exitDemo } from '@/lib/utils'
|
|
|
import { ACCENTS, type AccentId, type ThemeMode } from '@/lib/theme-boot'
|
|
import { ACCENTS, type AccentId, type ThemeMode } from '@/lib/theme-boot'
|
|
|
import pkg from '../../package.json'
|
|
import pkg from '../../package.json'
|
|
@@ -1873,7 +1876,8 @@ function DemoCard({ onSaved }: { reduce?: boolean; onSaved: () => void }) {
|
|
|
|
|
|
|
|
/** Widget inline de "Comprobar actualizaciones" para la AdminBar. Usa los
|
|
/** Widget inline de "Comprobar actualizaciones" para la AdminBar. Usa los
|
|
|
* endpoints /api/update/status y /api/update/apply (misma lógica que
|
|
* endpoints /api/update/status y /api/update/apply (misma lógica que
|
|
|
- * UpdateBanner, sin banner): al pulsar comprueba y muestra estado compacto. */
|
|
|
|
|
|
|
+ * UpdateBanner, sin banner): al pulsar comprueba y muestra estado compacto.
|
|
|
|
|
+ * Con readiness (issue #160): los checks previos bloquean el botón. */
|
|
|
interface NetPulseUpdateStatus {
|
|
interface NetPulseUpdateStatus {
|
|
|
current: string
|
|
current: string
|
|
|
latest: string | null
|
|
latest: string | null
|
|
@@ -1882,6 +1886,7 @@ interface NetPulseUpdateStatus {
|
|
|
canApply: boolean
|
|
canApply: boolean
|
|
|
repo: string
|
|
repo: string
|
|
|
updating: false | { step: string }
|
|
updating: false | { step: string }
|
|
|
|
|
+ readiness?: UpdateReadiness | null
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function UpdateCheckInline() {
|
|
function UpdateCheckInline() {
|
|
@@ -1915,6 +1920,8 @@ function UpdateCheckInline() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ const ready = status?.readiness ? status.readiness.ready : true
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<div className="flex flex-col gap-1">
|
|
<div className="flex flex-col gap-1">
|
|
|
{status?.updateAvailable && status.latest ? (
|
|
{status?.updateAvailable && status.latest ? (
|
|
@@ -1922,8 +1929,8 @@ function UpdateCheckInline() {
|
|
|
<button
|
|
<button
|
|
|
type="button"
|
|
type="button"
|
|
|
onClick={() => void apply()}
|
|
onClick={() => void apply()}
|
|
|
- disabled={busy}
|
|
|
|
|
- className="inline-flex h-9 shrink-0 items-center gap-1.5 rounded-xl border border-accent bg-accent-soft px-3 text-[13px] font-medium text-accent transition-colors hover:brightness-105 disabled:opacity-60"
|
|
|
|
|
|
|
+ disabled={busy || !ready}
|
|
|
|
|
+ className="inline-flex h-9 shrink-0 items-center gap-1.5 rounded-xl border border-accent bg-accent-soft px-3 text-[13px] font-medium text-accent transition-colors hover:brightness-105 disabled:cursor-not-allowed disabled:opacity-60"
|
|
|
>
|
|
>
|
|
|
<Download className="h-4 w-4 shrink-0" strokeWidth={1.75} aria-hidden="true" />
|
|
<Download className="h-4 w-4 shrink-0" strokeWidth={1.75} aria-hidden="true" />
|
|
|
<span className="hidden sm:inline">{t('update.button')}</span>
|
|
<span className="hidden sm:inline">{t('update.button')}</span>
|
|
@@ -1961,6 +1968,94 @@ function UpdateCheckInline() {
|
|
|
{t('settings.about.updateError')}
|
|
{t('settings.about.updateError')}
|
|
|
</span>
|
|
</span>
|
|
|
) : null}
|
|
) : null}
|
|
|
|
|
+ {status?.updateAvailable && status.canApply && status.readiness && (
|
|
|
|
|
+ <div className="mt-2 w-[260px]">
|
|
|
|
|
+ <ReadinessPanel readiness={status.readiness} compact />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/** Historial de actualizaciones (issue #159): tabla con los últimos applies
|
|
|
|
|
+ * (SHA from→to, fecha, estado, duración) servida por GET /api/updates/history. */
|
|
|
|
|
+interface UpdateHistoryRow {
|
|
|
|
|
+ id: number
|
|
|
|
|
+ ts: number
|
|
|
|
|
+ action: string
|
|
|
|
|
+ channel: string
|
|
|
|
|
+ versionFrom?: string
|
|
|
|
|
+ versionTo?: string
|
|
|
|
|
+ initiatedBy: string
|
|
|
|
|
+ status: string
|
|
|
|
|
+ durationMs?: number
|
|
|
|
|
+ error?: string
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function UpdateHistoryCard() {
|
|
|
|
|
+ const { t } = useTranslation()
|
|
|
|
|
+ const [rows, setRows] = useState<UpdateHistoryRow[] | null>(null)
|
|
|
|
|
+
|
|
|
|
|
+ const load = useCallback(async () => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await fetch('/api/updates/history')
|
|
|
|
|
+ if (!res.ok) return
|
|
|
|
|
+ const json = (await res.json()) as { history?: UpdateHistoryRow[] }
|
|
|
|
|
+ setRows(json.history ?? [])
|
|
|
|
|
+ } catch {
|
|
|
|
|
+ /* sin historial: la tarjeta muestra el estado vacío */
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [])
|
|
|
|
|
+
|
|
|
|
|
+ useEffect(() => { void load() }, [load])
|
|
|
|
|
+
|
|
|
|
|
+ const statusLabel = (s: string) =>
|
|
|
|
|
+ s === 'success' ? t('update.history.success') : s === 'failed' ? t('update.history.failed') : t('update.history.running')
|
|
|
|
|
+ const statusCls = (s: string) =>
|
|
|
|
|
+ s === 'success' ? 'text-ok' : s === 'failed' ? 'text-rose-500' : 'text-amber-600 dark:text-amber-400'
|
|
|
|
|
+
|
|
|
|
|
+ return (
|
|
|
|
|
+ <div className="rounded-2xl border border-border bg-surface p-4 md:p-5">
|
|
|
|
|
+ <div className="mb-3 flex items-center gap-2">
|
|
|
|
|
+ <History className="h-4 w-4 text-accent" strokeWidth={1.75} aria-hidden="true" />
|
|
|
|
|
+ <h3 className="text-sm font-semibold text-text-primary">{t('update.history.title')}</h3>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ {rows === null ? (
|
|
|
|
|
+ <p className="text-xs text-text-muted">{t('settings.about.checking')}</p>
|
|
|
|
|
+ ) : rows.length === 0 ? (
|
|
|
|
|
+ <p className="text-xs text-text-secondary">{t('update.history.empty')}</p>
|
|
|
|
|
+ ) : (
|
|
|
|
|
+ <div className="overflow-x-auto">
|
|
|
|
|
+ <table className="w-full min-w-[540px] text-left text-xs">
|
|
|
|
|
+ <thead>
|
|
|
|
|
+ <tr className="border-b border-border text-text-muted">
|
|
|
|
|
+ <th className="py-2 pr-3 font-medium">{t('update.history.date')}</th>
|
|
|
|
|
+ <th className="py-2 pr-3 font-medium">{t('update.history.from')}</th>
|
|
|
|
|
+ <th className="py-2 pr-3 font-medium">{t('update.history.to')}</th>
|
|
|
|
|
+ <th className="py-2 pr-3 font-medium">{t('update.history.initiatedBy')}</th>
|
|
|
|
|
+ <th className="py-2 pr-3 font-medium">{t('update.history.duration')}</th>
|
|
|
|
|
+ <th className="py-2 font-medium">{t('update.history.status')}</th>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ </thead>
|
|
|
|
|
+ <tbody>
|
|
|
|
|
+ {rows.map((r) => (
|
|
|
|
|
+ <tr key={r.id} className="border-b border-border/60 last:border-0">
|
|
|
|
|
+ <td className="whitespace-nowrap py-2 pr-3 text-text-secondary">
|
|
|
|
|
+ {relTimeFromTs(r.ts) ?? new Date(r.ts).toLocaleString()}
|
|
|
|
|
+ </td>
|
|
|
|
|
+ <td className="py-2 pr-3 font-mono text-text-primary">{r.versionFrom ?? '—'}</td>
|
|
|
|
|
+ <td className="py-2 pr-3 font-mono text-text-primary">{r.versionTo ?? '—'}</td>
|
|
|
|
|
+ <td className="py-2 pr-3 text-text-secondary">{r.initiatedBy || '—'}</td>
|
|
|
|
|
+ <td className="py-2 pr-3 text-text-secondary">
|
|
|
|
|
+ {r.durationMs != null ? `${(r.durationMs / 1000).toFixed(1)} s` : '—'}
|
|
|
|
|
+ </td>
|
|
|
|
|
+ <td className={cn('py-2 font-semibold', statusCls(r.status))}>{statusLabel(r.status)}</td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ ))}
|
|
|
|
|
+ </tbody>
|
|
|
|
|
+ </table>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )}
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
@@ -3198,6 +3293,14 @@ export default function Settings() {
|
|
|
</div>
|
|
</div>
|
|
|
)}
|
|
)}
|
|
|
|
|
|
|
|
|
|
+ {/* Historial de actualizaciones (issue #159) — solo admin y modo live;
|
|
|
|
|
+ el updater es un mecanismo de auto-aplicación que no existe en demo */}
|
|
|
|
|
+ {!isDemo && auth?.role === 'admin' && (
|
|
|
|
|
+ <div className="lg:col-span-12">
|
|
|
|
|
+ <UpdateHistoryCard />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )}
|
|
|
|
|
+
|
|
|
{/* Gestión de routers — solo admin y con backend (modo live); la API
|
|
{/* Gestión de routers — solo admin y con backend (modo live); la API
|
|
|
exige rol admin en las mutaciones (auditoría v2.4.0 §2, #7) */}
|
|
exige rol admin en las mutaciones (auditoría v2.4.0 §2, #7) */}
|
|
|
{!isDemo && auth?.role === 'admin' && (
|
|
{!isDemo && auth?.role === 'admin' && (
|