From d1ed0a9ba6ffea4006fadf3847495563d11dc12e Mon Sep 17 00:00:00 2001 From: sebdet Date: Wed, 21 Apr 2021 16:28:33 +0200 Subject: ToscaFileSelector The UI code that manages the tosca file selector that will be sent to clamp be + fix Rest Camel endpoint that always want ot convert http body to JSON (due to Camel upgrade) Issue-ID: POLICY-3229 Signed-off-by: sebdet Change-Id: I6148276d4c527f29db904a76655055c19d4e2023 --- ui-react/src/api/PolicyService.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'ui-react/src/api') diff --git a/ui-react/src/api/PolicyService.js b/ui-react/src/api/PolicyService.js index 54110f39c..f2886b30a 100644 --- a/ui-react/src/api/PolicyService.js +++ b/ui-react/src/api/PolicyService.js @@ -119,4 +119,30 @@ export default class PolicyService { return undefined; }); } + static sendNewPolicyModel(newPolicyModel) { + return fetch(window.location.pathname + 'restservices/clds/v2/policies/policytype', { + method: 'POST', + credentials: 'same-origin', + headers: { + "Content-Type": "plain/text" + }, + body: newPolicyModel + }) + .then(function (response) { + console.debug("sendNewPolicyModel response received: ", response.status); + if (response.ok) { + console.info("sendNewPolicyModel query successful"); + return response.text(); + } else { + return response.text().then(responseBody => { + throw new Error("HTTP " + response.status + "," + responseBody); + }) + } + }) + .catch(function (error) { + console.error("sendNewPolicyModel error occurred ", error); + alert ("sendNewPolicyModel error occurred " + error); + return undefined; + }); + } } -- cgit 1.2.3-korg