summaryrefslogtreecommitdiffstats
path: root/ui-react/src/api/LoopService.js
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2019-07-15 17:26:18 +0200
committersebdet <sebastien.determe@intl.att.com>2019-07-16 23:23:58 +0200
commit493c3839fb6807512218165fd8a3a6efe1933fb9 (patch)
treed5b71a3a1fc554270ae6b4ec138058fb378a732d /ui-react/src/api/LoopService.js
parent8bd462f6dc4a714b1680cb11f525c05445d3da33 (diff)
SVG Rendering
SVG rendering draft for Config and operational policies management + call to back-end Issue-ID: CLAMP-422 Change-Id: Ia3ca4223e283d0cd56d98fb1871fd3b2880940ec Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'ui-react/src/api/LoopService.js')
-rw-r--r--ui-react/src/api/LoopService.js91
1 files changed, 49 insertions, 42 deletions
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 "";
+ });
}
}