2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END============================================
19 * ===================================================================
23 export default class TemplateService {
25 static getLoopNames() {
26 return fetch(window.location.pathname + 'restservices/clds/v2/loop/getAllNames', { method: 'GET', credentials: 'same-origin' })
27 .then(function (response) {
28 console.debug("getLoopNames response received: ", response.status);
30 return response.json();
32 console.error("getLoopNames query failed");
36 .catch(function (error) {
37 console.error("getLoopNames error received", error);
42 static getAllLoopTemplates() {
43 return fetch(window.location.pathname + 'restservices/clds/v2/templates', { method: 'GET', credentials: 'same-origin', })
44 .then(function (response) {
45 console.debug("getAllLoopTemplates response received: ", response.status);
47 return response.json();
49 console.error("getAllLoopTemplates query failed");
53 .catch(function (error) {
54 console.error("getAllLoopTemplates error received", error);
59 static getDictionary() {
60 return fetch(window.location.pathname + 'restservices/clds/v2/dictionary/', { method: 'GET', credentials: 'same-origin', })
61 .then(function (response) {
62 console.debug("getDictionary response received: ", response.status);
64 return response.json();
66 console.error("getDictionary query failed");
70 .catch(function (error) {
71 console.error("getDictionary error received", error);
76 static getDictionaryElements(dictionaryName) {
77 return fetch(window.location.pathname + 'restservices/clds/v2/dictionary/' + dictionaryName, {
80 "Content-Type": "application/json",
82 credentials: 'same-origin',
84 .then(function (response) {
85 console.debug("getDictionaryElements response received: ", response.status);
87 return response.json();
89 console.error("getDictionaryElements query failed");
93 .catch(function (error) {
94 console.error("getDictionaryElements error received", error);
99 static insDictionary(jsonData) {
100 console.log("dictionaryName is", jsonData.name)
101 return fetch(window.location.pathname + 'restservices/clds/v2/dictionary/', {
103 credentials: 'same-origin',
105 "Content-Type": "application/json",
107 body: JSON.stringify(jsonData)
109 .then(function (response) {
110 console.debug("insDictionary response received: ", response.status);
112 return response.status;
114 var errorMessage = response.status;
115 console.error("insDictionary query failed", response.status);
119 .catch(function (error) {
120 console.error("insDictionary error received", error);
125 static insDictionaryElements(jsonData) {
126 console.log("dictionaryName is", jsonData.name)
127 return fetch(window.location.pathname + 'restservices/clds/v2/dictionary/' + jsonData.name, {
129 credentials: 'same-origin',
131 "Content-Type": "application/json",
133 body: JSON.stringify(jsonData)
135 .then(function (response) {
136 console.debug("insDictionary response received: ", response.status);
138 return response.status;
140 var errorMessage = response.status;
141 console.error("insDictionary query failed", response.status);
145 .catch(function (error) {
146 console.error("insDictionary error received", error);
151 static deleteDictionary(dictionaryName) {
152 console.log("inside templaemenu service", dictionaryName)
153 return fetch(window.location.pathname + 'restservices/clds/v2/dictionary/' + dictionaryName, {
156 "Content-Type": "application/json",
158 credentials: 'same-origin',
160 .then(function (response) {
161 console.debug("deleteDictionary response received: ", response.status);
163 return response.status;
165 console.error("deleteDictionary query failed");
169 .catch(function (error) {
170 console.error("deleteDictionary error received", error);
175 static deleteDictionaryElements(dictionaryData) {
176 return fetch(window.location.pathname + 'restservices/clds/v2/dictionary/' + dictionaryData.name + '/elements/' + dictionaryData.shortName , {
179 "Content-Type": "application/json",
181 credentials: 'same-origin',
183 .then(function (response) {
184 console.debug("deleteDictionary response received: ", response.status);
186 return response.status;
188 console.error("deleteDictionary query failed");
192 .catch(function (error) {
193 console.error("deleteDictionary error received", error);