diff options
author | brunomilitzer <bruno.militzer@est.tech> | 2021-07-27 17:47:25 +0100 |
---|---|---|
committer | brunomilitzer <bruno.militzer@est.tech> | 2021-07-30 17:02:30 +0100 |
commit | bdc4cc9d4a75bfdd2f5656f102d2f6ac7817e4ef (patch) | |
tree | 4f7a851ae2d78a386626c85091761042894d55e9 /gui-clamp/ui-react/src/api | |
parent | 83c09e788eb75b287c946acbcba0d43cd3cd4681 (diff) |
Add Instance Properties Form
Added save button to update paramaters
Added service to retrieve paramaters;
Added service to upload instance paramaters
Issue-ID: POLICY-3436
Change-Id: I82e7545b12160f2e7937db2fdb3857c66ea0b858
Signed-off-by: brunomilitzer <bruno.militzer@est.tech>
Diffstat (limited to 'gui-clamp/ui-react/src/api')
-rw-r--r-- | gui-clamp/ui-react/src/api/ControlLoopService.js | 64 |
1 files changed, 27 insertions, 37 deletions
diff --git a/gui-clamp/ui-react/src/api/ControlLoopService.js b/gui-clamp/ui-react/src/api/ControlLoopService.js index 5938bd2..513fe68 100644 --- a/gui-clamp/ui-react/src/api/ControlLoopService.js +++ b/gui-clamp/ui-react/src/api/ControlLoopService.js @@ -19,7 +19,7 @@ export default class ControlLoopService { - static async fetchControlLoopInstantiation(windowLocationPathname) { + static async getControlLoopInstantiation(windowLocationPathname) { return await fetch(windowLocationPathname + '/restservices/clds/v2/toscaControlLoop/getToscaInstantiation', { method: 'GET', @@ -45,18 +45,33 @@ export default class ControlLoopService { }); } - static async uploadToscaInstantiation(toscaObject, windowLocationPathname) { + static async getInstanceProperties(name, version, windowLocationPathname) { + const params = { + name: name, + version: version, + common: "false" + } + + const response = await fetch(windowLocationPathname + '/restservices/clds/v2/toscaControlLoop/getCommonOrInstanceProperties' + '?' + (new URLSearchParams(params))); + + this.checkResponseForError(response); + + return response; + } + + static async createInstanceProperties(instancePropertiesTemplate, windowLocationPathname) { - const response = await fetch(windowLocationPathname + '/restservices/clds/v2/toscaControlLoop/postToscaInstantiation', { + const response = await fetch(windowLocationPathname + + '/restservices/clds/v2/toscaControlLoop/postToscaInstanceProperties', { method: 'POST', headers: { - 'Content-Type': 'application/json', + "Content-Type": "application/json" }, credentials: 'same-origin', - body: JSON.stringify(toscaObject) + body: JSON.stringify(instancePropertiesTemplate), }); - return response; + return response } static async getToscaTemplate(name, version, windowLocationPathname) { @@ -68,37 +83,11 @@ export default class ControlLoopService { const response = await fetch(windowLocationPathname + '/restservices/clds/v2/toscaControlLoop/getToscaTemplate' + '?' + (new URLSearchParams(params))); - const data = await response; - - return data; - } - - static async deleteToscaTemplate(name, version, windowLocationPathname) { - const params = { - name: name, - version: version + if (!response.ok) { + const message = `An error has occurred: ${ response.status }`; + throw new Error(message); } - const response = await fetch(windowLocationPathname + - '/restservices/clds/v2/toscaControlLoop/decommissionToscaTemplate' + '?' + (new URLSearchParams(params)), - { - method: 'DELETE' - }); - - this.checkResponseForError(response); - - const data = await response; - - return data; - } - - static async getToscaControlLoopDefinitions(windowLocationPathname) { - - const response = await fetch(windowLocationPathname + - '/restservices/clds/v2/toscaControlLoop/getElementDefinitions'); - - this.checkResponseForError(response); - const data = await response; return data; @@ -149,10 +138,11 @@ export default class ControlLoopService { return response; } - static checkResponseForError (response) { + static checkResponseForError(response) { if (!response.ok) { - const message = `An error has occurred: ${response.status}`; + const message = `An error has occurred: ${ response.status }`; throw new Error(message); } } + } |