@@ -36,14 +36,17 @@ class Admin extends Component {
36
36
filesInput : undefined ,
37
37
fileListHtml : undefined ,
38
38
lastExecution : undefined ,
39
- serverBusy : false
39
+ serverBusy : false ,
40
+ isFileListExist : false
40
41
}
41
42
42
43
this . handleIndexChange = this . handleIndexChange . bind ( this ) ;
43
44
this . handleUpload = this . handleUpload . bind ( this ) ;
44
45
this . handleExecute = this . handleExecute . bind ( this ) ;
45
46
this . handleGetFileList = this . handleGetFileList . bind ( this ) ;
46
47
this . handleGetStatistics = this . handleGetStatistics . bind ( this ) ;
48
+ this . setFileListExist = this . setFileListExist . bind ( this ) ;
49
+
47
50
}
48
51
49
52
async refreshPage ( ) {
@@ -141,6 +144,18 @@ class Admin extends Component {
141
144
this . setState ( { fileListHtml : filesResponse } ) ;
142
145
}
143
146
147
+ setFileListExist ( ) {
148
+ debugger ;
149
+ let uploadedItems = document . getElementById ( 'fileItemsID' ) ;
150
+
151
+ if ( uploadedItems ) {
152
+ if ( _ . size ( uploadedItems . files ) > 0 ) {
153
+ this . setState ( { isFileListExist : true } ) ;
154
+ }
155
+
156
+ }
157
+ }
158
+
144
159
render ( ) {
145
160
return (
146
161
< Container >
@@ -191,7 +206,11 @@ class Admin extends Component {
191
206
< CardContent >
192
207
< Typography variant = "h5" > Upload Files</ Typography >
193
208
< form onSubmit = { this . handleUpload } >
194
- < input type = "file" value = { this . state . filesInput } multiple />
209
+ < input type = "file" id = "fileItemsID"
210
+ onChange = { this . setFileListExist }
211
+ value = { this . state . filesInput }
212
+ multiple
213
+ />
195
214
< Button type = "submit" variant = "contained" color = "primary"
196
215
disabled = { this . state . statistics === 'Running' } >
197
216
Upload
@@ -210,41 +229,41 @@ class Admin extends Component {
210
229
< Grid item >
211
230
212
231
213
- { _ . isEmpty ( this . state . statistics ) !== true &&
214
- this . state . statistics !== 'Running' &&
215
- < TableContainer component = { Paper } >
216
- < Table aria-label = "simple table" >
217
- < TableBody >
218
- < TableRow key = 'time' >
219
- < TableCell align = "left" component = "th" scope = "row" >
220
- < b > Last Analysis</ b >
221
- </ TableCell >
222
- < TableCell align = "left" >
223
- < b >
224
- { moment ( this . state . lastExecution , "dddd MMMM Do h:mm:ss YYYY" ) . local ( ) . format ( "MMMM Do YYYY, h:mm:ss a" ) }
225
- </ b >
226
- </ TableCell >
227
- </ TableRow >
228
- { this . state . statistics . map ( ( row , index ) => (
229
- < TableRow key = { index } >
232
+ { _ . isEmpty ( this . state . statistics ) !== true &&
233
+ this . state . statistics !== 'Running' &&
234
+ < TableContainer component = { Paper } >
235
+ < Table aria-label = "simple table" >
236
+ < TableBody >
237
+ < TableRow key = 'time' >
230
238
< TableCell align = "left" component = "th" scope = "row" >
231
- { row [ 0 ] }
239
+ < b > Last Analysis</ b >
240
+ </ TableCell >
241
+ < TableCell align = "left" >
242
+ < b >
243
+ { moment ( this . state . lastExecution , "dddd MMMM Do h:mm:ss YYYY" ) . local ( ) . format ( "MMMM Do YYYY, h:mm:ss a" ) }
244
+ </ b >
232
245
</ TableCell >
233
- < TableCell align = "left" > { row [ 1 ] } </ TableCell >
234
246
</ TableRow >
235
- ) ) }
236
- </ TableBody >
237
- </ Table >
238
- </ TableContainer >
239
- }
247
+ { this . state . statistics . map ( ( row , index ) => (
248
+ < TableRow key = { index } >
249
+ < TableCell align = "left" component = "th" scope = "row" >
250
+ { row [ 0 ] }
251
+ </ TableCell >
252
+ < TableCell align = "left" > { row [ 1 ] } </ TableCell >
253
+ </ TableRow >
254
+ ) ) }
255
+ </ TableBody >
256
+ </ Table >
257
+ </ TableContainer >
258
+ }
240
259
</ Grid >
241
260
< Grid item >
242
261
< Paper style = { { padding : 5 , marginTop : 10 } } >
243
262
< CardContent >
244
263
< Typography variant = "h5" > Run New Analysis</ Typography >
245
264
< form onSubmit = { this . handleExecute } >
246
265
< Button type = "submit" variant = "contained" color = "primary"
247
- disabled = { this . state . statistics === 'Running' } >
266
+ disabled = { this . state . statistics === 'Running' || this . state . isFileListExist === false } >
248
267
Run Data Analysis
249
268
</ Button >
250
269
</ form >
0 commit comments