xuegao | b09e7df | 2019-07-23 14:13:06 +0200 | [diff] [blame] | 1 | /*- |
| 2 | * ============LICENSE_START======================================================= |
| 3 | * ONAP CLAMP |
| 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 |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 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 | * =================================================================== |
| 20 | * |
| 21 | */ |
| 22 | |
| 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'; |
| 29 | |
| 30 | const ModalStyled = styled(Modal)` |
| 31 | background-color: transparent; |
| 32 | ` |
| 33 | |
| 34 | export default class LoopProperties extends React.Component { |
| 35 | |
sebdet | 8a02dd7 | 2019-07-31 17:11:11 +0200 | [diff] [blame^] | 36 | state = { |
| 37 | show: true, |
| 38 | loopCache: this.props.loopCache, |
| 39 | }; |
xuegao | b09e7df | 2019-07-23 14:13:06 +0200 | [diff] [blame] | 40 | |
| 41 | constructor(props, context) { |
| 42 | super(props, context); |
| 43 | |
| 44 | this.handleClose = this.handleClose.bind(this); |
sebdet | 8a02dd7 | 2019-07-31 17:11:11 +0200 | [diff] [blame^] | 45 | this.handleSave = this.handleSave.bind(this); |
| 46 | this.renderDcaeParameters = this.renderDcaeParameters.bind(this); |
| 47 | this.renderAllParameters = this.renderAllParameters.bind(this); |
| 48 | this.getDcaeParameters = this.getDcaeParameters.bind(this); |
| 49 | } |
| 50 | |
| 51 | componentWillReceiveProps(newProps) { |
| 52 | this.setState({ |
| 53 | loopCache: newProps.loopCache, |
| 54 | }); |
| 55 | } |
| 56 | |
| 57 | handleClose() { |
| 58 | this.props.history.push('/'); |
| 59 | } |
| 60 | |
| 61 | handleSave(event) { |
| 62 | // translate the deploymentParameter into jsonFormat at submit time |
xuegao | b09e7df | 2019-07-23 14:13:06 +0200 | [diff] [blame] | 63 | |
| 64 | } |
sebdet | 8a02dd7 | 2019-07-31 17:11:11 +0200 | [diff] [blame^] | 65 | |
| 66 | saveAllProperties() { |
| 67 | |
xuegao | b09e7df | 2019-07-23 14:13:06 +0200 | [diff] [blame] | 68 | } |
sebdet | 8a02dd7 | 2019-07-31 17:11:11 +0200 | [diff] [blame^] | 69 | |
| 70 | renderAllParameters() { |
| 71 | return (<Modal.Body> |
| 72 | <Form> |
| 73 | {this.renderDcaeParameters()} |
| 74 | </Form> |
| 75 | </Modal.Body> |
| 76 | ); |
xuegao | b09e7df | 2019-07-23 14:13:06 +0200 | [diff] [blame] | 77 | } |
sebdet | 8a02dd7 | 2019-07-31 17:11:11 +0200 | [diff] [blame^] | 78 | |
| 79 | getDcaeParameters() { |
| 80 | if (typeof (this.state.loopCache.getGlobalProperties()) !== "undefined") { |
| 81 | return JSON.stringify(this.state.loopCache.getGlobalProperties()["dcaeDeployParameters"]); |
| 82 | } else { |
| 83 | return ""; |
| 84 | } |
| 85 | |
xuegao | b09e7df | 2019-07-23 14:13:06 +0200 | [diff] [blame] | 86 | } |
sebdet | 8a02dd7 | 2019-07-31 17:11:11 +0200 | [diff] [blame^] | 87 | |
| 88 | renderDcaeParameters() { |
| 89 | return ( |
| 90 | <Form.Group > |
| 91 | <Form.Label>Deploy Parameters</Form.Label> |
| 92 | <Form.Control as="textarea" rows="3" name="dcaeDeployParameters">{this.getDcaeParameters()}</Form.Control> |
| 93 | </Form.Group> |
| 94 | ); |
| 95 | } |
| 96 | |
xuegao | b09e7df | 2019-07-23 14:13:06 +0200 | [diff] [blame] | 97 | render() { |
| 98 | return ( |
sebdet | 8a02dd7 | 2019-07-31 17:11:11 +0200 | [diff] [blame^] | 99 | <ModalStyled size="lg" show={this.state.show} onHide={this.handleClose} > |
xuegao | b09e7df | 2019-07-23 14:13:06 +0200 | [diff] [blame] | 100 | <Modal.Header closeButton> |
| 101 | <Modal.Title>Model Properties</Modal.Title> |
| 102 | </Modal.Header> |
sebdet | 8a02dd7 | 2019-07-31 17:11:11 +0200 | [diff] [blame^] | 103 | {this.renderAllParameters()} |
xuegao | b09e7df | 2019-07-23 14:13:06 +0200 | [diff] [blame] | 104 | <Modal.Footer> |
sebdet | 8a02dd7 | 2019-07-31 17:11:11 +0200 | [diff] [blame^] | 105 | <Button variant="secondary" type="null" onClick={this.handleClose}>Cancel</Button> |
| 106 | <Button variant="primary" type="submit" onClick={this.handleSave}>Save Changes</Button> |
xuegao | b09e7df | 2019-07-23 14:13:06 +0200 | [diff] [blame] | 107 | </Modal.Footer> |
| 108 | </ModalStyled> |
| 109 | ); |
| 110 | } |
| 111 | } |