diff --git a/client/src/pages/Metaset.tsx b/client/src/pages/Metaset.tsx index 9493454..c09b1f0 100644 --- a/client/src/pages/Metaset.tsx +++ b/client/src/pages/Metaset.tsx @@ -1,77 +1,66 @@ -import { useState } from "react"; -import { Loader2, AlertCircle, ExternalLink } from "lucide-react"; -import { Button } from "@/components/ui/button"; +import { useState, useEffect } from "react"; +import { Loader2, AlertCircle } from "lucide-react"; import { Alert, AlertDescription } from "@/components/ui/alert"; +import { Button } from "@/components/ui/button"; export default function Metaset() { const [isLoading, setIsLoading] = useState(true); const [hasError, setHasError] = useState(false); + const [errorMessage, setErrorMessage] = useState(""); + + useEffect(() => { + // Verificar se o Metaset está online + fetch("/api/bi/metaset/health", { credentials: "include" }) + .then(r => r.json()) + .then(data => { + if (!data.online) { + setHasError(true); + setErrorMessage("O Metaset está offline ou iniciando."); + } + }) + .catch(() => { + setHasError(true); + setErrorMessage("Não foi possível conectar ao Metaset."); + }) + .finally(() => { + setIsLoading(false); + }); + }, []); + + if (hasError) { + return ( +
+ + + + {errorMessage} +
+ +
+
+
+
+ ); + } return ( -
- {/* Header do módulo */} -
-
- Metaset BI +
+ {isLoading && ( +
+
+ + Carregando Metaset... +
- -
- - {/* Container do iframe */} -
- {isLoading && ( -
-
- - Carregando Metaset... -
-
- )} - - {hasError ? ( -
- - - - Não foi possível carregar o Metaset. O site pode não permitir embed em iframe. - - - -
- ) : ( -