X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ui-react%2Fsrc%2Fcomponents%2Fdialogs%2FLoop%2FCreateLoopModal.js;h=a8e8dee1fbe72f1376ccdf60c6eaed91b1f5ebf1;hb=c0ec0fc448af1c5d6eacb195e95938c921ba1bce;hp=e98b595663aa98d602e04037e097644671bf7c02;hpb=061ecec6a6099ad7fb480b0fe67f6e5154f9db23;p=clamp.git diff --git a/ui-react/src/components/dialogs/Loop/CreateLoopModal.js b/ui-react/src/components/dialogs/Loop/CreateLoopModal.js index e98b5956..a8e8dee1 100644 --- a/ui-react/src/components/dialogs/Loop/CreateLoopModal.js +++ b/ui-react/src/components/dialogs/Loop/CreateLoopModal.js @@ -30,46 +30,33 @@ import Col from 'react-bootstrap/Col'; import styled from 'styled-components'; import LoopService from '../../../api/LoopService'; import TemplateService from '../../../api/TemplateService'; +import LoopCache from '../../../api/LoopCache'; +import SvgGenerator from '../../loop_viewer/svg/SvgGenerator'; const ModalStyled = styled(Modal)` background-color: transparent; ` -const LoopViewSvgDivStyled = styled.svg` - display: flex; - flex-direction: row; - overflow-x: scroll; - background-color: ${props => (props.theme.loopViewerBackgroundColor)}; - border-color: ${props => (props.theme.loopViewerHeaderColor)}; - margin-top: 3em; - margin-left: auto; - margin-right:auto; - margin-bottom: -1em; - text-align: center; - align-items: center; - height: 100%; - width: 100%; -` export default class CreateLoopModal extends React.Component { constructor(props, context) { super(props, context); - this.getTemplateNames = this.getTemplateNames.bind(this); + this.getAllLoopTemplates = this.getAllLoopTemplates.bind(this); this.handleCreate = this.handleCreate.bind(this); this.handleModelName = this.handleModelName.bind(this); this.handleClose = this.handleClose.bind(this); - this.handleDropdownListChange = this.handleDropdownListChange.bind(this); + this.handleDropDownListChange = this.handleDropDownListChange.bind(this); this.state = { show: true, - content: '', chosenTemplateName: '', modelName: '', - templateNames: [] + templateNames: [], + fakeLoopCacheWithTemplate: new LoopCache({}) }; } componentWillMount() { - this.getTemplateNames(); + this.getAllLoopTemplates(); } handleClose() { @@ -77,21 +64,26 @@ export default class CreateLoopModal extends React.Component { this.props.history.push('/'); } - handleDropdownListChange(e) { - this.setState({ chosenTemplateName: e.value }); - TemplateService.getBlueprintMicroServiceTemplateSvg(e.value).then(svgXml => { - if (svgXml.length !== 0) { - this.setState({ content: svgXml }) - } else { - this.setState({ content: 'Error1' }) - } - }) + handleDropDownListChange(e) { + if (typeof e.value !== "undefined") { + this.setState({ + fakeLoopCacheWithTemplate: + new LoopCache({ + "loopTemplate":e.templateObject, + "name": "fakeLoop" + }), + chosenTemplateName: e.value + }) + } else { + this.setState({ fakeLoopCacheWithTemplate: new LoopCache({}) }) + } } - getTemplateNames() { - TemplateService.getTemplateNames().then(templateNames => { - const templateOptions = templateNames.map((templateName) => { return { label: templateName, value: templateName } }); - this.setState({ templateNames: templateOptions }) + getAllLoopTemplates() { + TemplateService.getAllLoopTemplates().then(templatesData => { + const templateOptions = templatesData.map((templateData) => { return { label: templateData.name, value: templateData.name, templateObject: templateData } }); + this.setState({ + templateNames: templateOptions }) }); } @@ -133,17 +125,15 @@ export default class CreateLoopModal extends React.Component { Template Name: - - - Model Preview: - - - - - + + Model Preview: + + + + Model Name: