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 --- .../custom-components/NewScenarioModalComponent.js | 155 +++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 frontend/src/components/modals/custom-components/NewScenarioModalComponent.js (limited to 'frontend/src/components/modals/custom-components/NewScenarioModalComponent.js') 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