@@ -3,6 +3,7 @@ import DropZone from "./dropZone";
3
3
import Button from "@material-ui/core/Button" ;
4
4
import Container from "@material-ui/core/Container" ;
5
5
import CloudUploadIcon from "@material-ui/icons/CloudUpload" ;
6
+ import CircularProgress from '@material-ui/core/CircularProgress' ;
6
7
import css from "./index.module.less" ;
7
8
8
9
/**
@@ -14,6 +15,7 @@ import css from "./index.module.less";
14
15
*/
15
16
export default function DropAndFetch ( { onStore, onClick, newURL } ) {
16
17
const [ dataFiles , setDataFiles ] = useState ( { } ) ;
18
+ const [ loading , setLoading ] = useState ( false ) ;
17
19
18
20
const dragsAndDrops = [
19
21
{ name : "Domain" , fileType : ".pddl" , desc : "or predictes and actions." } ,
@@ -41,6 +43,7 @@ export default function DropAndFetch({ onStore, onClick, newURL }) {
41
43
formData . append ( name , files [ name ] ) ;
42
44
}
43
45
try {
46
+ setLoading ( true )
44
47
const resp = await fetch (
45
48
"https://planimation.planning.domains/upload/pddl" ,
46
49
{
@@ -55,6 +58,8 @@ export default function DropAndFetch({ onStore, onClick, newURL }) {
55
58
onStore ( txt ) ;
56
59
} catch ( error ) {
57
60
alert ( error ) ;
61
+ } finally {
62
+ setLoading ( false ) ;
58
63
}
59
64
} ;
60
65
@@ -92,6 +97,7 @@ export default function DropAndFetch({ onStore, onClick, newURL }) {
92
97
onFileLoad = { handleFileLoad }
93
98
/>
94
99
) ) }
100
+ { loading && < div className = { css . loadingBox } /> }
95
101
</ Container >
96
102
< Container maxWidth = "sm" component = "main" >
97
103
< div className = { css . buttonBox } >
@@ -102,14 +108,18 @@ export default function DropAndFetch({ onStore, onClick, newURL }) {
102
108
>
103
109
Cancel
104
110
</ Button >
111
+ < div className = { css . wrapper } >
105
112
< Button
106
113
variant = "contained"
107
114
color = "primary"
108
115
startIcon = { < CloudUploadIcon /> }
109
116
onClick = { handleSubmit }
117
+ disabled = { loading }
110
118
>
111
119
Upload Files
112
120
</ Button >
121
+ { loading && < CircularProgress size = { 24 } className = { css . loading } /> }
122
+ </ div >
113
123
</ div >
114
124
</ Container >
115
125
</ div >
0 commit comments