sebdet | 1e2760e | 2021-02-26 19:14:03 +0100 | [diff] [blame] | 1 | /*- |
| 2 | * ============LICENSE_START======================================================= |
| 3 | * ONAP POLICY-CLAMP |
| 4 | * ================================================================================ |
| 5 | * Copyright (C) 2021 AT&T Intellectual Property. All rights |
| 6 | * reserved. |
| 7 | * ================================================================================ |
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | * you may not use this file except in compliance with the License. |
| 10 | * You may obtain a copy of the License at |
| 11 | * |
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | * |
| 14 | * Unless required by applicable law or agreed to in writing, software |
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | * See the License for the specific language governing permissions and |
| 18 | * limitations under the License. |
| 19 | * ============LICENSE_END============================================ |
| 20 | * =================================================================== |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | import React from 'react' |
| 25 | import PolicyToscaService from '../../../api/PolicyToscaService'; |
| 26 | import styled from 'styled-components'; |
| 27 | import Button from 'react-bootstrap/Button'; |
| 28 | |
sebdet | 42fa9f4 | 2021-03-26 18:31:08 +0100 | [diff] [blame] | 29 | const ToscaDiv = styled.div` |
sebdet | 1e2760e | 2021-02-26 19:14:03 +0100 | [diff] [blame] | 30 | background-color: ${props => props.theme.toscaTextareaBackgroundColor}; |
| 31 | text-align: justify; |
| 32 | font-size: ${props => props.theme.toscaTextareaFontSize}; |
| 33 | width: 100%; |
| 34 | height: 30%; |
| 35 | ` |
| 36 | |
| 37 | export default class ToscaViewer extends React.Component { |
| 38 | |
| 39 | state = { |
| 40 | toscaData: this.props.toscaData, |
| 41 | yamlPolicyTosca: this.getToscaModelYamlFor(this.props.toscaData), |
| 42 | } |
| 43 | |
| 44 | constructor(props, context) { |
| 45 | super(props, context); |
| 46 | this.getToscaModelYamlFor = this.getToscaModelYamlFor.bind(this); |
| 47 | } |
| 48 | |
| 49 | getToscaModelYamlFor(toscaData) { |
| 50 | PolicyToscaService.getToscaPolicyModelYaml(toscaData["policyModelType"], toscaData["version"]).then(respYamlPolicyTosca => { |
| 51 | this.setState({ |
| 52 | yamlPolicyTosca: respYamlPolicyTosca, |
| 53 | }) |
| 54 | }); |
| 55 | } |
| 56 | |
| 57 | render() { |
| 58 | return ( |
sebdet | 42fa9f4 | 2021-03-26 18:31:08 +0100 | [diff] [blame] | 59 | <ToscaDiv> |
sebdet | 1e2760e | 2021-02-26 19:14:03 +0100 | [diff] [blame] | 60 | <pre>{this.state.yamlPolicyTosca}</pre> |
| 61 | <Button variant="secondary" title="Create a new policy version from the defined parameters" |
| 62 | onClick={this.handleCreateNewVersion}>Create New Version</Button> |
sebdet | 42fa9f4 | 2021-03-26 18:31:08 +0100 | [diff] [blame] | 63 | </ToscaDiv> |
sebdet | 1e2760e | 2021-02-26 19:14:03 +0100 | [diff] [blame] | 64 | ); |
| 65 | } |
| 66 | } |