Clamp react ui to use url pathname dynamically instead of hardcoded prefix for calling apis

Issue-ID: CLAMP-914
Signed-off-by: Ashwin Sharma <ashwin.shyam.sharma@att.com>
Change-Id: I266aeafe9a543e95bcb96fcab6437227c148f8c4
diff --git a/ui-react/src/api/LoopActionService.js b/ui-react/src/api/LoopActionService.js
index 7cea3ff..bff812a 100644
--- a/ui-react/src/api/LoopActionService.js
+++ b/ui-react/src/api/LoopActionService.js
@@ -26,7 +26,7 @@
 	static performAction(cl_name, uiAction) {
 		console.info("LoopActionService perform action: " + uiAction + " closedloopName=" + cl_name);
 		const svcAction = uiAction.toLowerCase();
- 		return fetch("/restservices/clds/v2/loop/" + svcAction + "/" + cl_name, {
+ 		return fetch(window.location.pathname + "restservices/clds/v2/loop/" + svcAction + "/" + cl_name, {
  				method: 'PUT',
  				credentials: 'same-origin'
  			})
@@ -51,7 +51,7 @@
 	static refreshStatus(cl_name) {
 		console.info("Refresh the status for closedloopName=" + cl_name);
 
-		return fetch("/restservices/clds/v2/loop/getstatus/" + cl_name, {
+		return fetch(window.location.pathname + "restservices/clds/v2/loop/getstatus/" + cl_name, {
 			method: 'GET',
 			credentials: 'same-origin'
 		})
diff --git a/ui-react/src/api/LoopService.js b/ui-react/src/api/LoopService.js
index c45df6c..96bb8a0 100644
--- a/ui-react/src/api/LoopService.js
+++ b/ui-react/src/api/LoopService.js
@@ -22,7 +22,7 @@
 
 export default class LoopService {
 	static getLoopNames() {
-		return fetch('/restservices/clds/v2/loop/getAllNames', { method: 'GET', credentials: 'same-origin' })
+		return fetch(window.location.pathname + 'restservices/clds/v2/loop/getAllNames', { method: 'GET', credentials: 'same-origin' })
 			.then(function (response) {
 				console.debug("GetLoopNames response received: ", response.status);
 				if (response.ok) {
@@ -39,7 +39,7 @@
 	}
 
 	static createLoop(loopName, templateName) {
-		return fetch('/restservices/clds/v2/loop/create/' + loopName + '?templateName=' + templateName, {
+		return fetch(window.location.pathname + 'restservices/clds/v2/loop/create/' + loopName + '?templateName=' + templateName, {
 			method: 'POST',
 			headers: {
 				"Content-Type": "application/json"
@@ -57,7 +57,7 @@
 	}
 
 	static getLoop(loopName) {
-		return fetch('/restservices/clds/v2/loop/' + loopName, {
+		return fetch(window.location.pathname + 'restservices/clds/v2/loop/' + loopName, {
 			method: 'GET',
 			headers: {
 				"Content-Type": "application/json"
@@ -80,7 +80,7 @@
 	}
 
 	static setMicroServiceProperties(loopName, jsonData) {
-		return fetch('/restservices/clds/v2/loop/updateMicroservicePolicy/' + loopName, {
+		return fetch(window.location.pathname + 'restservices/clds/v2/loop/updateMicroservicePolicy/' + loopName, {
 			method: 'POST',
 			credentials: 'same-origin',
 			headers: {
@@ -104,7 +104,7 @@
 	}
 	
 	static setOperationalPolicyProperties(loopName, jsonData) {
-		return fetch('/restservices/clds/v2/loop/updateOperationalPolicies/' + loopName, {
+		return fetch(window.location.pathname + 'restservices/clds/v2/loop/updateOperationalPolicies/' + loopName, {
 			method: 'POST',
 			credentials: 'same-origin',
 			headers: {
@@ -128,7 +128,7 @@
 	}
 
 	static updateGlobalProperties(loopName, jsonData) {
-		return fetch('/restservices/clds/v2/loop/updateGlobalProperties/' + loopName, {
+		return fetch(window.location.pathname + 'restservices/clds/v2/loop/updateGlobalProperties/' + loopName, {
 			method: 'POST',
 			credentials: 'same-origin',
 			headers: {
@@ -152,7 +152,7 @@
 	}
 
 	static refreshOperationalPolicyJson(loopName,operationalPolicyName) {
-		return fetch('/restservices/clds/v2/loop/refreshOperationalPolicyJsonSchema/' + loopName + '/' + operationalPolicyName, {
+		return fetch(window.location.pathname + 'restservices/clds/v2/loop/refreshOperationalPolicyJsonSchema/' + loopName + '/' + operationalPolicyName, {
 			method: 'PUT',
 			headers: {
 				"Content-Type": "application/json"
@@ -175,7 +175,7 @@
 	}
 
 		static refreshMicroServicePolicyJson(loopName,microServicePolicyName) {
-    		return fetch('/restservices/clds/v2/loop/refreshMicroServicePolicyJsonSchema/' + loopName + '/' + microServicePolicyName, {
+    		return fetch(window.location.pathname + 'restservices/clds/v2/loop/refreshMicroServicePolicyJsonSchema/' + loopName + '/' + microServicePolicyName, {
     			method: 'PUT',
     			headers: {
     				"Content-Type": "application/json"
@@ -198,7 +198,7 @@
     }
 
 	static addOperationalPolicyType(loopName, policyType, policyVersion) {
-		return fetch('/restservices/clds/v2/loop/addOperationaPolicy/' + loopName + '/policyModel/' + policyType +'/' + policyVersion , {
+		return fetch(window.location.pathname + 'restservices/clds/v2/loop/addOperationaPolicy/' + loopName + '/policyModel/' + policyType +'/' + policyVersion , {
 			method: 'PUT',
 			headers: {
 				"Content-Type": "application/json"
@@ -220,7 +220,7 @@
 	}
 
 	static removeOperationalPolicyType(loopName, policyType, policyVersion, policyName) {
-		return fetch('/restservices/clds/v2/loop/removeOperationaPolicy/' + loopName + '/policyModel/' + policyType +'/' + policyVersion + '/' + policyName , {
+		return fetch(window.location.pathname + 'restservices/clds/v2/loop/removeOperationaPolicy/' + loopName + '/policyModel/' + policyType +'/' + policyVersion + '/' + policyName , {
 			method: 'PUT',
 			headers: {
 				"Content-Type": "application/json"
diff --git a/ui-react/src/api/PolicyToscaService.js b/ui-react/src/api/PolicyToscaService.js
index 610a114..a7bc140 100644
--- a/ui-react/src/api/PolicyToscaService.js
+++ b/ui-react/src/api/PolicyToscaService.js
@@ -22,7 +22,7 @@
 
 export default class PolicyToscaService {
   static getToscaPolicyModels() {
-    return fetch('restservices/clds/v2/policyToscaModels', { method: 'GET', credentials: 'same-origin' })
+    return fetch(window.location.pathname + 'restservices/clds/v2/policyToscaModels', { method: 'GET', credentials: 'same-origin' })
       .then(function (response) {
         console.debug("getToscaPolicyModels response received: ", response.status);
         if (response.ok) {
@@ -39,7 +39,7 @@
   }
 
   static getToscaPolicyModelYaml(policyModelType, policyModelVersion) {
-		return fetch('/restservices/clds/v2/policyToscaModels/yaml/' + policyModelType + "/" + policyModelVersion, {
+		return fetch(window.location.pathname + 'restservices/clds/v2/policyToscaModels/yaml/' + policyModelType + "/" + policyModelVersion, {
 			method: 'GET',
 			credentials: 'same-origin'
 		})
@@ -59,7 +59,7 @@
  }
 
  static getToscaPolicyModel(policyModelType, policyModelVersion) {
- 		return fetch('/restservices/clds/v2/policyToscaModels/' + policyModelType + "/" + policyModelVersion, {
+ 		return fetch(window.location.pathname + 'restservices/clds/v2/policyToscaModels/' + policyModelType + "/" + policyModelVersion, {
  			method: 'GET',
  			credentials: 'same-origin'
  		})
@@ -79,7 +79,7 @@
   }
 
   static createPolicyModelFromToscaModel(jsonData) {
-       return fetch('/restservices/clds/v2/policyToscaModels', {
+       return fetch(window.location.pathname + 'restservices/clds/v2/policyToscaModels', {
            method: 'POST',
            credentials: 'same-origin',
            headers: {
@@ -107,7 +107,7 @@
      }
 
      static updatePolicyModelTosca(policyModelType, policyModelVersion, jsonData) {
-         return fetch('/restservices/clds/v2/policyToscaModels/' + policyModelType + '/' + policyModelVersion, {
+         return fetch(window.location.pathname + 'restservices/clds/v2/policyToscaModels/' + policyModelType + '/' + policyModelVersion, {
              method: 'PUT',
              credentials: 'same-origin',
              headers: {
diff --git a/ui-react/src/api/TemplateService.js b/ui-react/src/api/TemplateService.js
index 7d8a340..08436f2 100644
--- a/ui-react/src/api/TemplateService.js
+++ b/ui-react/src/api/TemplateService.js
@@ -23,7 +23,7 @@
 export default class TemplateService {
 
         static getLoopNames() {
-                return fetch('/restservices/clds/v2/loop/getAllNames', { method: 'GET', credentials: 'same-origin' })
+                return fetch(window.location.pathname + 'restservices/clds/v2/loop/getAllNames', { method: 'GET', credentials: 'same-origin' })
                         .then(function (response) {
                                 console.debug("getLoopNames response received: ", response.status);
                                 if (response.ok) {
@@ -40,7 +40,7 @@
         }
 
 	static getAllLoopTemplates() {
-	    return fetch('restservices/clds/v2/templates', { method: 'GET', credentials: 'same-origin', })
+	    return fetch(window.location.pathname + 'restservices/clds/v2/templates', { method: 'GET', credentials: 'same-origin', })
 	        .then(function (response) {
 	            console.debug("getAllLoopTemplates response received: ", response.status);
 	            if (response.ok) {
@@ -57,7 +57,7 @@
 	    }
 
 	static getDictionary() {
-	    return fetch('restservices/clds/v2/dictionary/', { method: 'GET', credentials: 'same-origin', })
+	    return fetch(window.location.pathname + 'restservices/clds/v2/dictionary/', { method: 'GET', credentials: 'same-origin', })
 	      .then(function (response) {
 	        console.debug("getDictionary response received: ", response.status);
 	        if (response.ok) {
@@ -74,7 +74,7 @@
 	  }
 
 	  static getDictionaryElements(dictionaryName) {
-	    return fetch('restservices/clds/v2/dictionary/' + dictionaryName, {
+	    return fetch(window.location.pathname + 'restservices/clds/v2/dictionary/' + dictionaryName, {
 	      method: 'GET',
 	      headers: {
 	        "Content-Type": "application/json",
@@ -98,7 +98,7 @@
 
 	  static insDictionary(jsonData) {
 	    console.log("dictionaryName is", jsonData.name)
-	    return fetch('/restservices/clds/v2/dictionary/', {
+	    return fetch(window.location.pathname + 'restservices/clds/v2/dictionary/', {
 	      method: 'PUT',
 	      credentials: 'same-origin',
 	      headers: {
@@ -124,7 +124,7 @@
 
 	  static insDictionaryElements(jsonData) {
 	    console.log("dictionaryName is", jsonData.name)
-	    return fetch('/restservices/clds/v2/dictionary/' + jsonData.name, {
+	    return fetch(window.location.pathname + 'restservices/clds/v2/dictionary/' + jsonData.name, {
 	      method: 'PUT',
 	      credentials: 'same-origin',
 	      headers: {
@@ -150,7 +150,7 @@
 
 	  static deleteDictionary(dictionaryName) {
 	    console.log("inside templaemenu service", dictionaryName)
-	    return fetch('restservices/clds/v2/dictionary/' + dictionaryName, {
+	    return fetch(window.location.pathname + 'restservices/clds/v2/dictionary/' + dictionaryName, {
 	      method: 'DELETE',
 	      headers: {
 	        "Content-Type": "application/json",
@@ -173,7 +173,7 @@
 	  }
 
 	  static deleteDictionaryElements(dictionaryData) {
-	    return fetch('restservices/clds/v2/dictionary/' + dictionaryData.name + '/elements/' + dictionaryData.shortName , {
+	    return fetch(window.location.pathname + 'restservices/clds/v2/dictionary/' + dictionaryData.name + '/elements/' + dictionaryData.shortName , {
 	      method: 'DELETE',
 	      headers: {
 	        "Content-Type": "application/json",
diff --git a/ui-react/src/api/UserService.js b/ui-react/src/api/UserService.js
index 477ca42..5fb4aa6 100644
--- a/ui-react/src/api/UserService.js
+++ b/ui-react/src/api/UserService.js
@@ -24,7 +24,7 @@
 export default class UserService {
 	static notLoggedUserName='Anonymous';
 	static login() {
-		return fetch('/restservices/clds/v1/user/getUser', {
+		return fetch(window.location.pathname + 'restservices/clds/v1/user/getUser', {
 				method: 'GET',
 				credentials: 'same-origin'
 			})
@@ -49,7 +49,7 @@
 	}
 
 	static getUserInfo() {
-		return fetch('/restservices/clds/v2/clampInformation', {
+		return fetch(window.location.pathname + 'restservices/clds/v2/clampInformation', {
 				method: 'GET',
 				credentials: 'same-origin'
 			})