2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END============================================
19 * ===================================================================
23 import React from 'react'
24 import Button from 'react-bootstrap/Button';
25 import Modal from 'react-bootstrap/Modal';
26 import Form from 'react-bootstrap/Form';
27 import styled from 'styled-components';
28 import LoopService from '../../api/LoopService';
30 const ModalStyled = styled(Modal)`
31 background-color: transparent;
34 export default class LoopProperties extends React.Component {
38 loopCache: this.props.loopCache,
39 temporaryPropertiesJson: JSON.parse(JSON.stringify(this.props.loopCache.getGlobalProperties())),
42 constructor(props, context) {
43 super(props, context);
45 this.handleClose = this.handleClose.bind(this);
46 this.handleSave = this.handleSave.bind(this);
47 this.handleChange = this.handleChange.bind(this);
49 this.renderDcaeParameters = this.renderDcaeParameters.bind(this);
50 this.renderAllParameters = this.renderAllParameters.bind(this);
51 this.getDcaeParameters = this.getDcaeParameters.bind(this);
54 componentWillReceiveProps(newProps) {
56 loopCache: newProps.loopCache,
57 temporaryPropertiesJson: JSON.parse(JSON.stringify(newProps.loopCache.getGlobalProperties())),
63 this.props.history.push('/');
67 LoopService.updateGlobalProperties(this.state.loopCache.getLoopName(), this.state.temporaryPropertiesJson).then(resp => {
68 this.setState({ show: false });
69 this.props.history.push('/');
70 this.props.loadLoopFunction(this.state.loopCache.getLoopName());
75 this.setState({temporaryPropertiesJson:{[event.target.name]: JSON.parse(event.target.value)}});
78 renderAllParameters() {
81 {this.renderDcaeParameters()}
88 if (typeof (this.state.temporaryPropertiesJson) !== "undefined") {
89 return JSON.stringify(this.state.temporaryPropertiesJson["dcaeDeployParameters"]);
96 renderDcaeParameters() {
99 <Form.Label>Deploy Parameters</Form.Label>
100 <Form.Control as="textarea" rows="3" name="dcaeDeployParameters" onChange={this.handleChange} defaultValue={this.getDcaeParameters()}></Form.Control>
107 <ModalStyled size="lg" show={this.state.show} onHide={this.handleClose} >
108 <Modal.Header closeButton>
109 <Modal.Title>Model Properties</Modal.Title>
111 {this.renderAllParameters()}
113 <Button variant="secondary" type="null" onClick={this.handleClose}>Cancel</Button>
114 <Button variant="primary" type="submit" onClick={this.handleSave}>Save Changes</Button>