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.toLowerCase().indexOf("policy") >= 0){
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 setLastUpdatedStatus(data.lastUpdatedStatus);
55 setDeploymentStatusURL(data.dcaeDeploymentStatusUrl);
56 setDeploymentID(data.dcaeDeploymentId);
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) {
74 }).error(function(data) {
75 def.reject("Open Model not successful");
79 this.getSavedModel = function() {
82 var svcUrl = "/restservices/clds/v2/loop/getAllNames";
83 $http.get(svcUrl).success(function(data) {
86 }).error(function(data) {
88 def.reject("Open Model not successful");
92 this.processAction = function(uiAction, modelName) {
95 var svcAction = uiAction.toLowerCase();
96 var svcUrl = "/restservices/clds/v2/loop/" + svcAction + "/" + modelName;
98 $http.put(svcUrl).success(
101 alertService.alertMessage("Action Successful: " + svcAction, 1)
102 // update deploymentID, lastUpdatedStatus
103 setLastUpdatedStatus(data.lastUpdatedStatus);
104 setDeploymentStatusURL(data.dcaeDeploymentStatusUrl);
105 setDeploymentID(data.dcaeDeploymentId);
107 enableDisableMenuOptions();
111 alertService.alertMessage("Action Failure: " + svcAction, 2);
112 def.reject(svcAction + " not successful");
117 this.manageAction = function(modelName, typeId, typeName) {
119 var def = $q.defer();
122 url : "/restservices/clds/v1/clds/getDispatcherInfo",
130 $http(config).success(function(data) {
133 }).error(function(data) {
135 def.reject("manage action not successful");
139 this.processActionResponse = function(modelName) {
140 // populate control name (prefix and uuid here)
141 $("#loop_name").text(getLoopName());
143 manageCLImage(modelName);
144 enableDisableMenuOptions();
146 this.processRefresh = function() {
148 enableDisableMenuOptions();
150 function setStatus() {
151 var status = getLastUpdatedStatus();
152 // apply color to status
153 var statusColor = 'white';
154 if (status.trim() === "DESIGN") {
156 } else if (status.trim() === "DISTRIBUTED") {
158 } else if (status.trim() === "ACTIVE") {
159 statusColor = 'green'
160 } else if (status.trim() === "STOPPED") {
162 } else if (status.trim() === "DELETING") {
164 } else if (status.trim() === "ERROR") {
165 statusColor = 'orange'
166 } else if (status.trim() === "UNKNOWN") {
171 var statusMsg = '<span style="background-color:'
173 + ';-moz-border-radius: 50px; -webkit-border-radius: 50px; border-radius: 50px;"> '
174 + status + ' </span>';
176 if ($("#status_clds").length >= 1)
177 $("#status_clds").remove();
178 $("#activity_modeler")
180 '<span id="status_clds" style="position: absolute; left: 61%;top: 151px; font-size:20px;">Status: '
181 + statusMsg + '</span>');
184 function manageCLImage(modelName) {
185 getModelImage(modelName).then(function(pars) {
187 if ($("#svgContainer").length > 0)
188 $("#svgContainer").remove();
189 $("#js-canvas").append(
190 "<span id=\"svgContainer\">" + svg + "</span>");
191 $("#svgContainer svg").attr('width', '100%');
192 $("#svgContainer svg").attr('height', '100%');
193 $("#svgContainer").click(
195 var name = $($($($(event.target).parent()).parent()).parent()).attr("data-element-id")
196 checkIfElementType(name)
201 enableDisableMenuOptions = function() {
203 //var status = getStatus();
204 //enableActionMenu(status);
205 enableAllActionMenu();
207 getModelImage = function(modelName) {
208 var def = $q.defer();
210 var svcUrl = "/restservices/clds/v2/loop/svgRepresentation/" + modelName;
211 $http.get(svcUrl).success(function(data) {
213 }).error(function(data) {
214 def.reject("Not able to get the model image");