diff --git a/modelina-website/src/components/contexts/PlaygroundContext.tsx b/modelina-website/src/components/contexts/PlaygroundContext.tsx index 7d646877cc..893aa6261f 100644 --- a/modelina-website/src/components/contexts/PlaygroundContext.tsx +++ b/modelina-website/src/components/contexts/PlaygroundContext.tsx @@ -41,6 +41,8 @@ interface PlaygroundContextProps { setHasLoadedQuery: Dispatch>; renderModels: React.ReactNode | null; setRenderModels: (models: React.ReactNode) => void; + outputLoading: boolean; + setOutputLoading: Dispatch>; } const PlaygroundContext = createContext(undefined); @@ -104,6 +106,7 @@ export const PlaygroundContextProvider: React.FC<{ const [isLoaded, setIsLoaded] = useState(false); const [hasLoadedQuery, setHasLoadedQuery] = useState(false); const [renderModels, setRenderModels] = React.useState(null); + const [outputLoading, setOutputLoading] = useState(true); const contextValue = useMemo( () => ({ @@ -130,7 +133,9 @@ export const PlaygroundContextProvider: React.FC<{ hasLoadedQuery, setHasLoadedQuery, renderModels, - setRenderModels + setRenderModels, + outputLoading, + setOutputLoading }), [ config, @@ -156,7 +161,9 @@ export const PlaygroundContextProvider: React.FC<{ hasLoadedQuery, setHasLoadedQuery, renderModels, - setRenderModels + setRenderModels, + outputLoading, + setOutputLoading ] ); diff --git a/modelina-website/src/components/playground/GeneratedModels.tsx b/modelina-website/src/components/playground/GeneratedModels.tsx index c363323106..1d4971122e 100644 --- a/modelina-website/src/components/playground/GeneratedModels.tsx +++ b/modelina-website/src/components/playground/GeneratedModels.tsx @@ -13,6 +13,7 @@ const GeneratedModelsComponent: React.FC = ({ sho const context = useContext(PlaygroundGeneratedContext); const [selectedModel, setSelectedModel] = useState(''); const { setRenderModels, generatorCode, showGeneratorCode, setShowGeneratorCode } = usePlaygroundContext(); + const { outputLoading } = usePlaygroundContext(); const toShow = () => { let selectedCode = ''; @@ -90,11 +91,17 @@ const GeneratedModelsComponent: React.FC = ({ sho return (
- +
Loading...
+
: + + }
); diff --git a/modelina-website/src/components/playground/Playground.tsx b/modelina-website/src/components/playground/Playground.tsx index 5843f5d6a1..02e5b4128f 100644 --- a/modelina-website/src/components/playground/Playground.tsx +++ b/modelina-website/src/components/playground/Playground.tsx @@ -43,7 +43,9 @@ const Playground: React.FC = (props) => { isLoaded, setIsLoaded, hasLoadedQuery, - setHasLoadedQuery + setHasLoadedQuery, + outputLoading, + setOutputLoading } = usePlaygroundContext(); // To avoid hydration error @@ -53,6 +55,8 @@ const Playground: React.FC = (props) => { * Tell the socket io server that we want some code */ const generateNewCode = (inputArgs: string) => { + setOutputLoading(true); + try { const message: GenerateMessage = { ...config, @@ -102,6 +106,7 @@ const Playground: React.FC = (props) => { setError(false); setStatusCode(200); setErrorMessage(''); + setOutputLoading(false); }) .catch((error) => { console.error(error); diff --git a/modelina-website/src/styles/globals.css b/modelina-website/src/styles/globals.css index 1faeb27206..6bbc6a517c 100644 --- a/modelina-website/src/styles/globals.css +++ b/modelina-website/src/styles/globals.css @@ -72,3 +72,13 @@ abbr[title] { scroll-margin-top: 155px; } } + +.loading-text { + position: relative; + width: 100%; + height: 100%; + z-index: 9999; + display: flex; + justify-content: center; + align-items: center; +}