@@ -5,6 +5,7 @@ import Container from "@material-ui/core/Container";
5
5
import CloudUploadIcon from "@material-ui/icons/CloudUpload" ;
6
6
import css from "../../Styles/index.module.less" ;
7
7
import Alert from "../../components/alertInFormat" ;
8
+ import CircularProgress from "@material-ui/core/CircularProgress" ;
8
9
9
10
/**
10
11
* Three DropZones and Upload button to fetch pddl to server
@@ -16,6 +17,7 @@ import Alert from "../../components/alertInFormat";
16
17
export default function DropAndFetch ( { onStore, onClick, newURL } ) {
17
18
const [ dataFiles , setDataFiles ] = useState ( { } ) ;
18
19
const [ showAlert , setAlert ] = useState ( false ) ;
20
+ const [ loading , setLoading ] = useState ( false ) ;
19
21
20
22
const dragsAndDrops = [
21
23
{
@@ -47,6 +49,7 @@ export default function DropAndFetch({ onStore, onClick, newURL }) {
47
49
formData . append ( name , files [ name ] ) ;
48
50
}
49
51
try {
52
+ setLoading ( true ) ;
50
53
const resp = await fetch (
51
54
"https://planimation.planning.domains/upload/pddl" ,
52
55
{
@@ -61,6 +64,8 @@ export default function DropAndFetch({ onStore, onClick, newURL }) {
61
64
onStore ( txt ) ;
62
65
} catch ( error ) {
63
66
alert ( error ) ;
67
+ } finally {
68
+ setLoading ( false ) ;
64
69
}
65
70
} ;
66
71
@@ -102,6 +107,7 @@ export default function DropAndFetch({ onStore, onClick, newURL }) {
102
107
onFileLoad = { handleFileLoad }
103
108
/>
104
109
) ) }
110
+ { loading && < div className = { css . loadingBox } /> }
105
111
</ Container >
106
112
< Container maxWidth = "sm" component = "main" >
107
113
< div className = { css . buttonBox } >
@@ -112,14 +118,20 @@ export default function DropAndFetch({ onStore, onClick, newURL }) {
112
118
>
113
119
Cancel
114
120
</ Button >
115
- < Button
116
- variant = "contained"
117
- color = "primary"
118
- startIcon = { < CloudUploadIcon /> }
119
- onClick = { handleSubmit }
120
- >
121
- Upload Files
122
- </ Button >
121
+ < div className = { css . wrapper } >
122
+ < Button
123
+ variant = "contained"
124
+ color = "primary"
125
+ startIcon = { < CloudUploadIcon /> }
126
+ onClick = { handleSubmit }
127
+ disabled = { loading }
128
+ >
129
+ Upload Files
130
+ </ Button >
131
+ { loading && (
132
+ < CircularProgress size = { 24 } className = { css . loading } />
133
+ ) }
134
+ </ div >
123
135
</ div >
124
136
</ Container >
125
137
< Alert open = { showAlert } reset = { handleResetAlert } severity = "warning" >
0 commit comments