summaryrefslogtreecommitdiffstats
path: root/ui-react/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'ui-react/src/api')
-rw-r--r--ui-react/src/api/LoopCache.js31
-rw-r--r--ui-react/src/api/LoopService.js91
-rw-r--r--ui-react/src/api/UserService.js17
-rw-r--r--ui-react/src/api/example.json2
4 files changed, 68 insertions, 73 deletions
diff --git a/ui-react/src/api/LoopCache.js b/ui-react/src/api/LoopCache.js
index d44b5cfd8..4c8f68c23 100644
--- a/ui-react/src/api/LoopCache.js
+++ b/ui-react/src/api/LoopCache.js
@@ -21,15 +21,14 @@
*
*/
-class LoopCache {
+export default class LoopCache {
loopJsonCache;
constructor(loopJson) {
this.loopJsonCache=loopJson;
- //LoopCache.SET_LOOP_JSON_CACHE(require('./example.json');
}
- updateMsProperties(type, newMsProperties) {
+ updateMicroServiceProperties(type, newMsProperties) {
if (newMsProperties["name"] === type) {
for (var policy in this.loopJsonCache["microServicePolicies"]) {
if (this.loopJsonCache["microServicePolicies"][policy]["name"] === type) {
@@ -43,7 +42,7 @@ class LoopCache {
this.loopJsonCache["globalPropertiesJson"] = newGlobalProperties;
}
- updateOpPolicyProperties(newOpProperties) {
+ updateOperationalPolicyProperties(newOpProperties) {
this.loopJsonCache["operationalPolicies"] = newOpProperties;
}
@@ -51,7 +50,7 @@ class LoopCache {
return this.loopJsonCache["name"];
}
- getOperationalPolicyProperty() {
+ getOperationalPolicyConfigurationJson() {
return JSON.parse(JSON.stringify(this.loopJsonCache["operationalPolicies"]["0"]["configurationsJson"]));
}
@@ -59,15 +58,15 @@ class LoopCache {
return JSON.parse(JSON.stringify(this.loopJsonCache["operationalPolicies"]));
}
- getGlobalProperty() {
+ getGlobalProperties() {
return JSON.parse(JSON.stringify(this.loopJsonCache["globalPropertiesJson"]));
}
- getDeploymentProperties() {
+ getDcaeDeploymentProperties() {
return JSON.parse(JSON.stringify(this.loopJsonCache["globalPropertiesJson"]["dcaeDeployParameters"]));
}
- getMsJson(type) {
+ getMicroServicesJsonForType(type) {
var msProperties = this.loopJsonCache["microServicePolicies"];
for (var policy in msProperties) {
if (msProperties[policy]["name"] === type) {
@@ -77,7 +76,7 @@ class LoopCache {
return null;
}
- getMsProperty(type) {
+ getMicroServiceProperties(type) {
var msProperties = this.loopJsonCache["microServicePolicies"];
for (var policy in msProperties) {
if (msProperties[policy]["name"] === type) {
@@ -89,7 +88,7 @@ class LoopCache {
return null;
}
- getMsUI(type) {
+ getMicroServiceJsonRepresentationForType(type) {
var msProperties = this.loopJsonCache["microServicePolicies"];
for (var policy in msProperties) {
if (msProperties[policy]["name"] === type) {
@@ -114,16 +113,4 @@ class LoopCache {
getComponentStates() {
return this.loopJsonCache.components;
}
-
- get getLoopJsonCache() {
- return this.loopJsonCache;
- }
-
- set setLoopJsonCache(newJson) {
- this.loopJsonCache = newJson;
- }
}
-
-export const LOOP_CACHE = new LoopCache(require('./example.json'));
-
-export default LoopCache;
diff --git a/ui-react/src/api/LoopService.js b/ui-react/src/api/LoopService.js
index f59f45763..2813a7c08 100644
--- a/ui-react/src/api/LoopService.js
+++ b/ui-react/src/api/LoopService.js
@@ -22,55 +22,62 @@
export default class LoopService {
static getLoopNames() {
- const url = '/restservices/clds/v2/loop/getAllNames';
- const options = {
- method: 'GET'
- };
- return fetch(url,options)
- .then(function (response) {
- if (response.ok) {
- console.log("GetLoopNames response received: ", response.status);
- return response.json();
- } else {
- let errorMsg = "GetLoopNames failed with status code: " + response.status;
- console.error(errorMsg);
- return Promise.reject(errorMsg);
- }
- })
- .then(function (data) {
- return data;
- })
- .catch(function(error) {
- console.error("GetLoopNames error received",error);
- return Promise.reject(error);
- });
+ return fetch('/restservices/clds/v2/loop/getAllNames', { method: 'GET', credentials: 'include', })
+ .then(function (response) {
+ console.debug("GetLoopNames response received: ", response.status);
+ if (response.ok) {
+ return response.json();
+ } else {
+ console.error("GetLoopNames query failed");
+ return {};
+ }
+ })
+ .catch(function (error) {
+ console.error("GetLoopNames error received", error);
+ return {};
+ });
}
static getLoop(loopName) {
- const url = '/restservices/clds/v2/loop/' + loopName;
- const options = {
+ return fetch('/restservices/clds/v2/loop/' + loopName, {
method: 'GET',
headers: {
"Content-Type": "application/json"
- }
- };
- return fetch(url,options)
- .then(function (response) {
- if (response.ok) {
- console.log("GetLoop response received: ", response.status);
- return response.json();
- } else {
- let errorMsg = "GetLoop failed with status code: " + response.status;
- console.error(errorMsg);
- return Promise.reject(errorMsg);
- }
+ },
+ credentials: 'include',
})
- .then(function (data) {
- return data;
+ .then(function (response) {
+ console.debug("GetLoop response received: ", response.status);
+ if (response.ok) {
+ return response.json();
+ } else {
+ console.error("GetLoop query failed");
+ return {};
+ }
+ })
+ .catch(function (error) {
+ console.error("GetLoop error received", error);
+ return {};
+ });
+ }
+
+ static getSvg(loopName) {
+ return fetch('/restservices/clds/v2/loop/svgRepresentation/' + loopName, {
+ method: 'GET',
+ credentials: 'include',
})
- .catch(function(error) {
- console.error("GetLoop error received",error);
- return Promise.reject(error);
- });
+ .then(function (response) {
+ console.debug("svgRepresentation response received: ", response.status);
+ if (response.ok) {
+ return response.text();
+ } else {
+ console.error("svgRepresentation query failed");
+ return "";
+ }
+ })
+ .catch(function (error) {
+ console.error("svgRepresentation error received", error);
+ return "";
+ });
}
}
diff --git a/ui-react/src/api/UserService.js b/ui-react/src/api/UserService.js
index 814539551..8f53d7b8a 100644
--- a/ui-react/src/api/UserService.js
+++ b/ui-react/src/api/UserService.js
@@ -22,28 +22,29 @@
*/
export default class UserService {
-
- static LOGIN() {
+ static notLoggedUserName='Anonymous';
+ static login() {
return fetch('/restservices/clds/v1/user/getUser', {
method: 'GET',
credentials: 'include',
})
.then(function (response) {
+ console.debug("getUser response received, status code:", response.status);
if (response.ok) {
- console.log("getUser response received: ", response.status);
return response.text();
} else {
- console.error("getUser failed with status code: ",response.status);
- return "Anonymous";
+ console.error("getUser response is nok");
+ return UserService.notLoggedUserName;
}
})
.then(function (data) {
- console.log ("User connected:",data)
+ console.info ("User connected:",data)
return data;
})
.catch(function(error) {
- console.error("getUser error received",error);
- return "Anonymous";
+ console.warn("getUser error received, user set to: ",UserService.notLoggedUserName);
+ console.error("getUser error:",error);
+ return UserService.notLoggedUserName;
});
}
}
diff --git a/ui-react/src/api/example.json b/ui-react/src/api/example.json
index f3cc9e189..108cf78e2 100644
--- a/ui-react/src/api/example.json
+++ b/ui-react/src/api/example.json
@@ -1,5 +1,5 @@
{
- "name": "LOOP_h2NMX_v1_0_ResourceInstanceName1_tca",
+ "name": "LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca",
"dcaeBlueprintId": "typeId-3a942643-a8f7-4e54-b2c1-eea8daba2b17",
"globalPropertiesJson": {
"dcaeDeployParameters": {