2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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 * ===================================================================
31 function(alertService, $http, $q, $rootScope) {
33 function checkIfElementType(name) {
34 //This will open the methods located in the app.js
35 if (undefined == name) {
37 }else if (name === "OperationalPolicy"){
40 $rootScope.selectedBoxName = name;
44 this.toggleDeploy = function(uiAction, modelName) {
45 var svcAction = uiAction.toLowerCase();
46 var deployUrl = "/restservices/clds/v2/loop/" + svcAction + "Loop/" + modelName;
49 $http.put(deployUrl).success(
52 alertService.alertMessage("Action Successful: " + svcAction, 1)
53 // update deploymentID, lastUpdatedStatus
54 setLastComputedState(data.lastComputedState);
55 setDeploymentStatusURL(data.dcaeDeploymentStatusUrl);
56 setDeploymentID(data.dcaeDeploymentId);
57 setStatus(data.lastComputedState);
58 enableDisableMenuOptions();
62 alertService.alertMessage("Action Failure: " + svcAction, 2);
63 def.reject(svcAction + " not successful");
67 this.getModel = function(modelName) {
70 var svcUrl = "/restservices/clds/v2/loop/" + modelName;
71 $http.get(svcUrl).success(function(data) {
73 setStatus(data.lastComputedState);
75 }).error(function(data) {
76 def.reject("Open Model not successful");
80 this.getSavedModel = function() {
83 var svcUrl = "/restservices/clds/v2/loop/getAllNames";
84 $http.get(svcUrl).success(function(data) {
87 }).error(function(data) {
89 def.reject("Open Model not successful");
93 this.processAction = function(uiAction, modelName) {
96 var svcAction = uiAction.toLowerCase();
97 var svcUrl = "/restservices/clds/v2/loop/" + svcAction + "/" + modelName;
99 $http.put(svcUrl).success(
102 alertService.alertMessage("Action Successful: " + svcAction, 1)
103 // update deploymentID, lastUpdatedStatus
104 setLastComputedState(data.lastComputedState);
105 setDeploymentStatusURL(data.dcaeDeploymentStatusUrl);
106 setDeploymentID(data.dcaeDeploymentId);
110 alertService.alertMessage("Action Failure: " + svcAction, 2);
111 def.reject(svcAction + " not successful");
116 this.manageAction = function(modelName, typeId, typeName) {
118 var def = $q.defer();
121 url : "/restservices/clds/v1/clds/getDispatcherInfo",
129 $http(config).success(function(data) {
132 }).error(function(data) {
134 def.reject("manage action not successful");
138 this.processActionResponse = function(modelName) {
139 // populate control name (prefix and uuid here)
140 $("#loop_name").text(getLoopName());
141 manageCLImage(modelName);
142 enableDisableMenuOptions();
144 this.refreshStatus = function(modelName) {
145 var def = $q.defer();
147 var svcUrl = "/restservices/clds/v2/loop/getstatus/" + modelName;
148 $http.get(svcUrl).success(function(data) {
149 setStatus(data.lastComputedState);
151 }).error(function(data) {
152 def.reject("Refresh Status not successful");
155 enableDisableMenuOptions();
157 function setStatus(status) {
158 // apply color to status
159 var statusColor = 'white';
160 if (status.trim() === "DESIGN") {
162 } else if (status.trim() === "DISTRIBUTED") {
164 } else if (status.trim() === "SUBMITTED") {
165 statusColor = 'green'
166 } else if (status.trim() === "STOPPED") {
168 } else if (status.trim() === "DELETING") {
170 } else if (status.trim() === "ERROR") {
171 statusColor = 'orange'
172 } else if (status.trim() === "UNKNOWN") {
177 var statusMsg = '<span style="background-color:'
179 + ';-moz-border-radius: 50px; -webkit-border-radius: 50px; border-radius: 50px;"> '
180 + status + ' </span>';
182 if ($("#status_clds").length >= 1)
183 $("#status_clds").remove();
184 $("#activity_modeler")
186 '<span id="status_clds" style="position: absolute; left: 61%;top: 151px; font-size:20px;">Status: '
187 + statusMsg + '</span>');
189 function manageCLImage(modelName) {
190 getModelImage(modelName).then(function(pars) {
192 if ($("#svgContainer").length > 0)
193 $("#svgContainer").remove();
194 $("#js-canvas").append(
195 "<span id=\"svgContainer\">" + svg + "</span>");
196 $("#svgContainer svg").attr('width', '100%');
197 $("#svgContainer svg").attr('height', '100%');
198 $("#svgContainer").click(
200 var name = $($($($(event.target).parent()).parent()).parent()).attr("data-element-id")
201 checkIfElementType(name)
206 enableDisableMenuOptions = function() {
208 enableAllActionMenu();
210 getModelImage = function(modelName) {
211 var def = $q.defer();
213 var svcUrl = "/restservices/clds/v2/loop/svgRepresentation/" + modelName;
214 $http.get(svcUrl).success(function(data) {
216 }).error(function(data) {
217 def.reject("Not able to get the model image");