summaryrefslogtreecommitdiffstats
path: root/ui-react/src/components/dialogs/Loop/OpenLoopModal.js
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2020-05-18 12:31:11 +0200
committersebdet <sebastien.determe@intl.att.com>2020-05-20 18:00:03 +0200
commitc0ec0fc448af1c5d6eacb195e95938c921ba1bce (patch)
treef294596a5aa001f76fa4cd6f1a3c88d669fadd32 /ui-react/src/components/dialogs/Loop/OpenLoopModal.js
parent061ecec6a6099ad7fb480b0fe67f6e5154f9db23 (diff)
Create SVG in UI
Remove the SVG generation from the backend and put it in the UI Issue-ID: CLAMP-854 Signed-off-by: sebdet <sebastien.determe@intl.att.com> Change-Id: Icfa9e107d83bb244ac3d87300d013555bfa0b037
Diffstat (limited to 'ui-react/src/components/dialogs/Loop/OpenLoopModal.js')
-rw-r--r--ui-react/src/components/dialogs/Loop/OpenLoopModal.js45
1 files changed, 13 insertions, 32 deletions
diff --git a/ui-react/src/components/dialogs/Loop/OpenLoopModal.js b/ui-react/src/components/dialogs/Loop/OpenLoopModal.js
index c04883443..7ca90b493 100644
--- a/ui-react/src/components/dialogs/Loop/OpenLoopModal.js
+++ b/ui-react/src/components/dialogs/Loop/OpenLoopModal.js
@@ -30,6 +30,8 @@ import Col from 'react-bootstrap/Col';
import FormCheck from 'react-bootstrap/FormCheck'
import styled from 'styled-components';
import LoopService from '../../../api/LoopService';
+import SvgGenerator from '../../loop_viewer/svg/SvgGenerator';
+import LoopCache from '../../../api/LoopCache';
const ModalStyled = styled(Modal)`
background-color: transparent;
@@ -37,21 +39,6 @@ const ModalStyled = styled(Modal)`
const CheckBoxStyled = styled(FormCheck.Input)`
margin-left:3rem;
`
-const LoopViewSvgDivStyled = styled.svg`
- overflow-x: scroll;
- display: flex;
- flex-direction: row;
- background-color: ${props => (props.theme.loopViewerBackgroundColor)};
- border-color: ${props => (props.theme.loopViewerHeaderColor)};
- margin-top: 2em;
- margin-left: auto;
- margin-right:auto;
- margin-bottom: -3em;
- text-align: center;
- align-items: center;
- height: 100%;
- width: 100%;
-`
export default class OpenLoopModal extends React.Component {
constructor(props, context) {
@@ -60,13 +47,13 @@ export default class OpenLoopModal extends React.Component {
this.getLoopNames = this.getLoopNames.bind(this);
this.handleOpen = this.handleOpen.bind(this);
this.handleClose = this.handleClose.bind(this);
- this.handleDropdownListChange = this.handleDropdownListChange.bind(this);
+ this.handleDropDownListChange = this.handleDropDownListChange.bind(this);
this.showReadOnly = props.showReadOnly ? props.showReadOnly : true;
this.state = {
show: true,
chosenLoopName: '',
loopNames: [],
- content:''
+ loopCacheOpened: new LoopCache({})
};
}
@@ -79,14 +66,12 @@ export default class OpenLoopModal extends React.Component {
this.props.history.push('/');
}
- handleDropdownListChange(e) {
- this.setState({ chosenLoopName: e.value });
- LoopService.getSvg(e.value).then(svgXml => {
- if (svgXml.length !== 0) {
- this.setState({ content: svgXml })
- } else {
- this.setState({ content: 'Error1' })
- }
+ handleDropDownListChange(e) {
+ LoopService.getLoop(e.value).then(loop => {
+ this.setState({
+ chosenLoopName: e.value,
+ loopCacheOpened: new LoopCache(loop)
+ });
});
}
@@ -95,9 +80,7 @@ export default class OpenLoopModal extends React.Component {
if (Object.entries(loopNames).length !== 0) {
const loopOptions = loopNames.filter(loopName => loopName!=='undefined').map((loopName) => { return { label: loopName, value: loopName } });
this.setState({ loopNames: loopOptions })
-
}
-
});
}
@@ -117,20 +100,18 @@ export default class OpenLoopModal extends React.Component {
<Form.Group as={Row} controlId="formPlaintextEmail">
<Form.Label column sm="2">Model Name:</Form.Label>
<Col sm="10">
- <Select onChange={this.handleDropdownListChange}
+ <Select onChange={this.handleDropDownListChange}
options={this.state.loopNames} />
</Col>
</Form.Group>
<Form.Group as={Row} style={{alignItems: 'center'}} controlId="formSvgPreview">
<Form.Label column sm="2">Model Preview:</Form.Label>
<Col sm="10">
- <LoopViewSvgDivStyled dangerouslySetInnerHTML={{ __html: this.state.content }}
- value={this.state.content} >
- </LoopViewSvgDivStyled>
+ <SvgGenerator loopCache={this.state.loopCacheOpened} clickable={false} generatedFrom={SvgGenerator.GENERATED_FROM_INSTANCE}/>
</Col>
</Form.Group>
{this.showReadOnly === true ?
- <Form.Group as={Row} controlId="formBasicChecbox">
+ <Form.Group as={Row} controlId="formBasicCheckbox">
<Form.Check>
<FormCheck.Label>Read Only Mode:</FormCheck.Label>
<CheckBoxStyled style={{marginLeft: '3.5em'}} type="checkbox" />