From 8aa174e70c01631ae4e00a6d208966fcd77cf972 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Fri, 10 Jul 2020 10:21:46 +0200 Subject: Add implementation of portfolio and scenario UI structure --- .../NewExperimentModalComponent.js | 105 -------------- .../NewPortfolioModalComponent.js | 99 +++++++++++++ .../custom-components/NewScenarioModalComponent.js | 155 +++++++++++++++++++++ 3 files changed, 254 insertions(+), 105 deletions(-) delete mode 100644 frontend/src/components/modals/custom-components/NewExperimentModalComponent.js create mode 100644 frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js create mode 100644 frontend/src/components/modals/custom-components/NewScenarioModalComponent.js (limited to 'frontend/src/components/modals/custom-components') diff --git a/frontend/src/components/modals/custom-components/NewExperimentModalComponent.js b/frontend/src/components/modals/custom-components/NewExperimentModalComponent.js deleted file mode 100644 index ce685837..00000000 --- a/frontend/src/components/modals/custom-components/NewExperimentModalComponent.js +++ /dev/null @@ -1,105 +0,0 @@ -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, - topologies: PropTypes.arrayOf(Shapes.Topology), - schedulers: PropTypes.arrayOf(Shapes.Scheduler), - traces: PropTypes.arrayOf(Shapes.Trace), - callback: PropTypes.func.isRequired, - } - - reset() { - this.textInput.value = '' - this.topologySelect.selectedIndex = 0 - this.traceSelect.selectedIndex = 0 - this.schedulerSelect.selectedIndex = 0 - } - - onSubmit() { - this.props.callback( - this.textInput.value, - this.topologySelect.value, - this.traceSelect.value, - this.schedulerSelect.value, - ) - this.reset() - } - - onCancel() { - this.props.callback(undefined) - this.reset() - } - - render() { - return ( - -
{ - e.preventDefault() - this.onSubmit() - }} - > -
- - (this.textInput = textInput)} - /> -
-
- - -
-
- - -
-
- - -
-
-
- ) - } -} - -export default NewExperimentModalComponent 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 ( + +
{ + e.preventDefault() + this.onSubmit() + }} + > +
+ + (this.textInput = textInput)} + /> +
+

Targets

+
Metrics
+
+ {AVAILABLE_METRICS.map(metric => ( +
+ +
+ ))} +
+
+ + (this.repeatsInput = repeatsInput)} + /> +
+
+
+ ) + } +} + +export default NewPortfolioModalComponent diff --git a/frontend/src/components/modals/custom-components/NewScenarioModalComponent.js b/frontend/src/components/modals/custom-components/NewScenarioModalComponent.js new file mode 100644 index 00000000..4c2df2f6 --- /dev/null +++ b/frontend/src/components/modals/custom-components/NewScenarioModalComponent.js @@ -0,0 +1,155 @@ +import PropTypes from 'prop-types' +import React from 'react' +import Shapes from '../../../shapes' +import Modal from '../Modal' + +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), + callback: PropTypes.func.isRequired, + } + + componentDidMount() { + this.reset() + } + + reset() { + this.textInput.value = '' + 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.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() + } + + onCancel() { + this.props.callback(undefined) + this.reset() + } + + render() { + return ( + +
{ + e.preventDefault() + this.onSubmit() + }} + > +
+ + (this.textInput = textInput)} + /> +
+

Trace

+
+ + +
+
+ + (this.traceLoadInput = traceLoadInput)} + /> +
+

Topology

+
+ + +
+

Operational Phenomena

+
+ +
+
+ +
+
+ + +
+
+
+ ) + } +} + +export default NewScenarioModalComponent -- cgit v1.2.3