summaryrefslogtreecommitdiff
path: root/frontend/src/components/modals/custom-components/NewExperimentModalComponent.js
diff options
context:
space:
mode:
authorGeorgios Andreadis <info@gandreadis.com>2020-06-29 15:47:09 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-08-24 16:08:41 +0200
commit90fae26aa4bd0e0eb3272ff6e6524060e9004fbb (patch)
treebf6943882f5fa5f3114c01fc571503c79ee1056d /frontend/src/components/modals/custom-components/NewExperimentModalComponent.js
parent7032a007d4431f5a0c4c5e2d3f3bd20462d49950 (diff)
Prepare frontend repository for monorepo
This change prepares the frontend Git repository for the monorepo residing at https://github.com/atlarge-research.com/opendc. To accomodate for this, we move all files into a frontend subdirectory.
Diffstat (limited to 'frontend/src/components/modals/custom-components/NewExperimentModalComponent.js')
-rw-r--r--frontend/src/components/modals/custom-components/NewExperimentModalComponent.js104
1 files changed, 104 insertions, 0 deletions
diff --git a/frontend/src/components/modals/custom-components/NewExperimentModalComponent.js b/frontend/src/components/modals/custom-components/NewExperimentModalComponent.js
new file mode 100644
index 00000000..e356fe96
--- /dev/null
+++ b/frontend/src/components/modals/custom-components/NewExperimentModalComponent.js
@@ -0,0 +1,104 @@
+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,
+ parseInt(this.pathSelect.value, 10),
+ parseInt(this.traceSelect.value, 10),
+ 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 ? path.name : "Path " + path.id}
+ </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;