diff options
author | danielhanrahan <daniel.hanrahan@est.tech> | 2021-09-08 12:34:22 +0100 |
---|---|---|
committer | danielhanrahan <daniel.hanrahan@est.tech> | 2021-09-10 11:46:48 +0100 |
commit | 426fa90230fc6732bd2a74e4c202e697ecd4c11b (patch) | |
tree | d696ba8aaaba2f556cb82d651cd1c380486a7c77 /gui-clamp/ui-react/src/api | |
parent | 4ee6cfe3c0c507370118348d782b14a09e1b3c53 (diff) |
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 <daniel.hanrahan@est.tech>
Change-Id: I6951a0a6b3f3bef15d262242df13cc2d20a198c8
Diffstat (limited to 'gui-clamp/ui-react/src/api')
-rw-r--r-- | gui-clamp/ui-react/src/api/ControlLoopService.js | 63 |
1 files changed, 33 insertions, 30 deletions
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); |