2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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 * ===================================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
24 app.service('cldsTemplateService', ['alertService', '$http', '$q', function (alertService, $http, $q) {
25 this.getTemplate = function(templateName){
27 console.log("///////////////cldsTemplateService");
31 var svcUrl = "/restservices/clds/v1/cldsTempate/template/" + templateName;
34 .success(function(data){
35 console.log("success");
39 .error(function(data){
41 def.reject("Open Model not successful");
46 this.getSavedTemplate=function(){
47 console.log("getSavedTemplate");
51 var svcUrl = "/restservices/clds/v1/cldsTempate/template-names";
54 .success(function(data){
55 console.log("success");
59 .error(function(data){
61 def.reject("Open Model not successful");
66 this.setTemplate = function(templateName, controlNamePrefixIn, bpmnTextIn, propTextIn){
68 console.log("setTemplate");
72 var svcUrl = "/restservices/clds/v1/clds/model/" + modelName;
73 var svcRequest = {name: templateName, controlNamePrefix: controlNamePrefixIn, bpmnText: bpmnTextIn, propText: propTextIn};
76 $http.put(svcUrl, svcRequest)
77 .success(function(data){
78 console.log("success");
82 .error(function(data){
84 def.reject("Save Model not successful");
89 this.processAction = function(uiAction, templateName, controlNamePrefixIn, bpmnTextIn, propTextIn,svgXmlIn){
91 console.log("processAction");
94 console.log("Generated SVG xml File...");
95 console.log(propTextIn);
96 var svcUrl = "/restservices/clds/v1/cldsTempate/template/"+templateName;
98 var svcRequest = {name: templateName, controlNamePrefix: controlNamePrefixIn, bpmnText: bpmnTextIn, propText: propTextIn, imageText:svgXmlIn};
99 $http.put(svcUrl, svcRequest)
100 .success(function(data){
101 console.log("success");
103 alertService.alertMessage("Action Successful:"+uiAction,1)
106 .error(function(data){
107 console.log("error");
108 def.reject(" not successful");
109 alertService.alertMessage("Action Failure:"+uiAction,2)
115 this.checkPermittedActionCd = function(permittedActionCd, menuText, actionCd){
116 console.log("checkPermittedActionCd");
117 if ( permittedActionCd.indexOf(actionCd) > -1 ) {
118 document.getElementById(menuText).classList.remove('ThisLink');
120 document.getElementById(menuText).classList.add('ThisLink');
123 this.processActionResponse = function(templateName, pars){
124 console.log("processActionResponse");
125 // populate control name (prefix and uuid here)
126 var controlNamePrefix = pars.controlNamePrefix;
127 var controlNameUuid = pars.controlNameUuid;
129 var headerText = "Closed Loop Modeler - " + templateName;
130 if ( controlNameUuid != null ) {
131 var actionCd = pars.event.actionCd;
132 var actionStateCd = pars.event.actionStateCd;
133 // headerText = headerText + " [" + controlNamePrefix + controlNameUuid + "] [" + actionCd + ":" + actionStateCd + "]";
134 headerText = headerText + " [" + controlNamePrefix + controlNameUuid + "]";
137 document.getElementById("modeler_name").textContent = headerText;
140 // enable menu options
141 document.getElementById('Save Template').classList.remove('ThisLink');
142 document.getElementById('Template Properties').classList.remove('ThisLink');
143 document.getElementById('Test').classList.remove('ThisLink');
144 if(!pars.newTemplate){
145 document.getElementById('Revert Template Changes').classList.remove('ThisLink');
147 document.getElementById('Close Template').classList.remove('ThisLink');
149 document.getElementById('Refresh Status').classList.remove('ThisLink');
150 //disable save/properties for model
151 document.getElementById('Save CL').classList.add('ThisLink');
152 document.getElementById('Properties CL').classList.add('ThisLink');
153 document.getElementById('Revert Model Changes').classList.add('ThisLink');
154 document.getElementById('Close Model').classList.add('ThisLink');
155 document.getElementById('Refresh ASDC').classList.add('ThisLink');
156 document.getElementById('Running Instances').classList.add('ThisLink');