feat: tarjeta portal lleva al tablero IT (boardHref shell)
This commit is contained in:
1 parent
23df440b79
commit
39cb4ec89a
3 files changed
+42
-8
No files matched your search
+18
-6
@@ -3,6 +3,7 @@
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useModules, refreshModules } from "@/lib/store";
|
import { useModules, refreshModules } from "@/lib/store";
|
||||||
import {
|
import {
|
||||||
|
boardHref,
|
||||||
displayName,
|
displayName,
|
||||||
envOf,
|
envOf,
|
||||||
getModuleMeta,
|
getModuleMeta,
|
||||||
@@ -33,6 +34,22 @@ export default function Home() {
|
|||||||
const env = envOf(m.branch);
|
const env = envOf(m.branch);
|
||||||
const url = moduleUrl(m);
|
const url = moduleUrl(m);
|
||||||
const name = displayName(m.name);
|
const name = displayName(m.name);
|
||||||
|
const board = boardHref(m);
|
||||||
|
const boardLink = board.external ? (
|
||||||
|
<a
|
||||||
|
href={board.href}
|
||||||
|
className="text-decoration-none text-dark d-block py-2 stretched-link"
|
||||||
|
>
|
||||||
|
{name}
|
||||||
|
</a>
|
||||||
|
) : (
|
||||||
|
<Link
|
||||||
|
href={board.href}
|
||||||
|
className="text-decoration-none text-dark d-block py-2 stretched-link"
|
||||||
|
>
|
||||||
|
{name}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<div className="col-md-6" key={m.name}>
|
<div className="col-md-6" key={m.name}>
|
||||||
<div className="app-card p-2">
|
<div className="app-card p-2">
|
||||||
@@ -45,12 +62,7 @@ export default function Home() {
|
|||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<Link
|
{boardLink}
|
||||||
href={`/m/${m.name}`}
|
|
||||||
className="text-decoration-none text-dark d-block py-2 stretched-link"
|
|
||||||
>
|
|
||||||
{name}
|
|
||||||
</Link>
|
|
||||||
<div className="d-flex align-items-center gap-2">
|
<div className="d-flex align-items-center gap-2">
|
||||||
<span className={`status-dot ${status.cls}`} />
|
<span className={`status-dot ${status.cls}`} />
|
||||||
<small className="text-muted" style={{ fontSize: "0.75rem" }}>
|
<small className="text-muted" style={{ fontSize: "0.75rem" }}>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import SamShell from "@/components/SamShell";
|
|||||||
import { useModules, useStats } from "@/lib/store";
|
import { useModules, useStats } from "@/lib/store";
|
||||||
import {
|
import {
|
||||||
displayName,
|
displayName,
|
||||||
|
boardHref,
|
||||||
envOf,
|
envOf,
|
||||||
getModuleMeta,
|
getModuleMeta,
|
||||||
moduleUrl,
|
moduleUrl,
|
||||||
@@ -103,6 +104,7 @@ function AppCard({ m, stat }: { m: ModuleState; stat?: ContainerStat }) {
|
|||||||
const env = envOf(m.branch);
|
const env = envOf(m.branch);
|
||||||
const cpu = pct(stat?.cpu);
|
const cpu = pct(stat?.cpu);
|
||||||
const mem = pct(stat?.memPerc);
|
const mem = pct(stat?.memPerc);
|
||||||
|
const board = boardHref(m);
|
||||||
return (
|
return (
|
||||||
<div className="col-md-6 col-xl-4">
|
<div className="col-md-6 col-xl-4">
|
||||||
<div className="app-card p-3 h-100">
|
<div className="app-card p-3 h-100">
|
||||||
@@ -133,9 +135,15 @@ function AppCard({ m, stat }: { m: ModuleState; stat?: ContainerStat }) {
|
|||||||
<Bar value={mem} color="#6f42c1" />
|
<Bar value={mem} color="#6f42c1" />
|
||||||
</div>
|
</div>
|
||||||
<div className="d-flex gap-2 mt-2">
|
<div className="d-flex gap-2 mt-2">
|
||||||
<Link href={`/m/${m.name}`} className="btn btn-sm btn-outline-primary flex-fill">
|
{board.external ? (
|
||||||
|
<a href={board.href} className="btn btn-sm btn-outline-primary flex-fill">
|
||||||
|
<i className="bx bx-grid-alt me-1" /> Tablero
|
||||||
|
</a>
|
||||||
|
) : (
|
||||||
|
<Link href={board.href} className="btn btn-sm btn-outline-primary flex-fill">
|
||||||
<i className="bx bx-grid-alt me-1" /> Tablero
|
<i className="bx bx-grid-alt me-1" /> Tablero
|
||||||
</Link>
|
</Link>
|
||||||
|
)}
|
||||||
<a
|
<a
|
||||||
href={moduleUrl(m)}
|
href={moduleUrl(m)}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
|
|||||||
+15
-1
@@ -221,6 +221,20 @@ export function moduleUrl(m: ModuleState) {
|
|||||||
return `https://${m.subdomain}.devops.norteamericano.cl`;
|
return `https://${m.subdomain}.devops.norteamericano.cl`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tablero IT: es el tablero del propio shell (módulo portal).
|
||||||
|
export const IT_BOARD_URL = "https://it.sam.devops.norteamericano.cl";
|
||||||
|
|
||||||
|
// El módulo que sirve sam.devops es el shell: su tablero es el IT.
|
||||||
|
export function isShellModule(m: ModuleState): boolean {
|
||||||
|
return m.subdomain === "sam" || m.name.toLowerCase() === "portal";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destino del botón/tarjeta "Tablero" del módulo.
|
||||||
|
export function boardHref(m: ModuleState): { href: string; external: boolean } {
|
||||||
|
if (isShellModule(m)) return { href: IT_BOARD_URL, external: true };
|
||||||
|
return { href: `/m/${m.name}`, external: false };
|
||||||
|
}
|
||||||
|
|
||||||
// ============================================================
|
// ============================================================
|
||||||
// Secciones del índice: dónde aparece cada módulo.
|
// Secciones del índice: dónde aparece cada módulo.
|
||||||
// - Todo módulo nuevo cae en "apps" (Aplicaciones) automáticamente.
|
// - Todo módulo nuevo cae en "apps" (Aplicaciones) automáticamente.
|
||||||
@@ -270,7 +284,7 @@ export function itMenu(modules: ModuleState[]): MenuItem[] {
|
|||||||
...modules.map((m) => ({
|
...modules.map((m) => ({
|
||||||
label: displayName(m.name),
|
label: displayName(m.name),
|
||||||
icon: getModuleMeta(m.name).icon,
|
icon: getModuleMeta(m.name).icon,
|
||||||
href: `/m/${m.name}`,
|
href: boardHref(m).href,
|
||||||
})),
|
})),
|
||||||
{ label: "Agregar", icon: "bx-plus", href: "/upload" },
|
{ label: "Agregar", icon: "bx-plus", href: "/upload" },
|
||||||
{ label: "Actualizar", icon: "bx-refresh", href: "/actualizar" },
|
{ label: "Actualizar", icon: "bx-refresh", href: "/actualizar" },
|
||||||
|
|||||||
Reference in new issue
Block a user