2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
24 export default class LoopActionService{
26 static performAction(cl_name, uiAction) {
27 console.info("LoopActionService perform action: " + uiAction + " closedloopName=" + cl_name);
28 const svcAction = uiAction.toLowerCase();
29 return fetch("/restservices/clds/v2/loop/" + svcAction + "/" + cl_name, {
31 credentials: 'same-origin'
33 .then(function (response) {
35 return response.json();
37 return Promise.reject("Perform action failed with code:" + response.status);
40 .then(function (data) {
41 console.info("Action Successful: " + uiAction);
44 .catch(function(error) {
45 console.info("Action Failure: " + uiAction);
46 return Promise.reject(error);
51 static refreshStatus(cl_name) {
52 console.info("Refresh the status for closedloopName=" + cl_name);
54 return fetch("/restservices/clds/v2/loop/getstatus/" + cl_name, {
56 credentials: 'same-origin'
58 .then(function (response) {
60 return response.json();
62 return Promise.reject("Refresh status failed with code:" + response.status);
65 .then(function (data) {
66 console.info ("Refresh status Successful");
69 .catch(function(error) {
70 console.info ("Refresh status failed:", error);
71 return Promise.reject(error);