From 496247d0b9975097a008cf4d3a999d77648fd930 Mon Sep 17 00:00:00 2001 From: Sabir Hassan Date: Tue, 5 Jul 2022 08:23:51 +0500 Subject: [PATCH] fix: show loading spinner in studio while executing code --- web/src/containers/Studio/index.tsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/web/src/containers/Studio/index.tsx b/web/src/containers/Studio/index.tsx index c05516a..011ce05 100644 --- a/web/src/containers/Studio/index.tsx +++ b/web/src/containers/Studio/index.tsx @@ -2,13 +2,15 @@ import React, { useEffect, useRef, useState, useContext } from 'react' import axios from 'axios' import { + Backdrop, Box, - MenuItem, + Button, + CircularProgress, FormControl, + MenuItem, + Paper, Select, SelectChangeEvent, - Button, - Paper, Tab, Tooltip } from '@mui/material' @@ -50,6 +52,7 @@ const Studio = () => { const [tab, setTab] = useState('1') const [runTimes, setRunTimes] = useState([]) const [selectedRunTime, setSelectedRunTime] = useState('') + const [isRunning, setIsRunning] = useState(false) useEffect(() => { setRunTimes(Object.values(appContext.runTimes)) @@ -78,6 +81,7 @@ const Studio = () => { const handleRunBtnClick = () => runCode(getSelection() || fileContent) const runCode = (code: string) => { + setIsRunning(true) axios .post(`/SASjsApi/code/execute`, { code, runTime: selectedRunTime }) .then((res: any) => { @@ -94,6 +98,7 @@ const Studio = () => { window.scrollTo(0, document.body.scrollHeight) }) .catch((err) => console.log(err)) + .finally(() => setIsRunning(false)) } const handleKeyDown = (event: any) => { @@ -163,6 +168,12 @@ const Studio = () => { + theme.zIndex.drawer + 1 }} + open={isRunning} + > + +