mirror of
https://github.com/sasjs/server.git
synced 2025-12-12 03:54:34 +00:00
fix: show loading spinner in studio while executing code
This commit is contained in:
@@ -2,13 +2,15 @@ import React, { useEffect, useRef, useState, useContext } from 'react'
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
Backdrop,
|
||||||
Box,
|
Box,
|
||||||
MenuItem,
|
Button,
|
||||||
|
CircularProgress,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
MenuItem,
|
||||||
|
Paper,
|
||||||
Select,
|
Select,
|
||||||
SelectChangeEvent,
|
SelectChangeEvent,
|
||||||
Button,
|
|
||||||
Paper,
|
|
||||||
Tab,
|
Tab,
|
||||||
Tooltip
|
Tooltip
|
||||||
} from '@mui/material'
|
} from '@mui/material'
|
||||||
@@ -50,6 +52,7 @@ const Studio = () => {
|
|||||||
const [tab, setTab] = useState('1')
|
const [tab, setTab] = useState('1')
|
||||||
const [runTimes, setRunTimes] = useState<string[]>([])
|
const [runTimes, setRunTimes] = useState<string[]>([])
|
||||||
const [selectedRunTime, setSelectedRunTime] = useState('')
|
const [selectedRunTime, setSelectedRunTime] = useState('')
|
||||||
|
const [isRunning, setIsRunning] = useState(false)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setRunTimes(Object.values(appContext.runTimes))
|
setRunTimes(Object.values(appContext.runTimes))
|
||||||
@@ -78,6 +81,7 @@ const Studio = () => {
|
|||||||
const handleRunBtnClick = () => runCode(getSelection() || fileContent)
|
const handleRunBtnClick = () => runCode(getSelection() || fileContent)
|
||||||
|
|
||||||
const runCode = (code: string) => {
|
const runCode = (code: string) => {
|
||||||
|
setIsRunning(true)
|
||||||
axios
|
axios
|
||||||
.post(`/SASjsApi/code/execute`, { code, runTime: selectedRunTime })
|
.post(`/SASjsApi/code/execute`, { code, runTime: selectedRunTime })
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
@@ -94,6 +98,7 @@ const Studio = () => {
|
|||||||
window.scrollTo(0, document.body.scrollHeight)
|
window.scrollTo(0, document.body.scrollHeight)
|
||||||
})
|
})
|
||||||
.catch((err) => console.log(err))
|
.catch((err) => console.log(err))
|
||||||
|
.finally(() => setIsRunning(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleKeyDown = (event: any) => {
|
const handleKeyDown = (event: any) => {
|
||||||
@@ -163,6 +168,12 @@ const Studio = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<TabPanel sx={{ paddingBottom: 0 }} value="1">
|
<TabPanel sx={{ paddingBottom: 0 }} value="1">
|
||||||
|
<Backdrop
|
||||||
|
sx={{ color: '#fff', zIndex: (theme) => theme.zIndex.drawer + 1 }}
|
||||||
|
open={isRunning}
|
||||||
|
>
|
||||||
|
<CircularProgress color="inherit" />
|
||||||
|
</Backdrop>
|
||||||
<div className={classes.subMenu}>
|
<div className={classes.subMenu}>
|
||||||
<Tooltip title="CTRL+ENTER will also run SAS code">
|
<Tooltip title="CTRL+ENTER will also run SAS code">
|
||||||
<Button onClick={handleRunBtnClick} className={classes.runButton}>
|
<Button onClick={handleRunBtnClick} className={classes.runButton}>
|
||||||
|
|||||||
Reference in New Issue
Block a user