aboutsummaryrefslogtreecommitdiffstats
path: root/ui-react/src/components/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'ui-react/src/components/dialogs')
-rw-r--r--ui-react/src/components/dialogs/Loop/ModifyLoopModal.js187
-rw-r--r--ui-react/src/components/dialogs/Loop/OpenLoopModal.js9
-rw-r--r--ui-react/src/components/dialogs/Tosca/UploadToscaPolicyModal.js26
-rw-r--r--ui-react/src/components/dialogs/Tosca/ViewLoopTemplatesModal.js4
-rw-r--r--ui-react/src/components/dialogs/Tosca/ViewToscaPolicyModal.js10
-rw-r--r--ui-react/src/components/dialogs/Tosca/__snapshots__/UploadToscaPolicyModal.test.js.snap6
6 files changed, 212 insertions, 30 deletions
diff --git a/ui-react/src/components/dialogs/Loop/ModifyLoopModal.js b/ui-react/src/components/dialogs/Loop/ModifyLoopModal.js
new file mode 100644
index 000000000..4cd21fdb5
--- /dev/null
+++ b/ui-react/src/components/dialogs/Loop/ModifyLoopModal.js
@@ -0,0 +1,187 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+import React, { forwardRef } from 'react'
+import MaterialTable from "material-table";
+import Button from 'react-bootstrap/Button';
+import Modal from 'react-bootstrap/Modal';
+import styled from 'styled-components';
+import PolicyToscaService from '../../../api/PolicyToscaService';
+import ArrowUpward from '@material-ui/icons/ArrowUpward';
+import ChevronLeft from '@material-ui/icons/ChevronLeft';
+import ChevronRight from '@material-ui/icons/ChevronRight';
+import Clear from '@material-ui/icons/Clear';
+import FirstPage from '@material-ui/icons/FirstPage';
+import LastPage from '@material-ui/icons/LastPage';
+import Search from '@material-ui/icons/Search';
+import LoopService from '../../../api/LoopService';
+
+
+const ModalStyled = styled(Modal)`
+ background-color: transparent;
+`
+const TextModal = styled.textarea`
+ margin-top: 20px;
+ white-space:pre;
+ background-color: ${props => props.theme.toscaTextareaBackgroundColor};
+ text-align: justify;
+ font-size: ${props => props.theme.toscaTextareaFontSize};
+ width: 100%;
+ height: 300px;
+`
+const cellStyle = { border: '1px solid black' };
+const headerStyle = { backgroundColor: '#ddd', border: '2px solid black' };
+const rowHeaderStyle = {backgroundColor:'#ddd', fontSize: '15pt', text: 'bold', border: '1px solid black'};
+
+export default class ModifyLoopModal extends React.Component {
+
+ state = {
+ show: true,
+ loopCache: this.props.loopCache,
+ content: 'Please select Tosca model to view the details',
+ selectedRowData: {},
+ toscaPolicyModelsData: [],
+ toscaColumns: [
+ { title: "#", field: "index", render: rowData => rowData.tableData.id + 1,
+ cellStyle: cellStyle,
+ headerStyle: headerStyle
+ },
+ { title: "Policy Model Type", field: "policyModelType",
+ cellStyle: cellStyle,
+ headerStyle: headerStyle
+ },
+ { title: "Policy Acronym", field: "policyAcronym",
+ cellStyle: cellStyle,
+ headerStyle: headerStyle
+ },
+ { title: "Version", field: "version",
+ cellStyle: cellStyle,
+ headerStyle: headerStyle
+ },
+ { title: "Uploaded By", field: "updatedBy",
+ cellStyle: cellStyle,
+ headerStyle: headerStyle
+ },
+ { title: "Uploaded Date", field: "updatedDate", editable: 'never',
+ cellStyle: cellStyle,
+ headerStyle: headerStyle
+ },
+ { title: "Add", field: "updatedDate", editable: 'never',
+ cellStyle: cellStyle,
+ headerStyle: headerStyle
+ }
+ ],
+ tableIcons: {
+ FirstPage: forwardRef((props, ref) => <FirstPage {...props} ref={ref} />),
+ LastPage: forwardRef((props, ref) => <LastPage {...props} ref={ref} />),
+ NextPage: forwardRef((props, ref) => <ChevronRight {...props} ref={ref} />),
+ PreviousPage: forwardRef((props, ref) => <ChevronLeft {...props} ref={ref} />),
+ ResetSearch: forwardRef((props, ref) => <Clear {...props} ref={ref} />),
+ Search: forwardRef((props, ref) => <Search {...props} ref={ref} />),
+ SortArrow: forwardRef((props, ref) => <ArrowUpward {...props} ref={ref} />)
+ }
+ };
+
+ constructor(props, context) {
+ super(props, context);
+ this.handleClose = this.handleClose.bind(this);
+ this.getPolicyToscaModels = this.getToscaPolicyModels.bind(this);
+ this.handleYamlContent = this.handleYamlContent.bind(this);
+ this.getToscaPolicyModelYaml = this.getToscaPolicyModelYaml.bind(this);
+ this.handleAdd = this.handleAdd.bind(this);
+ this.getToscaPolicyModels();
+ }
+
+ componentWillReceiveProps(newProps) {
+ this.setState({
+ loopCache: newProps.loopCache,
+ temporaryPropertiesJson: JSON.parse(JSON.stringify(newProps.loopCache.getGlobalProperties()))
+ });
+ }
+
+ getToscaPolicyModels() {
+ PolicyToscaService.getToscaPolicyModels().then(allToscaModels => {
+ this.setState({ toscaPolicyModelsData: allToscaModels});
+ });
+ }
+
+ getToscaPolicyModelYaml(policyModelType, policyModelVersion) {
+ if (typeof policyModelType !== "undefined") {
+ PolicyToscaService.getToscaPolicyModelYaml(policyModelType, policyModelVersion).then(toscaYaml => {
+ if (toscaYaml.length !== 0) {
+ this.setState({content: toscaYaml})
+ } else {
+ this.setState({ content: 'No Tosca model Yaml available' })
+ }
+ });
+ } else {
+ this.setState({ content: 'Please select Tosca model to view the details' })
+ }
+ }
+
+ handleYamlContent(event) {
+ this.setState({ content: event.target.value });
+ }
+
+ handleClose() {
+ this.setState({ show: false });
+ this.props.history.push('/');
+ }
+
+ handleAdd() {
+ LoopService.addOperationalPolicyType(this.state.loopCache.getLoopName(),this.state.selectedRowData.policyModelType,this.state.selectedRowData.version);
+ this.handleClose();
+ this.props.loadLoopFunction(this.state.loopCache.getLoopName());
+ }
+
+ render() {
+ return (
+ <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose}>
+ <Modal.Header closeButton>
+ </Modal.Header>
+ <Modal.Body>
+ <MaterialTable
+ title={"View Tosca Policy Models"}
+ data={this.state.toscaPolicyModelsData}
+ columns={this.state.toscaColumns}
+ icons={this.state.tableIcons}
+ onRowClick={(event, rowData) => {this.getToscaPolicyModelYaml(rowData.policyModelType, rowData.version);this.setState({selectedRowData: rowData})}}
+ options={{
+ headerStyle: rowHeaderStyle,
+ rowStyle: rowData => ({
+ backgroundColor: (this.state.selectedRowData !== {} && this.state.selectedRowData.id === rowData.tableData.id) ? '#EEE' : '#FFF'
+ })
+ }}
+ />
+ <div>
+ <TextModal value={this.state.content} onChange={this.handleYamlContent}/>
+ </div>
+ </Modal.Body>
+ <Modal.Footer>
+ <Button variant="secondary" type="null" onClick={this.handleClose}>Cancel</Button>
+ <Button variant="primary" type="submit" onClick={this.handleAdd}>Add</Button>
+ </Modal.Footer>
+ </ModalStyled>
+ );
+ }
+}
diff --git a/ui-react/src/components/dialogs/Loop/OpenLoopModal.js b/ui-react/src/components/dialogs/Loop/OpenLoopModal.js
index fbfc727eb..4e8d97820 100644
--- a/ui-react/src/components/dialogs/Loop/OpenLoopModal.js
+++ b/ui-react/src/components/dialogs/Loop/OpenLoopModal.js
@@ -68,15 +68,16 @@ export default class OpenLoopModal extends React.Component {
getLoopNames() {
LoopService.getLoopNames().then(loopNames => {
- const loopOptions = loopNames.map((loopName) => { return { label: loopName, value: loopName } });
- this.setState({ loopNames: loopOptions })
+ if (Object.entries(loopNames).length !== 0) {
+ const loopOptions = loopNames.filter(loopName => loopName!=='undefined').map((loopName) => { return { label: loopName, value: loopName } });
+ this.setState({ loopNames: loopOptions })
+ }
});
}
handleOpen() {
console.info("Loop " + this.state.chosenLoopName + " is chosen");
- this.setState({ show: false });
- this.props.history.push('/');
+ this.handleClose();
this.props.loadLoopFunction(this.state.chosenLoopName);
}
diff --git a/ui-react/src/components/dialogs/Tosca/UploadToscaPolicyModal.js b/ui-react/src/components/dialogs/Tosca/UploadToscaPolicyModal.js
index 76beca711..2e0460f61 100644
--- a/ui-react/src/components/dialogs/Tosca/UploadToscaPolicyModal.js
+++ b/ui-react/src/components/dialogs/Tosca/UploadToscaPolicyModal.js
@@ -28,7 +28,7 @@ import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
import styled from 'styled-components';
import Alert from 'react-bootstrap/Alert';
-import TemplateMenuService from '../../../api/TemplateMenuService';
+import PolicyToscaService from '../../../api/PolicyToscaService';
const ModalStyled = styled(Modal)`
background-color: transparent;
@@ -37,7 +37,7 @@ export default class UploadToscaPolicyModal extends React.Component {
constructor(props, context) {
super(props, context);
- this.handleUploadToscaPolicyModel = this.handleUploadToscaPolicyModel.bind(this);
+ this.handleCreateFromToscaPolicyModel = this.handleCreateFromToscaPolicyModel.bind(this);
this.handleClose = this.handleClose.bind(this);
this.handlePolicyModelType = this.handlePolicyModelType.bind(this);
this.fileSelectedHandler = this.fileSelectedHandler.bind(this);
@@ -55,16 +55,10 @@ export default class UploadToscaPolicyModal extends React.Component {
fileSelectedHandler = (event) => {
if (event.target.files && event.target.files[0]) {
const scope = this;
- let reader = new FileReader();
+ let reader = new FileReader();
this.setState({policyModelType: '', policyModelTosca: '' });
reader.onload = function(e) {
- var lines = reader.result.split('\n');
- for (var line = 0; line < lines.length; line++) {
- if(lines[line].trim().slice(0, 24) === 'onap.policies.monitoring') {
- var microsvc = lines[line].trim().slice(0, -1);
- scope.setState({ policyModelType: microsvc, policyModelTosca: reader.result});
- }
- }
+ scope.setState({ policyModelTosca: reader.result});
};
console.log("Filename is", event.target.files[0]);
reader.readAsText(event.target.files[0]);
@@ -77,11 +71,11 @@ export default class UploadToscaPolicyModal extends React.Component {
this.props.history.push('/');
}
- handleUploadToscaPolicyModel(e) {
- e.preventDefault();
+ handleCreateFromToscaPolicyModel(e) {
+ e.preventDefault();
console.log("Policy Model Type is", this.state.policyModelType);
if(this.state.policyModelType && this.state.policyModelTosca) {
- TemplateMenuService.uploadToscaPolicyModal(this.state.policyModelType, this.state.policyModelTosca).then(resp => {
+ PolicyToscaService.createPolicyModelFromToscaModel(this.state.policyModelType, this.state.policyModelTosca).then(resp => {
if(resp.status === 200) {
this.setState({apiResponseStatus: resp.status, apiResponseMessage: resp.message, upldBtnClicked: true});
} else {
@@ -103,7 +97,7 @@ export default class UploadToscaPolicyModal extends React.Component {
return (
<ModalStyled size="lg" show={this.state.show} onHide={this.handleClose}>
<Modal.Header closeButton>
- <Modal.Title>Upload Tosca Modal</Modal.Title>
+ <Modal.Title>Upload Tosca Model</Modal.Title>
</Modal.Header>
<Modal.Body>
<Form.Group as={Row} controlId="formPlaintextEmail">
@@ -114,7 +108,7 @@ export default class UploadToscaPolicyModal extends React.Component {
<Alert variant="secondary">
<p>{this.state.selectedFile.name}</p>
</Alert>
- <Form.Label column sm="2">Micro Service Name:</Form.Label>
+ <Form.Label column sm="2">Policy Model Type:</Form.Label>
<input type="text" style={{width: '50%'}}
value={this.state.policyModelType}
onChange={this.handlePolicyModelType}
@@ -124,7 +118,7 @@ export default class UploadToscaPolicyModal extends React.Component {
</Modal.Body>
<Modal.Footer>
{!this.state.apiResponseStatus?<Button variant="secondary" type="null" onClick={this.handleClose}>Cancel</Button>:""}
- {!this.state.apiResponseStatus?<Button disabled={!this.state.selectedFile.name || this.state.upldBtnClicked} variant="primary" type="submit" onClick={this.handleUploadToscaPolicyModel.bind(this)}>Upload</Button>:""}
+ {!this.state.apiResponseStatus?<Button disabled={!this.state.selectedFile.name || this.state.upldBtnClicked} variant="primary" type="submit" onClick={this.handleCreateFromToscaPolicyModel.bind(this)}>Create</Button>:""}
{this.state.apiResponseStatus?<Alert variant={this.state.apiResponseStatus === 200?"success":"danger"}>
<p>{this.state.apiResponseMessage}</p>
<Button onClick={this.handleClose} variant={this.state.apiResponseStatus === 200?"outline-success":"danger"}>
diff --git a/ui-react/src/components/dialogs/Tosca/ViewLoopTemplatesModal.js b/ui-react/src/components/dialogs/Tosca/ViewLoopTemplatesModal.js
index a78d454ff..89e5697c9 100644
--- a/ui-react/src/components/dialogs/Tosca/ViewLoopTemplatesModal.js
+++ b/ui-react/src/components/dialogs/Tosca/ViewLoopTemplatesModal.js
@@ -25,7 +25,7 @@ import React, { forwardRef } from 'react'
import Button from 'react-bootstrap/Button';
import Modal from 'react-bootstrap/Modal';
import styled from 'styled-components';
-import TemplateMenuService from '../../../api/TemplateMenuService';
+import TemplateService from '../../../api/TemplateService';
import ArrowUpward from '@material-ui/icons/ArrowUpward';
import ChevronLeft from '@material-ui/icons/ChevronLeft';
import ChevronRight from '@material-ui/icons/ChevronRight';
@@ -103,7 +103,7 @@ export default class ViewLoopTemplatesModal extends React.Component {
}
getBlueprintMicroServiceTemplates() {
- TemplateMenuService.getBlueprintMicroServiceTemplates().then(loopTemplateData => {
+ TemplateService.getBlueprintMicroServiceTemplates().then(loopTemplateData => {
this.setState({ loopTemplateData: loopTemplateData })
});
}
diff --git a/ui-react/src/components/dialogs/Tosca/ViewToscaPolicyModal.js b/ui-react/src/components/dialogs/Tosca/ViewToscaPolicyModal.js
index 5b66a25c0..650080520 100644
--- a/ui-react/src/components/dialogs/Tosca/ViewToscaPolicyModal.js
+++ b/ui-react/src/components/dialogs/Tosca/ViewToscaPolicyModal.js
@@ -26,7 +26,7 @@ import MaterialTable from "material-table";
import Button from 'react-bootstrap/Button';
import Modal from 'react-bootstrap/Modal';
import styled from 'styled-components';
-import TemplateMenuService from '../../../api/TemplateMenuService';
+import PolicyToscaService from '../../../api/PolicyToscaService';
import ArrowUpward from '@material-ui/icons/ArrowUpward';
import ChevronLeft from '@material-ui/icons/ChevronLeft';
import ChevronRight from '@material-ui/icons/ChevronRight';
@@ -109,14 +109,14 @@ export default class ViewToscalPolicyModal extends React.Component {
}
getToscaPolicyModels() {
- TemplateMenuService.getToscaPolicyModels().then(toscaPolicyModelNames => {
+ PolicyToscaService.getToscaPolicyModels().then(toscaPolicyModelNames => {
this.setState({ toscaPolicyModelNames: toscaPolicyModelNames });
});
}
- getToscaPolicyModelYaml(policyModelType) {
+ getToscaPolicyModelYaml(policyModelType, policyModelVersion) {
if (typeof policyModelType !== "undefined") {
- TemplateMenuService.getToscaPolicyModelYaml(policyModelType).then(toscaYaml => {
+ PolicyToscaService.getToscaPolicyModelYaml(policyModelType, policyModelVersion).then(toscaYaml => {
if (toscaYaml.length !== 0) {
this.setState({content: toscaYaml})
} else {
@@ -148,7 +148,7 @@ export default class ViewToscalPolicyModal extends React.Component {
data={this.state.toscaPolicyModelNames}
columns={this.state.toscaColumns}
icons={this.state.tableIcons}
- onRowClick={(event, rowData) => {this.getToscaPolicyModelYaml(rowData.policyModelType);this.setState({selectedRow: rowData.tableData.id})}}
+ onRowClick={(event, rowData) => {this.getToscaPolicyModelYaml(rowData.policyModelType,rowData.version);this.setState({selectedRow: rowData.tableData.id})}}
options={{
headerStyle: rowHeaderStyle,
rowStyle: rowData => ({
diff --git a/ui-react/src/components/dialogs/Tosca/__snapshots__/UploadToscaPolicyModal.test.js.snap b/ui-react/src/components/dialogs/Tosca/__snapshots__/UploadToscaPolicyModal.test.js.snap
index 1b5cd82a8..8e801367b 100644
--- a/ui-react/src/components/dialogs/Tosca/__snapshots__/UploadToscaPolicyModal.test.js.snap
+++ b/ui-react/src/components/dialogs/Tosca/__snapshots__/UploadToscaPolicyModal.test.js.snap
@@ -11,7 +11,7 @@ exports[`Test Upload Tosca Policy Model Test handleMicroServiceName 1`] = `
closeLabel="Close"
>
<ModalTitle>
- Upload Tosca Modal
+ Upload Tosca Model
</ModalTitle>
</ModalHeader>
<ModalBody>
@@ -72,7 +72,7 @@ exports[`Test Upload Tosca Policy Model Test handleMicroServiceName 1`] = `
sm="2"
srOnly={false}
>
- Micro Service Name:
+ Policy Model Type:
</FormLabel>
<input
onChange={[Function]}
@@ -104,7 +104,7 @@ exports[`Test Upload Tosca Policy Model Test handleMicroServiceName 1`] = `
type="submit"
variant="primary"
>
- Upload
+ Create
</Button>
</ModalFooter>
</Styled(Bootstrap(Modal))>