aboutsummaryrefslogtreecommitdiffstats
path: root/gui-clamp
diff options
context:
space:
mode:
Diffstat (limited to 'gui-clamp')
-rw-r--r--gui-clamp/ui-react-lib/libIndex.js8
-rw-r--r--gui-clamp/ui-react/src/LoopUI.js4
-rw-r--r--gui-clamp/ui-react/src/api/ControlLoopService.js34
-rw-r--r--gui-clamp/ui-react/src/api/GetToscaTemplate.js56
-rw-r--r--gui-clamp/ui-react/src/api/UploadToscaFile.js63
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetLocalToscaFileForUpload.js (renamed from gui-clamp/ui-react/src/components/dialogs/GetLocalToscaFileForUpload.js)43
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetLocalToscaFileForUpload.test.js (renamed from gui-clamp/ui-react/src/components/dialogs/GetLocalToscaFileForUpload.test.js)34
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.js50
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.test.js (renamed from gui-clamp/ui-react/src/api/GetToscaTemplate.test.js)34
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.js96
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.test.js (renamed from gui-clamp/ui-react/src/components/dialogs/ReadAndConvertYaml.test.js)34
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/ControlLoop/UploadToscaFile.js54
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/ControlLoop/UploadToscaFile.test.js (renamed from gui-clamp/ui-react/src/api/UploadToscaFile.test.js)34
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/GetLocalToscaFileForUpload.test.js.snap (renamed from gui-clamp/ui-react/src/components/dialogs/__snapshots__/GetLocalToscaFileForUpload.test.js.snap)0
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/GetToscaTemplate.test.js.snap (renamed from gui-clamp/ui-react/src/api/__snapshots__/GetToscaTemplate.test.js.snap)0
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/ReadAndConvertYaml.test.js.snap (renamed from gui-clamp/ui-react/src/components/dialogs/__snapshots__/ReadAndConvertYaml.test.js.snap)9
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/UploadToscaFile.test.js.snap (renamed from gui-clamp/ui-react/src/api/__snapshots__/UploadToscaFile.test.js.snap)0
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/ReadAndConvertYaml.js87
-rw-r--r--gui-clamp/ui-react/src/components/menu/MenuBar.js8
-rw-r--r--gui-clamp/ui-react/src/components/menu/__snapshots__/MenuBar.test.js.snap138
20 files changed, 407 insertions, 379 deletions
diff --git a/gui-clamp/ui-react-lib/libIndex.js b/gui-clamp/ui-react-lib/libIndex.js
index 21decbc..179b882 100644
--- a/gui-clamp/ui-react-lib/libIndex.js
+++ b/gui-clamp/ui-react-lib/libIndex.js
@@ -57,7 +57,7 @@ export { default as PoliciesTreeViewer } from '../ui-react/src/components/dialog
export { default as PolicyToscaFileSelector } from '../ui-react/src/components/dialogs/Policy/PolicyToscaFileSelector';
export { default as MonitoringControlLoopModal } from '../ui-react/src/components/dialogs/ControlLoop/MonitoringControlLoopModal';
export { default as ControlLoopService } from '../ui-react/src/api/ControlLoopService';
-export { default as GetLocalToscaFileForUpload } from '../ui-react/src/components/dialogs/GetLocalToscaFileForUpload';
-export { default as ReadAndConvertYaml } from '../ui-react/src/components/dialogs/ReadAndConvertYaml';
-export { default as UploadToscaFile } from '../ui-react/src/api/UploadToscaFile';
-export { default as GetToscaTemplate } from '../ui-react/src/api/GetToscaTemplate';
+export { default as GetLocalToscaFileForUpload } from '../ui-react/src/components/dialogs/ControlLoop/GetLocalToscaFileForUpload';
+export { default as ReadAndConvertYaml } from '../ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml';
+export { default as UploadToscaFile } from '../ui-react/src/components/dialogs/ControlLoop/UploadToscaFile';
+export { default as GetToscaTemplate } from '../ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate';
diff --git a/gui-clamp/ui-react/src/LoopUI.js b/gui-clamp/ui-react/src/LoopUI.js
index 4009bf1..752c89d 100644
--- a/gui-clamp/ui-react/src/LoopUI.js
+++ b/gui-clamp/ui-react/src/LoopUI.js
@@ -51,9 +51,9 @@ import Alert from 'react-bootstrap/Alert';
import Spinner from 'react-bootstrap/Spinner';
import { Link } from 'react-router-dom';
-import ReadAndConvertYaml from "./components/dialogs/ReadAndConvertYaml";
+import ReadAndConvertYaml from "./components/dialogs/ControlLoop/ReadAndConvertYaml";
import MonitoringControlLoopModal from "./components/dialogs/ControlLoop/MonitoringControlLoopModal";
-import GetLocalToscaFileForUpload from "./components/dialogs/GetLocalToscaFileForUpload";
+import GetLocalToscaFileForUpload from "./components/dialogs/ControlLoop/GetLocalToscaFileForUpload";
const StyledMainDiv = styled.div`
background-color: ${ props => props.theme.backgroundColor };
diff --git a/gui-clamp/ui-react/src/api/ControlLoopService.js b/gui-clamp/ui-react/src/api/ControlLoopService.js
index 5ef7529..1882f78 100644
--- a/gui-clamp/ui-react/src/api/ControlLoopService.js
+++ b/gui-clamp/ui-react/src/api/ControlLoopService.js
@@ -44,4 +44,38 @@ export default class ControlLoopService {
return undefined;
});
}
+
+ static async getToscaTemplate(name, version, windowLocationPathname) {
+ const params = {
+ name: name,
+ version: version
+ }
+
+ const response = await fetch(windowLocationPathname +
+ '/restservices/clds/v2/toscaControlLoop/getToscaTemplate' + '?' + (new URLSearchParams(params)));
+
+ if (!response.ok) {
+ const message = `An error has occurred: ${response.status}`;
+ throw new Error(message);
+ }
+
+ const data = await response;
+
+ return data;
+ }
+
+ static async uploadToscaFile(toscaObject, windowLocationPathName) {
+ const response = await fetch(windowLocationPathName +
+ '/restservices/clds/v2/toscaControlLoop/commissionToscaTemplate', {
+ method: 'POST',
+ headers: {
+ "Content-Type": "application/json"
+ },
+ credentials: 'same-origin',
+ body: JSON.stringify(toscaObject),
+ });
+
+ return response
+
+ }
}
diff --git a/gui-clamp/ui-react/src/api/GetToscaTemplate.js b/gui-clamp/ui-react/src/api/GetToscaTemplate.js
deleted file mode 100644
index d428491..0000000
--- a/gui-clamp/ui-react/src/api/GetToscaTemplate.js
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-import React, { useState } from "react";
-import Button from "react-bootstrap/Button";
-
-const GetToscaTemplate = (props) => {
-
- const [windowLocationPathName, setWindowLocationPathname] = useState('');
-
- const getTemplateHandler = async () => {
- console.log('getTemplateHandler called')
- setWindowLocationPathname(window.location.pathname);
-
- const params = {
- name: props.templateName,
- version: props.templateVersion
- }
-
- const response = await fetch(windowLocationPathName +
- '/restservices/clds/v2/toscaControlLoop/getToscaTemplate' + '?' + (new URLSearchParams(params)));
-
- const data = await response.json();
-
- props.onGetToscaServiceTemplate(data);
-
- }
-
- return (
- <React.Fragment>
- <Button variant="primary"
- type="submit"
- onClick={ getTemplateHandler }>Get Tosca Service Template</Button>
- </React.Fragment>
- );
-
-
-}
-
-export default GetToscaTemplate;
diff --git a/gui-clamp/ui-react/src/api/UploadToscaFile.js b/gui-clamp/ui-react/src/api/UploadToscaFile.js
deleted file mode 100644
index 4173e0d..0000000
--- a/gui-clamp/ui-react/src/api/UploadToscaFile.js
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * -
- * * ============LICENSE_START=======================================================
- * * Copyright (C) 2021 Nordix Foundation.
- * * ================================================================================
- * * 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.
- * *
- * * SPDX-License-Identifier: Apache-2.0
- * * ============LICENSE_END=========================================================
- *
- */
-import Button from "react-bootstrap/Button";
-import React, { useState } from "react";
-
-const UploadToscaFile = (props) => {
- const [windowLocationPathName, setWindowLocationPathname] = useState('');
-
- const postServiceTemplateHandler = async (event) => {
- event.preventDefault();
- console.log('postServiceTemplateHandler called');
- setWindowLocationPathname(window.location.pathname);
-
- const response = await fetch(windowLocationPathName +
- '/restservices/clds/v2/toscaControlLoop/commissionToscaTemplate', {
- method: 'POST',
- headers: {
- "Content-Type": "application/json"
- },
- credentials: 'same-origin',
- body: JSON.stringify(props.toscaObject),
- });
-
- const responseObj = await response;
- const responseMessage = await response.text();
-
- props.onResponseReceived(responseObj, responseMessage);
-
- }
-
- return (
- <React.Fragment>
- <Button variant="primary"
- block={ true }
- type="submit"
- onClick={ postServiceTemplateHandler }>
- Upload Tosca Service Template
- </Button>
- </React.Fragment>
- );
-
-};
-
-export default UploadToscaFile;
diff --git a/gui-clamp/ui-react/src/components/dialogs/GetLocalToscaFileForUpload.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetLocalToscaFileForUpload.js
index bac9953..013dd89 100644
--- a/gui-clamp/ui-react/src/components/dialogs/GetLocalToscaFileForUpload.js
+++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetLocalToscaFileForUpload.js
@@ -1,23 +1,20 @@
/*
- * -
- * * ============LICENSE_START=======================================================
- * * Copyright (C) 2021 Nordix Foundation.
- * * ================================================================================
- * * 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.
- * *
- * * SPDX-License-Identifier: Apache-2.0
- * * ============LICENSE_END=========================================================
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
*/
import React, { useState } from 'react';
@@ -28,7 +25,7 @@ import Row from 'react-bootstrap/Row';
import styled from 'styled-components';
import Alert from 'react-bootstrap/Alert';
import * as yaml from "js-yaml";
-import UploadToscaFile from "../../api/UploadToscaFile";
+import UploadToscaFile from "./UploadToscaFile";
const ModalStyled = styled(Modal)`
background-color: transparent;
@@ -82,9 +79,9 @@ const GetLocalToscaFileForUpload = (props) => {
}
};
- const receiveResponseFromUpload = (response, responseMessage) => {
+ const receiveResponseFromUpload = async (response) => {
- if (response.ok) {
+ if (await response.ok) {
setAlertMessages(<Alert variant="success">
<Alert.Heading>Upload Success</Alert.Heading>
<p>Tosca Service Template from { selectedFile.name } was Successfully Uploaded</p>
@@ -96,8 +93,8 @@ const GetLocalToscaFileForUpload = (props) => {
setAlertMessages(<Alert variant="danger">
<Alert.Heading>Upload Failure</Alert.Heading>
<p>Tosca Service Template from { selectedFile.name } failed to upload</p>
- <p>Status code: { response.status }: { response.statusText }</p>
- <p>Response from CLAMP: { responseMessage }</p>
+ <p>Status code: { await response.status }: { response.statusText }</p>
+ <p>Response Text: { await response.text() }</p>
<hr/>
<p>Type: { selectedFile.type }</p><p>Size: { +selectedFile.size / 1000 }Kb</p>
</Alert>);
diff --git a/gui-clamp/ui-react/src/components/dialogs/GetLocalToscaFileForUpload.test.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetLocalToscaFileForUpload.test.js
index dfd3b9e..9b885c6 100644
--- a/gui-clamp/ui-react/src/components/dialogs/GetLocalToscaFileForUpload.test.js
+++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetLocalToscaFileForUpload.test.js
@@ -1,24 +1,22 @@
/*
- * -
- * * ============LICENSE_START=======================================================
- * * Copyright (C) 2021 Nordix Foundation.
- * * ================================================================================
- * * 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.
- * *
- * * SPDX-License-Identifier: Apache-2.0
- * * ============LICENSE_END=========================================================
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
*/
+
import React from 'react';
import { mount, shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.js
new file mode 100644
index 0000000..7da8c13
--- /dev/null
+++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.js
@@ -0,0 +1,50 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+import React, { useState } from "react";
+import Button from "react-bootstrap/Button";
+import ControlLoopService from "../../../api/ControlLoopService";
+
+const GetToscaTemplate = (props) => {
+
+ const [windowLocationPathName, setWindowLocationPathname] = useState('');
+
+ const getTemplateHandler = async () => {
+ console.log('getTemplateHandler called')
+ setWindowLocationPathname(window.location.pathname);
+
+ const response = await ControlLoopService.getToscaTemplate(props.templateName, props.templateVersion, windowLocationPathName)
+ .catch(error => error.message);
+
+ props.onGetToscaServiceTemplate(response);
+
+ }
+
+ return (
+ <React.Fragment>
+ <Button variant="primary"
+ type="submit"
+ onClick={ getTemplateHandler }>Get Tosca Service Template</Button>
+ </React.Fragment>
+ );
+
+
+}
+
+export default GetToscaTemplate;
diff --git a/gui-clamp/ui-react/src/api/GetToscaTemplate.test.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.test.js
index 338ee83..ce2a398 100644
--- a/gui-clamp/ui-react/src/api/GetToscaTemplate.test.js
+++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.test.js
@@ -1,24 +1,22 @@
/*
- * -
- * * ============LICENSE_START=======================================================
- * * Copyright (C) 2021 Nordix Foundation.
- * * ================================================================================
- * * 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.
- * *
- * * SPDX-License-Identifier: Apache-2.0
- * * ============LICENSE_END=========================================================
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
*/
+
import React from 'react';
import { mount, shallow } from 'enzyme';
import GetToscaTemplate from './GetToscaTemplate';
diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.js
new file mode 100644
index 0000000..53b541c
--- /dev/null
+++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.js
@@ -0,0 +1,96 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+import React, { useState } from "react";
+import GetToscaTemplate from "./GetToscaTemplate";
+import Modal from "react-bootstrap/Modal";
+import Button from "react-bootstrap/Button";
+import { Alert } from "react-bootstrap";
+
+import styled from 'styled-components';
+
+const ModalStyled = styled(Modal)`
+ background-color: transparent;
+`
+
+const AlertStyled = styled(Alert)`
+ margin-top: 10px;
+`
+
+const PreStyled = styled.pre`
+ color: #7F0055;
+ overflow: auto;
+ max-height: 70vh;
+ margin-top: 10px;
+`
+
+const ReadAndConvertYaml = (props) => {
+ const [show, setShow] = useState(true);
+ const [toscaTemplateData, setToscaTemplateData] = useState();
+ const [responeOk, setResponseOk] = useState(true);
+ const name = 'ToscaServiceTemplateSimple';
+ const version = '1.0.0';
+
+ const handleClose = () => {
+ console.log('handleClose called');
+ setShow(false);
+ props.history.push('/');
+ }
+
+ const getToscaServiceTemplateHandler = async (toscaServiceTemplateResponse) => {
+ // console.log('getToscaServiceTemplateHandler called: ' + toscaServiceTemplate);
+
+ if (!toscaServiceTemplateResponse.ok) {
+ setResponseOk(false);
+ const toscaData = await toscaServiceTemplateResponse;
+ setToscaTemplateData(toscaData);
+ } else {
+ setResponseOk(true);
+ const toscaData = await toscaServiceTemplateResponse.json();
+ setToscaTemplateData(toscaData);
+ }
+ }
+
+ return (
+ <ModalStyled size="xl"
+ show={ show }
+ onHide={ handleClose }
+ backdrop="static"
+ keyboard={ false }>
+ <Modal.Header closeButton>
+ <Modal.Title>View Tosca Template</Modal.Title>
+ </Modal.Header>
+ <Modal.Body>
+ <GetToscaTemplate templateName={ name }
+ templateVersion={ version }
+ onGetToscaServiceTemplate={ getToscaServiceTemplateHandler }/>
+ { responeOk && <PreStyled> { JSON.stringify(toscaTemplateData, null, 2) } </PreStyled> }
+ <AlertStyled show={ !responeOk }
+ variant="danger">{ toscaTemplateData }</AlertStyled>
+ </Modal.Body>
+ <Modal.Footer>
+ <Button variant="secondary"
+ type="null"
+ onClick={ handleClose }>Cancel</Button>
+ </Modal.Footer>
+ </ModalStyled>
+ );
+};
+
+export default ReadAndConvertYaml;
diff --git a/gui-clamp/ui-react/src/components/dialogs/ReadAndConvertYaml.test.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.test.js
index daec619..90d7185 100644
--- a/gui-clamp/ui-react/src/components/dialogs/ReadAndConvertYaml.test.js
+++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.test.js
@@ -1,24 +1,22 @@
/*
- * -
- * * ============LICENSE_START=======================================================
- * * Copyright (C) 2021 Nordix Foundation.
- * * ================================================================================
- * * 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.
- * *
- * * SPDX-License-Identifier: Apache-2.0
- * * ============LICENSE_END=========================================================
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
*/
+
import React from 'react';
import { mount, shallow } from 'enzyme';
import ReadAndConvertYaml from './ReadAndConvertYaml';
diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/UploadToscaFile.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/UploadToscaFile.js
new file mode 100644
index 0000000..6ee6a43
--- /dev/null
+++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/UploadToscaFile.js
@@ -0,0 +1,54 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+import Button from "react-bootstrap/Button";
+import React, { useState } from "react";
+import ControlLoopService from "../../../api/ControlLoopService";
+
+const UploadToscaFile = (props) => {
+ const [windowLocationPathName, setWindowLocationPathname] = useState('');
+
+ const postServiceTemplateHandler = async (event) => {
+ event.preventDefault();
+ console.log('postServiceTemplateHandler called');
+ setWindowLocationPathname(window.location.pathname);
+
+ const response = await ControlLoopService.uploadToscaFile(props.toscaObject, windowLocationPathName)
+ .catch(error => error.message);
+
+ // const responseMessage = await response.text();
+
+ props.onResponseReceived(response);
+
+ }
+
+ return (
+ <React.Fragment>
+ <Button variant="primary"
+ block={ true }
+ type="submit"
+ onClick={ postServiceTemplateHandler }>
+ Upload Tosca Service Template
+ </Button>
+ </React.Fragment>
+ );
+
+};
+
+export default UploadToscaFile;
diff --git a/gui-clamp/ui-react/src/api/UploadToscaFile.test.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/UploadToscaFile.test.js
index 681acc7..94d9038 100644
--- a/gui-clamp/ui-react/src/api/UploadToscaFile.test.js
+++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/UploadToscaFile.test.js
@@ -1,24 +1,22 @@
/*
- * -
- * * ============LICENSE_START=======================================================
- * * Copyright (C) 2021 Nordix Foundation.
- * * ================================================================================
- * * 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.
- * *
- * * SPDX-License-Identifier: Apache-2.0
- * * ============LICENSE_END=========================================================
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
*/
+
import React from 'react';
import { mount, shallow } from 'enzyme';
import UploadToscaFile from './UploadToscaFile';
diff --git a/gui-clamp/ui-react/src/components/dialogs/__snapshots__/GetLocalToscaFileForUpload.test.js.snap b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/GetLocalToscaFileForUpload.test.js.snap
index 84168fd..84168fd 100644
--- a/gui-clamp/ui-react/src/components/dialogs/__snapshots__/GetLocalToscaFileForUpload.test.js.snap
+++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/GetLocalToscaFileForUpload.test.js.snap
diff --git a/gui-clamp/ui-react/src/api/__snapshots__/GetToscaTemplate.test.js.snap b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/GetToscaTemplate.test.js.snap
index 2c591d9..2c591d9 100644
--- a/gui-clamp/ui-react/src/api/__snapshots__/GetToscaTemplate.test.js.snap
+++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/GetToscaTemplate.test.js.snap
diff --git a/gui-clamp/ui-react/src/components/dialogs/__snapshots__/ReadAndConvertYaml.test.js.snap b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/ReadAndConvertYaml.test.js.snap
index cbead03..fab7801 100644
--- a/gui-clamp/ui-react/src/components/dialogs/__snapshots__/ReadAndConvertYaml.test.js.snap
+++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/ReadAndConvertYaml.test.js.snap
@@ -22,7 +22,14 @@ exports[`Verify ReadAndConvertYaml renders correctly 1`] = `
templateName="ToscaServiceTemplateSimple"
templateVersion="1.0.0"
/>
- <styled.pre />
+ <styled.pre>
+
+
+ </styled.pre>
+ <Styled(Alert)
+ show={false}
+ variant="danger"
+ />
</ModalBody>
<ModalFooter>
<Button
diff --git a/gui-clamp/ui-react/src/api/__snapshots__/UploadToscaFile.test.js.snap b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/UploadToscaFile.test.js.snap
index a1ae439..a1ae439 100644
--- a/gui-clamp/ui-react/src/api/__snapshots__/UploadToscaFile.test.js.snap
+++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/UploadToscaFile.test.js.snap
diff --git a/gui-clamp/ui-react/src/components/dialogs/ReadAndConvertYaml.js b/gui-clamp/ui-react/src/components/dialogs/ReadAndConvertYaml.js
deleted file mode 100644
index 3a02588..0000000
--- a/gui-clamp/ui-react/src/components/dialogs/ReadAndConvertYaml.js
+++ /dev/null
@@ -1,87 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-import React, { useState } from "react";
-import GetToscaTemplate from "../../api/GetToscaTemplate";
-import Modal from "react-bootstrap/Modal";
-import Button from "react-bootstrap/Button";
-
-import styled from 'styled-components';
-
-const ModalStyled = styled(Modal)`
- background-color: transparent;
-`
-
-const ErrMsgStyled = styled.div`
- color: red;
-`
-
-const PreStyled = styled.pre`
- color: #7F0055;
- overflow: auto;
- max-height: 70vh;
-`
-
-const ReadAndConvertYaml = (props) => {
- const [show, setShow] = useState(true);
- const [toscaTemplateData, setToscaTemplateData] = useState();
- const name = 'ToscaServiceTemplateSimple';
- const version = '1.0.0';
-
- const handleClose = () => {
- console.log('handleClose called');
- setShow(false);
- props.history.push('/');
- }
-
- const getToscaServiceTemplateHandler = async (toscaServiceTemplate) => {
- console.log('getToscaServiceTemplateHandler called');
- const toscaData = {
- ...toscaServiceTemplate,
- id: Math.random().toString()
- };
- // console.log(toscaData);
- setToscaTemplateData(toscaData);
- }
-
- return (
- <ModalStyled size="xl"
- show={ show }
- onHide={ handleClose }
- backdrop="static"
- keyboard={ false }>
- <Modal.Header closeButton>
- <Modal.Title>View Tosca Template</Modal.Title>
- </Modal.Header>
- <Modal.Body>
- <GetToscaTemplate templateName={ name }
- templateVersion={ version }
- onGetToscaServiceTemplate={ getToscaServiceTemplateHandler }/>
- <PreStyled>{ JSON.stringify(toscaTemplateData, null, 2) }</PreStyled>
- </Modal.Body>
- <Modal.Footer>
- <Button variant="secondary"
- type="null"
- onClick={ handleClose }>Cancel</Button>
- </Modal.Footer>
- </ModalStyled>
- );
-}
-
-export default ReadAndConvertYaml;
diff --git a/gui-clamp/ui-react/src/components/menu/MenuBar.js b/gui-clamp/ui-react/src/components/menu/MenuBar.js
index d7784ef..4574a2a 100644
--- a/gui-clamp/ui-react/src/components/menu/MenuBar.js
+++ b/gui-clamp/ui-react/src/components/menu/MenuBar.js
@@ -87,10 +87,6 @@ export default class MenuBar extends React.Component {
render() {
return (
<Navbar.Collapse>
- <StyledNavDropdown title="Tosca">
- <NavDropdown.Item as={ StyledLink } to="/readToscaTemplate">View Tosca Template</NavDropdown.Item>
- <NavDropdown.Item as={ StyledLink } to="/uploadToscaFile">Upload Tosca to Commissioning</NavDropdown.Item>
- </StyledNavDropdown>
<StyledNavDropdown title="POLICY Framework">
<NavDropdown.Item as={ StyledLink } to="/viewAllPolicies">View All Policies</NavDropdown.Item>
</StyledNavDropdown>
@@ -119,6 +115,10 @@ export default class MenuBar extends React.Component {
</StyledNavDropdown>
<StyledNavDropdown title="TOSCA Control Loop">
<NavDropdown.Item as={ StyledLink } to="/monitoring">Monitoring Control Loop</NavDropdown.Item>
+ <NavDropdown.Divider />
+ <NavDropdown.Header>Commissioning</NavDropdown.Header>
+ <NavDropdown.Item as={ StyledLink } to="/readToscaTemplate">View Tosca Template</NavDropdown.Item>
+ <NavDropdown.Item as={ StyledLink } to="/uploadToscaFile">Upload Tosca to Commissioning</NavDropdown.Item>
</StyledNavDropdown>
<StyledNavDropdown title="Help">
<StyledNavLink href="https://wiki.onap.org/" target="_blank">Wiki</StyledNavLink>
diff --git a/gui-clamp/ui-react/src/components/menu/__snapshots__/MenuBar.test.js.snap b/gui-clamp/ui-react/src/components/menu/__snapshots__/MenuBar.test.js.snap
index 416d62e..8bdfb09 100644
--- a/gui-clamp/ui-react/src/components/menu/__snapshots__/MenuBar.test.js.snap
+++ b/gui-clamp/ui-react/src/components/menu/__snapshots__/MenuBar.test.js.snap
@@ -3,7 +3,7 @@
exports[`Verify MenuBar Test the render method 1`] = `
<NavbarCollapse>
<Styled(NavDropdown)
- title="Tosca"
+ title="POLICY Framework"
>
<DropdownItem
as={
@@ -66,10 +66,14 @@ exports[`Verify MenuBar Test the render method 1`] = `
}
}
disabled={false}
- to="/readToscaTemplate"
+ to="/viewAllPolicies"
>
- View Tosca Template
+ View All Policies
</DropdownItem>
+ </Styled(NavDropdown)>
+ <Styled(NavDropdown)
+ title="CLAMP Options"
+ >
<DropdownItem
as={
Object {
@@ -131,14 +135,13 @@ exports[`Verify MenuBar Test the render method 1`] = `
}
}
disabled={false}
- to="/uploadToscaFile"
+ to="/manageDictionaries"
>
- Upload Tosca to Commissioning
+ Tosca Metadata Dictionaries
</DropdownItem>
- </Styled(NavDropdown)>
- <Styled(NavDropdown)
- title="POLICY Framework"
- >
+ <DropdownDivider
+ role="separator"
+ />
<DropdownItem
as={
Object {
@@ -200,13 +203,13 @@ exports[`Verify MenuBar Test the render method 1`] = `
}
}
disabled={false}
- to="/viewAllPolicies"
+ to="/viewLoopTemplatesModal"
>
- View All Policies
+ View All Loop Templates
</DropdownItem>
</Styled(NavDropdown)>
<Styled(NavDropdown)
- title="CLAMP Options"
+ title="LOOP Instance"
>
<DropdownItem
as={
@@ -269,13 +272,10 @@ exports[`Verify MenuBar Test the render method 1`] = `
}
}
disabled={false}
- to="/manageDictionaries"
+ to="/createLoop"
>
- Tosca Metadata Dictionaries
+ Create
</DropdownItem>
- <DropdownDivider
- role="separator"
- />
<DropdownItem
as={
Object {
@@ -337,14 +337,10 @@ exports[`Verify MenuBar Test the render method 1`] = `
}
}
disabled={false}
- to="/viewLoopTemplatesModal"
+ to="/openLoop"
>
- View All Loop Templates
+ Open
</DropdownItem>
- </Styled(NavDropdown)>
- <Styled(NavDropdown)
- title="LOOP Instance"
- >
<DropdownItem
as={
Object {
@@ -405,10 +401,10 @@ exports[`Verify MenuBar Test the render method 1`] = `
"withComponent": [Function],
}
}
- disabled={false}
- to="/createLoop"
+ disabled={true}
+ to="/closeLoop"
>
- Create
+ Close
</DropdownItem>
<DropdownItem
as={
@@ -470,11 +466,14 @@ exports[`Verify MenuBar Test the render method 1`] = `
"withComponent": [Function],
}
}
- disabled={false}
- to="/openLoop"
+ disabled={true}
+ to="/modifyLoop"
>
- Open
+ Modify
</DropdownItem>
+ <DropdownDivider
+ role="separator"
+ />
<DropdownItem
as={
Object {
@@ -536,9 +535,9 @@ exports[`Verify MenuBar Test the render method 1`] = `
}
}
disabled={true}
- to="/closeLoop"
+ to="/loopProperties"
>
- Close
+ Properties
</DropdownItem>
<DropdownItem
as={
@@ -601,13 +600,14 @@ exports[`Verify MenuBar Test the render method 1`] = `
}
}
disabled={true}
- to="/modifyLoop"
+ to="/refreshStatus"
>
- Modify
+ Refresh Status
</DropdownItem>
- <DropdownDivider
- role="separator"
- />
+ </Styled(NavDropdown)>
+ <Styled(NavDropdown)
+ title="LOOP Operations"
+ >
<DropdownItem
as={
Object {
@@ -669,9 +669,9 @@ exports[`Verify MenuBar Test the render method 1`] = `
}
}
disabled={true}
- to="/loopProperties"
+ to="/submit"
>
- Properties
+ Create and deploy to Policy Framework (SUBMIT)
</DropdownItem>
<DropdownItem
as={
@@ -734,14 +734,10 @@ exports[`Verify MenuBar Test the render method 1`] = `
}
}
disabled={true}
- to="/refreshStatus"
+ to="/stop"
>
- Refresh Status
+ Undeploy from Policy Framework (STOP)
</DropdownItem>
- </Styled(NavDropdown)>
- <Styled(NavDropdown)
- title="LOOP Operations"
- >
<DropdownItem
as={
Object {
@@ -803,9 +799,9 @@ exports[`Verify MenuBar Test the render method 1`] = `
}
}
disabled={true}
- to="/submit"
+ to="/restart"
>
- Create and deploy to Policy Framework (SUBMIT)
+ ReDeploy to Policy Framework (RESTART)
</DropdownItem>
<DropdownItem
as={
@@ -868,10 +864,13 @@ exports[`Verify MenuBar Test the render method 1`] = `
}
}
disabled={true}
- to="/stop"
+ to="/delete"
>
- Undeploy from Policy Framework (STOP)
+ Delete loop instance (DELETE)
</DropdownItem>
+ <DropdownDivider
+ role="separator"
+ />
<DropdownItem
as={
Object {
@@ -933,9 +932,9 @@ exports[`Verify MenuBar Test the render method 1`] = `
}
}
disabled={true}
- to="/restart"
+ to="/deploy"
>
- ReDeploy to Policy Framework (RESTART)
+ Deploy to DCAE (DEPLOY)
</DropdownItem>
<DropdownItem
as={
@@ -998,13 +997,14 @@ exports[`Verify MenuBar Test the render method 1`] = `
}
}
disabled={true}
- to="/delete"
+ to="/undeploy"
>
- Delete loop instance (DELETE)
+ UnDeploy to DCAE (UNDEPLOY)
</DropdownItem>
- <DropdownDivider
- role="separator"
- />
+ </Styled(NavDropdown)>
+ <Styled(NavDropdown)
+ title="TOSCA Control Loop"
+ >
<DropdownItem
as={
Object {
@@ -1065,11 +1065,19 @@ exports[`Verify MenuBar Test the render method 1`] = `
"withComponent": [Function],
}
}
- disabled={true}
- to="/deploy"
+ disabled={false}
+ to="/monitoring"
>
- Deploy to DCAE (DEPLOY)
+ Monitoring Control Loop
</DropdownItem>
+ <DropdownDivider
+ role="separator"
+ />
+ <DropdownHeader
+ role="heading"
+ >
+ Commissioning
+ </DropdownHeader>
<DropdownItem
as={
Object {
@@ -1130,15 +1138,11 @@ exports[`Verify MenuBar Test the render method 1`] = `
"withComponent": [Function],
}
}
- disabled={true}
- to="/undeploy"
+ disabled={false}
+ to="/readToscaTemplate"
>
- UnDeploy to DCAE (UNDEPLOY)
+ View Tosca Template
</DropdownItem>
- </Styled(NavDropdown)>
- <Styled(NavDropdown)
- title="TOSCA Control Loop"
- >
<DropdownItem
as={
Object {
@@ -1200,9 +1204,9 @@ exports[`Verify MenuBar Test the render method 1`] = `
}
}
disabled={false}
- to="/monitoring"
+ to="/uploadToscaFile"
>
- Monitoring Control Loop
+ Upload Tosca to Commissioning
</DropdownItem>
</Styled(NavDropdown)>
<Styled(NavDropdown)