diff options
| author | Georgios Andreadis <info@gandreadis.com> | 2020-07-10 10:24:31 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-08-24 19:48:01 +0200 |
| commit | 3b4e27320c479bd6ef48998f448ed070e8bd7511 (patch) | |
| tree | 35ec6527e8d7a0b4093e18c8cb501c293a18b5eb /frontend/src/components/modals/custom-components | |
| parent | b30906bbe0d5f343b337a80de1b4b70ebf288331 (diff) | |
| parent | 8aa174e70c01631ae4e00a6d208966fcd77cf972 (diff) | |
Merge pull request #8 from atlarge-research/feature/portfolios-scenarios-frontend
Portfolios and scenarios on the frontend
Diffstat (limited to 'frontend/src/components/modals/custom-components')
| -rw-r--r-- | frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js | 99 | ||||
| -rw-r--r-- | frontend/src/components/modals/custom-components/NewScenarioModalComponent.js (renamed from frontend/src/components/modals/custom-components/NewExperimentModalComponent.js) | 86 |
2 files changed, 167 insertions, 18 deletions
diff --git a/frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js b/frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js new file mode 100644 index 00000000..ace2d751 --- /dev/null +++ b/frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js @@ -0,0 +1,99 @@ +import PropTypes from 'prop-types' +import React from 'react' +import Modal from '../Modal' +import { AVAILABLE_METRICS } from '../../../util/available-metrics' + +class NewPortfolioModalComponent extends React.Component { + static propTypes = { + show: PropTypes.bool.isRequired, + callback: PropTypes.func.isRequired, + } + + constructor(props) { + super(props) + this.metricCheckboxes = {} + } + + componentDidMount() { + this.reset() + } + + reset() { + this.textInput.value = '' + AVAILABLE_METRICS.forEach(metric => { + this.metricCheckboxes[metric].checked = true + }) + this.repeatsInput.value = 1 + } + + onSubmit() { + this.props.callback( + this.textInput.value, + { + enabledMetrics: AVAILABLE_METRICS.filter(metric => this.metricCheckboxes[metric].checked), + repeatsPerScenario: parseInt(this.repeatsInput.value), + }, + ) + this.reset() + } + + onCancel() { + this.props.callback(undefined) + this.reset() + } + + render() { + return ( + <Modal + title="New Portfolio" + 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" + required + ref={textInput => (this.textInput = textInput)} + /> + </div> + <h4>Targets</h4> + <h5>Metrics</h5> + <div className="form-group"> + {AVAILABLE_METRICS.map(metric => ( + <div className="form-check" key={metric}> + <label className="form-check-label"> + <input + type="checkbox" + className="form-check-input" + ref={checkbox => (this.metricCheckboxes[metric] = checkbox)} + /> + <code>{metric}</code> + </label> + </div> + ))} + </div> + <div className="form-group"> + <label className="form-control-label">Repeats per scenario</label> + <input + type="number" + className="form-control" + required + ref={repeatsInput => (this.repeatsInput = repeatsInput)} + /> + </div> + </form> + </Modal> + ) + } +} + +export default NewPortfolioModalComponent diff --git a/frontend/src/components/modals/custom-components/NewExperimentModalComponent.js b/frontend/src/components/modals/custom-components/NewScenarioModalComponent.js index ce685837..4c2df2f6 100644 --- a/frontend/src/components/modals/custom-components/NewExperimentModalComponent.js +++ b/frontend/src/components/modals/custom-components/NewScenarioModalComponent.js @@ -3,28 +3,46 @@ import React from 'react' import Shapes from '../../../shapes' import Modal from '../Modal' -class NewExperimentModalComponent extends React.Component { +class NewScenarioModalComponent extends React.Component { static propTypes = { show: PropTypes.bool.isRequired, + currentPortfolioId: PropTypes.string.isRequired, + traces: PropTypes.arrayOf(Shapes.Trace), topologies: PropTypes.arrayOf(Shapes.Topology), schedulers: PropTypes.arrayOf(Shapes.Scheduler), - traces: PropTypes.arrayOf(Shapes.Trace), callback: PropTypes.func.isRequired, } + componentDidMount() { + this.reset() + } + reset() { this.textInput.value = '' - this.topologySelect.selectedIndex = 0 this.traceSelect.selectedIndex = 0 + this.traceLoadInput.value = 1.0 + this.topologySelect.selectedIndex = 0 + this.failuresCheckbox.checked = false + this.performanceInterferenceCheckbox.checked = false this.schedulerSelect.selectedIndex = 0 } onSubmit() { this.props.callback( this.textInput.value, - this.topologySelect.value, - this.traceSelect.value, - this.schedulerSelect.value, + this.props.currentPortfolioId, + { + traceId: this.traceSelect.value, + loadSamplingFraction: parseFloat(this.traceLoadInput.value), + }, + { + topologyId: this.topologySelect.value + }, + { + failuresEnabled: this.failuresCheckbox.checked, + performanceInterferenceEnabled: this.performanceInterferenceCheckbox.checked, + schedulerName: this.schedulerSelect.value, + }, ) this.reset() } @@ -37,7 +55,7 @@ class NewExperimentModalComponent extends React.Component { render() { return ( <Modal - title="New Experiment" + title="New Scenario" show={this.props.show} onSubmit={this.onSubmit.bind(this)} onCancel={this.onCancel.bind(this)} @@ -57,32 +75,64 @@ class NewExperimentModalComponent extends React.Component { ref={textInput => (this.textInput = textInput)} /> </div> + <h4>Trace</h4> <div className="form-group"> - <label className="form-control-label">Topology</label> + <label className="form-control-label">Trace</label> <select className="form-control" - ref={topologySelect => (this.topologySelect = topologySelect)} + ref={traceSelect => (this.traceSelect = traceSelect)} > - {this.props.topologies.map(topology => ( - <option value={topology._id} key={topology._id}> - {topology.name} + {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">Trace</label> + <label className="form-control-label">Load sampling fraction</label> + <input + type="number" + className="form-control" + required + ref={traceLoadInput => (this.traceLoadInput = traceLoadInput)} + /> + </div> + <h4>Topology</h4> + <div className="form-group"> + <label className="form-control-label">Topology</label> <select className="form-control" - ref={traceSelect => (this.traceSelect = traceSelect)} + ref={topologySelect => (this.topologySelect = topologySelect)} > - {this.props.traces.map(trace => ( - <option value={trace._id} key={trace._id}> - {trace.name} + {this.props.topologies.map(topology => ( + <option value={topology._id} key={topology._id}> + {topology.name} </option> ))} </select> </div> + <h4>Operational Phenomena</h4> + <div className="form-check"> + <label className="form-check-label"> + <input + type="checkbox" + className="form-check-input" + ref={failuresCheckbox => (this.failuresCheckbox = failuresCheckbox)} + /> + <span className="ml-2">Enable failures</span> + </label> + </div> + <div className="form-check"> + <label className="form-check-label"> + <input + type="checkbox" + className="form-check-input" + ref={performanceInterferenceCheckbox => (this.performanceInterferenceCheckbox = performanceInterferenceCheckbox)} + /> + <span className="ml-2">Enable performance interference</span> + </label> + </div> <div className="form-group"> <label className="form-control-label">Scheduler</label> <select @@ -102,4 +152,4 @@ class NewExperimentModalComponent extends React.Component { } } -export default NewExperimentModalComponent +export default NewScenarioModalComponent |
