From 347d8510b48be51b14f40d03759ba733a1084a3b Mon Sep 17 00:00:00 2001 From: Nurfog Date: Tue, 8 Sep 2026 17:10:44 -0300 Subject: [PATCH] feat: indice estilo lanzador sam.norteamericano.cl, sidebar solo en IT + rewrite it.sam --- src/app/page.tsx | 333 ++++++++++++++++++++------------------- src/app/tablero/page.tsx | 26 ++- src/middleware.ts | 17 ++ 3 files changed, 205 insertions(+), 171 deletions(-) create mode 100644 src/middleware.ts diff --git a/src/app/page.tsx b/src/app/page.tsx index 6887c6e..5978ba2 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,9 +1,7 @@ "use client"; import Link from "next/link"; -import SamShell from "@/components/SamShell"; -import TableroView from "@/components/TableroView"; -import { useModules, refreshModules, useSiteSection } from "@/lib/store"; +import { useModules, refreshModules } from "@/lib/store"; import { displayName, envOf, @@ -14,35 +12,14 @@ import { sectionOf, SECTIONS, type ModuleState, + type RefApp, } from "@/lib/sam"; -const sectionMenu = [ - ...SECTIONS.map((s) => ({ label: s.title, icon: s.icon, href: `/#${s.id}` })), - { label: "Tablero IT", icon: "bx-pie-chart-alt-2", href: "/tablero" }, -]; - export default function Home() { const { data, error } = useModules(); - const site = useSiteSection(); const loading = data === null && error === null; const fetchModules = refreshModules; - // it.sam.devops... aterriza directo en el tablero - if (site === "it") { - return ( - - - - ); - } - const modules = data?.modules ?? []; const backend = data?.backend; @@ -107,13 +84,7 @@ export default function Home() { ); }; - const renderRefCard = (app: { - name: string; - title: string; - icon: string; - bg: string; - url: string; - }) => ( + const renderRefCard = (app: RefApp) => (
@@ -150,149 +121,181 @@ export default function Home() { ); return ( - - {loading && ( -
-
-

Cargando módulos...

-
- )} - - {error && ( -
- -
- Error: {error} - + SAM +
+
+
+

Sistema SAM

+
+
+

Aplicaciones

+
+
+ + Tablero IT + + + Nuevo Módulo + +
+
+ Portal de integración
- )} + - {!loading && !error && ( -
- {modules.length === 0 && ( -
-
- -

- No hay módulos integrados. ¡Sube tu primer proyecto! -

- - Subir Proyecto - +
+
+
+
+ {loading && ( +
+
+

Cargando módulos...

-
- )} + )} - {SECTIONS.map((section) => { - const list = bySection[section.id] ?? []; - const isReview = section.id === "otras-apps"; - if (!isReview && list.length === 0) return null; - return ( -
-
-
-
- - {" "} - {section.title} - - {list.length > 0 && ( - - {list.length} módulo - {list.length !== 1 ? "s" : ""} - - )} -
-
- - {list.map(renderModuleCard)} - - {section.id === "sam" && - REFERENCE_APPS.filter( - (a) => - !list.some((m) => m.name.toLowerCase() === a.name) - ).map(renderRefCard)} - - {isReview && backend && ( - <> -
-
-
- - - - - - -
- - - - API Backend - - - {backend.container ? "Activo" : "Detenido"} · {backend.branch} - -
-
-
-
-
- - - - - - - -
- - - - Gestionar Módulos - - - Subir / actualizar proyectos - -
-
-
- - )} + {error && ( +
+ +
+ Error: {error} +
- ); - })} + )} -
- - Auto-actualizado cada 15s ·{" "} - { e.preventDefault(); fetchModules(); }}> - actualizar ahora - - + {!loading && !error && ( +
+ {modules.length === 0 && ( +
+
+ +

+ No hay módulos integrados. ¡Sube tu primer proyecto! +

+ + Subir Proyecto + +
+
+ )} + + {SECTIONS.map((section) => { + const list = bySection[section.id] ?? []; + const isReview = section.id === "otras-apps"; + if (!isReview && list.length === 0) return null; + return ( +
+
+
+
+ + {" "} + {section.title} + + {list.length > 0 && ( + + {list.length} módulo + {list.length !== 1 ? "s" : ""} + + )} +
+
+ + {list.map(renderModuleCard)} + + {section.id === "sam" && + REFERENCE_APPS.filter( + (a) => + !list.some((m) => m.name.toLowerCase() === a.name) + ).map(renderRefCard)} + + {isReview && backend && ( + <> +
+
+ + + + + + + +
+ + + + API Backend + + + {backend.container ? "Activo" : "Detenido"} · {backend.branch} + +
+
+
+
+
+ + + + + + + +
+ + + + Gestionar Módulos + + + Subir / actualizar proyectos + +
+
+
+ + )} +
+
+ ); + })} + +
+ + Auto-actualizado cada 15s ·{" "} + { e.preventDefault(); fetchModules(); }}> + actualizar ahora + + +
+
+ )}
- )} - + + ); } diff --git a/src/app/tablero/page.tsx b/src/app/tablero/page.tsx index 604f627..ad9010d 100644 --- a/src/app/tablero/page.tsx +++ b/src/app/tablero/page.tsx @@ -2,17 +2,31 @@ import SamShell from "@/components/SamShell"; import TableroView from "@/components/TableroView"; +import { useModules } from "@/lib/store"; +import { displayName, getModuleMeta } from "@/lib/sam"; -const menu = [ - { label: "Resumen", icon: "bx-grid-alt", href: "#resumen" }, - { label: "Aplicaciones", icon: "bx-layer", href: "/" }, -]; - +// App IT: sidebar con todas sus opciones (resumen, aplicaciones, +// tableros por módulo y gestión). Se sirve en /tablero y en +// it.sam.devops.norteamericano.cl export default function Tablero() { + const { data } = useModules(); + const modules = data?.modules ?? []; + + const menu = [ + { label: "Resumen", icon: "bx-grid-alt", href: "#resumen" }, + { label: "Aplicaciones", icon: "bx-layer", href: "/" }, + ...modules.map((m) => ({ + label: displayName(m.name), + icon: getModuleMeta(m.name).icon, + href: `/m/${m.name}`, + })), + { label: "Nuevo Módulo", icon: "bx-plus", href: "/upload" }, + ]; + return (