From 3f99e6d9f007477fe6074f470048440d2b29c1ff Mon Sep 17 00:00:00 2001 From: "saul.gill" Date: Mon, 12 Jul 2021 17:10:10 +0100 Subject: Added Commissioning Template Editor Added a new modal to allow editing of the tosca template Json schema from the backend generates a for the user Added Decommissioning capability while viewing template Added service for decommissioning Issue-ID: POLICY-3439 Change-Id: Ic5bec9ea26aa8df468d36a893faa06f88d248dd5 Signed-off-by: saul.gill --- .../dialogs/ControlLoop/ReadAndConvertYaml.js | 43 ++++++++++++++++++---- 1 file changed, 36 insertions(+), 7 deletions(-) (limited to 'gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.js') diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.js index 53b541c..0ff8833 100644 --- a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.js +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.js @@ -24,6 +24,7 @@ import Button from "react-bootstrap/Button"; import { Alert } from "react-bootstrap"; import styled from 'styled-components'; +import DeleteToscaTemplate from "./DeleteToscaTemplate"; const ModalStyled = styled(Modal)` background-color: transparent; @@ -43,7 +44,9 @@ const PreStyled = styled.pre` const ReadAndConvertYaml = (props) => { const [show, setShow] = useState(true); const [toscaTemplateData, setToscaTemplateData] = useState(); - const [responeOk, setResponseOk] = useState(true); + const [deleteToscaTemplateData, setDeleteToscaTemplateData] = useState(); + const [responseOk, setResponseOk] = useState(true); + const [deleteResponseOk, setDeleteResponseOk] = useState(true); const name = 'ToscaServiceTemplateSimple'; const version = '1.0.0'; @@ -57,8 +60,9 @@ const ReadAndConvertYaml = (props) => { // console.log('getToscaServiceTemplateHandler called: ' + toscaServiceTemplate); if (!toscaServiceTemplateResponse.ok) { + console.log('Response is not ok'); setResponseOk(false); - const toscaData = await toscaServiceTemplateResponse; + const toscaData = await toscaServiceTemplateResponse.json(); setToscaTemplateData(toscaData); } else { setResponseOk(true); @@ -67,6 +71,20 @@ const ReadAndConvertYaml = (props) => { } } + const deleteToscaServiceTemplateHandler = async (deleteToscaServiceTemplateResponse) => { + + if (!deleteToscaServiceTemplateResponse.ok) { + console.log('Delete response not ok'); + setDeleteResponseOk(false); + const deleteToscaData = await deleteToscaServiceTemplateResponse; + setDeleteToscaTemplateData(deleteToscaData); + } else { + setDeleteResponseOk(true); + const deleteToscaData = await deleteToscaServiceTemplateResponse.json(); + setDeleteToscaTemplateData(deleteToscaData); + } + } + return ( { - { responeOk && { JSON.stringify(toscaTemplateData, null, 2) } } - { toscaTemplateData } + { responseOk && { JSON.stringify(toscaTemplateData, null, 2) } } + { JSON.stringify(toscaTemplateData, null, 2) } + { deleteResponseOk && responseOk && toscaTemplateData != null && + + } + { deleteToscaTemplateData } +

Delete Successful

{ JSON.stringify(deleteToscaTemplateData, null, 2) }
+ onClick={ handleClose }>Close
); -}; +} +; export default ReadAndConvertYaml; -- cgit 1.2.3-korg