Skip to content

Commit 46e2615

Browse files
committed
UI - issue 455 - don't allow to run pipeline in admin when no files uploaded
1 parent 523dd43 commit 46e2615

File tree

1 file changed

+46
-27
lines changed

1 file changed

+46
-27
lines changed

src/client/src/pages/Admin.js

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ class Admin extends Component {
3636
filesInput: undefined,
3737
fileListHtml: undefined,
3838
lastExecution: undefined,
39-
serverBusy: false
39+
serverBusy: false,
40+
isFileListExist: false
4041
}
4142

4243
this.handleIndexChange = this.handleIndexChange.bind(this);
4344
this.handleUpload = this.handleUpload.bind(this);
4445
this.handleExecute = this.handleExecute.bind(this);
4546
this.handleGetFileList = this.handleGetFileList.bind(this);
4647
this.handleGetStatistics = this.handleGetStatistics.bind(this);
48+
this.setFileListExist = this.setFileListExist.bind(this);
49+
4750
}
4851

4952
async refreshPage() {
@@ -141,6 +144,18 @@ class Admin extends Component {
141144
this.setState({fileListHtml: filesResponse});
142145
}
143146

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+
144159
render() {
145160
return (
146161
<Container>
@@ -191,7 +206,11 @@ class Admin extends Component {
191206
<CardContent>
192207
<Typography variant="h5">Upload Files</Typography>
193208
<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+
/>
195214
<Button type="submit" variant="contained" color="primary"
196215
disabled={this.state.statistics === 'Running'}>
197216
Upload
@@ -210,41 +229,41 @@ class Admin extends Component {
210229
<Grid item>
211230

212231

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'>
230238
<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>
232245
</TableCell>
233-
<TableCell align="left">{row[1]}</TableCell>
234246
</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+
}
240259
</Grid>
241260
<Grid item>
242261
<Paper style={{padding: 5, marginTop: 10}}>
243262
<CardContent>
244263
<Typography variant="h5">Run New Analysis</Typography>
245264
<form onSubmit={this.handleExecute}>
246265
<Button type="submit" variant="contained" color="primary"
247-
disabled={this.state.statistics === 'Running'}>
266+
disabled={this.state.statistics === 'Running' || this.state.isFileListExist === false}>
248267
Run Data Analysis
249268
</Button>
250269
</form>

0 commit comments

Comments
 (0)