diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-14 14:07:21 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-23 10:06:02 +0200 |
| commit | f604406453f95c82c3e5e4294a51245661868bbe (patch) | |
| tree | 6282cc3eb3164ddd94052175f872c8fc2ee2f623 /src/components/modals/custom-components/NewExperimentModalComponent.js | |
| parent | 7151ae60cf587a502a7e09d19ebd0fd33e761bf2 (diff) | |
First attempt at experiment list UI
Diffstat (limited to 'src/components/modals/custom-components/NewExperimentModalComponent.js')
| -rw-r--r-- | src/components/modals/custom-components/NewExperimentModalComponent.js | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/src/components/modals/custom-components/NewExperimentModalComponent.js b/src/components/modals/custom-components/NewExperimentModalComponent.js new file mode 100644 index 00000000..9efccc8a --- /dev/null +++ b/src/components/modals/custom-components/NewExperimentModalComponent.js @@ -0,0 +1,87 @@ +import PropTypes from "prop-types"; +import React from "react"; +import Shapes from "../../../shapes"; +import Modal from "../Modal"; + +class NewExperimentModalComponent extends React.Component { + static propTypes = { + show: PropTypes.bool.isRequired, + paths: PropTypes.arrayOf(Shapes.Path), + schedulers: PropTypes.arrayOf(Shapes.Scheduler), + traces: PropTypes.arrayOf(Shapes.Trace), + callback: PropTypes.func.isRequired, + }; + + reset() { + this.textInput.value = ""; + this.pathSelect.selectedIndex = 0; + this.traceSelect.selectedIndex = 0; + this.schedulerSelect.selectedIndex = 0; + } + + onSubmit() { + this.props.callback(this.textInput.value, this.pathSelect.value, this.traceSelect.value, + this.schedulerSelect.value); + this.reset(); + } + + onCancel() { + this.props.callback(undefined); + this.reset(); + } + + render() { + return ( + <Modal title="New Experiment" + show={this.props.show} + onSubmit={this.onSubmit.bind(this)} + onCancel={this.onCancel.bind(this)}> + <form onSubmit={e => { + e.preventDefault(); + this.onSubmit(); + }}> + <div className="form-group"> + <label className="form-control-label">Name:</label> + <input type="text" className="form-control" + ref={textInput => this.textInput = textInput}/> + </div> + <div className="form-group"> + <label className="form-control-label">Path:</label> + <select className="form-control" + ref={pathSelect => this.pathSelect = pathSelect}> + {this.props.paths.map(path => ( + <option value={path.id} key={path.id}> + {path.name} + </option> + ))} + </select> + </div> + <div className="form-group"> + <label className="form-control-label">Trace:</label> + <select className="form-control" + ref={traceSelect => this.traceSelect = traceSelect}> + {this.props.traces.map(trace => ( + <option value={trace.id} key={trace.id}> + {trace.name} + </option> + ))} + </select> + </div> + <div className="form-group"> + <label className="form-control-label">Scheduler:</label> + <select className="form-control" + ref={schedulerSelect => this.schedulerSelect = schedulerSelect}> + {this.props.schedulers.map(scheduler => ( + <option value={scheduler.name} key={scheduler.name}> + {scheduler.name} + </option> + ))} + </select> + </div> + </form> + </Modal> + ); + } +} + +export default NewExperimentModalComponent; |
