blob: d150e39db4e2bba31df0753c7ddc056076a833e4 [file] [log] [blame]
sebdet1e2760e2021-02-26 19:14:03 +01001/*-
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
24import React from 'react'
25import PolicyToscaService from '../../../api/PolicyToscaService';
26import styled from 'styled-components';
27import Button from 'react-bootstrap/Button';
28
sebdet42fa9f42021-03-26 18:31:08 +010029const ToscaDiv = styled.div`
sebdet1e2760e2021-02-26 19:14:03 +010030 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
37export 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 (
sebdet42fa9f42021-03-26 18:31:08 +010059 <ToscaDiv>
sebdet1e2760e2021-02-26 19:14:03 +010060 <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>
sebdet42fa9f42021-03-26 18:31:08 +010063 </ToscaDiv>
sebdet1e2760e2021-02-26 19:14:03 +010064 );
65 }
66}