From 426fa90230fc6732bd2a74e4c202e697ecd4c11b Mon Sep 17 00:00:00 2001 From: danielhanrahan Date: Wed, 8 Sep 2021 12:34:22 +0100 Subject: Make gui-clamp work in Docker image Change package.json to generate URLs relative to current pathname Change REST URLs to use window.location.pathname Remove broken React state variables for window.location.pathname Issue-ID: POLICY-3600 Signed-off-by: danielhanrahan Change-Id: I6951a0a6b3f3bef15d262242df13cc2d20a198c8 --- gui-clamp/ui-react/src/api/ControlLoopService.js | 63 +++++++++++++----------- 1 file changed, 33 insertions(+), 30 deletions(-) (limited to 'gui-clamp/ui-react/src/api/ControlLoopService.js') diff --git a/gui-clamp/ui-react/src/api/ControlLoopService.js b/gui-clamp/ui-react/src/api/ControlLoopService.js index 96eb403..b3d987c 100644 --- a/gui-clamp/ui-react/src/api/ControlLoopService.js +++ b/gui-clamp/ui-react/src/api/ControlLoopService.js @@ -19,17 +19,18 @@ export default class ControlLoopService { - static async getControlLoopInstantiation(windowLocationPathname) { + static async getControlLoopInstantiation() { - const response = await fetch(windowLocationPathname + '/restservices/clds/v2/toscaControlLoop/getToscaInstantiation'); + const response = await fetch(window.location.pathname + + 'restservices/clds/v2/toscaControlLoop/getToscaInstantiation'); return response } - static async createInstanceProperties(instanceName, instancePropertiesTemplate, windowLocationPathname) { + static async createInstanceProperties(instanceName, instancePropertiesTemplate) { - const response = await fetch(windowLocationPathname + - '/restservices/clds/v2/toscaControlLoop/postToscaInstanceProperties', { + const response = await fetch(window.location.pathname + + 'restservices/clds/v2/toscaControlLoop/postToscaInstanceProperties', { method: 'POST', headers: { "Content-Type": "application/json" @@ -41,14 +42,14 @@ export default class ControlLoopService { return response } - static async deleteInstantiation(name, version, windowLocationPathName) { - console.log(windowLocationPathName); + static async deleteInstantiation(name, version) { const params = { name: name, version: version } - const response = await fetch(windowLocationPathName + '/restservices/clds/v2/toscaControlLoop/deleteToscaInstanceProperties?' + (new URLSearchParams(params)), { + const response = await fetch(window.location.pathname + + 'restservices/clds/v2/toscaControlLoop/deleteToscaInstanceProperties?' + (new URLSearchParams(params)), { method: 'DELETE', credentials: 'same-origin', }); @@ -58,20 +59,22 @@ export default class ControlLoopService { return data; } - static async getInstanceOrderState(name, version, windowLocationPathName) { + static async getInstanceOrderState(name, version) { const params = { name: name, version: version } - const response = await fetch(windowLocationPathName + '/restservices/clds/v2/toscaControlLoop/getInstantiationOrderState'+ '?' + (new URLSearchParams(params))); + const response = await fetch(window.location.pathname + + 'restservices/clds/v2/toscaControlLoop/getInstantiationOrderState'+ '?' + (new URLSearchParams(params))); const data = await response; return data; } - static async changeInstanceOrderState(toscaObject, windowLocationPathName) { - const response = await fetch(windowLocationPathName + '/restservices/clds/v2/toscaControlLoop/putToscaInstantiationStateChange', { + static async changeInstanceOrderState(toscaObject) { + const response = await fetch(window.location.pathname + + 'restservices/clds/v2/toscaControlLoop/putToscaInstantiationStateChange', { method: 'PUT', headers: { "Content-Type": "application/json" @@ -83,23 +86,23 @@ export default class ControlLoopService { return response } - static async getToscaTemplate(name, version, windowLocationPathname) { + static async getToscaTemplate(name, version) { const params = { name: name, version: version } - const response = await fetch(windowLocationPathname + - '/restservices/clds/v2/toscaControlLoop/getToscaTemplate' + '?' + (new URLSearchParams(params))); + const response = await fetch(window.location.pathname + + 'restservices/clds/v2/toscaControlLoop/getToscaTemplate' + '?' + (new URLSearchParams(params))); const data = await response; return data; } - static async uploadToscaFile(toscaObject, windowLocationPathName) { - const response = await fetch(windowLocationPathName + - '/restservices/clds/v2/toscaControlLoop/commissionToscaTemplate', { + static async uploadToscaFile(toscaObject) { + const response = await fetch(window.location.pathname + + 'restservices/clds/v2/toscaControlLoop/commissionToscaTemplate', { method: 'POST', headers: { "Content-Type": "application/json" @@ -112,14 +115,14 @@ export default class ControlLoopService { } - static async deleteToscaTemplate(name, version, windowLocationPathname) { + static async deleteToscaTemplate(name, version) { const params = { name: name, version: version } - const response = await fetch(windowLocationPathname + - '/restservices/clds/v2/toscaControlLoop/decommissionToscaTemplate' + '?' + (new URLSearchParams(params)), + const response = await fetch(window.location.pathname + + 'restservices/clds/v2/toscaControlLoop/decommissionToscaTemplate' + '?' + (new URLSearchParams(params)), { method: 'DELETE' }); @@ -129,10 +132,10 @@ export default class ControlLoopService { return data; } - static async getToscaControlLoopDefinitions(windowLocationPathname) { + static async getToscaControlLoopDefinitions() { - const response = await fetch(windowLocationPathname + - '/restservices/clds/v2/toscaControlLoop/getElementDefinitions'); + const response = await fetch(window.location.pathname + + 'restservices/clds/v2/toscaControlLoop/getElementDefinitions'); this.checkResponseForError(response); @@ -141,27 +144,27 @@ export default class ControlLoopService { return data; } - static async getCommonOrInstanceProperties(name, version, windowLocationPathName, isCommon) { + static async getCommonOrInstanceProperties(name, version, isCommon) { const params = { name: name, version: version, common: isCommon } - const response = await fetch(windowLocationPathName + - '/restservices/clds/v2/toscaControlLoop/getCommonOrInstanceProperties' + '?' + (new URLSearchParams(params))); + const response = await fetch(window.location.pathname + + 'restservices/clds/v2/toscaControlLoop/getCommonOrInstanceProperties' + '?' + (new URLSearchParams(params))); return response; } - static async getToscaServiceTemplateSchema(section, windowLocationPathName) { + static async getToscaServiceTemplateSchema(section) { const params = { section: section } - const response = await fetch(windowLocationPathName + - '/restservices/clds/v2/toscaControlLoop/getJsonSchema' + '?' + (new URLSearchParams(params))); + const response = await fetch(window.location.pathname + + 'restservices/clds/v2/toscaControlLoop/getJsonSchema' + '?' + (new URLSearchParams(params))); this.checkResponseForError(response); -- cgit 1.2.3-korg