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 //When element is first created it should have a red box because it hasn't been edited
25 function newElementProcessor(id) {
26 if ($('g[data-element-id="' + id + '"]').length > 0) {
28 var _idNode = $('g[data-element-id="' + id + '"]')
29 _idNode.children("rect").each(function() {
30 if ($(this).attr('class') === 'djs-outline') {
31 $(this).attr('class', "djs-outline-no-property-saved")
32 $(this).attr('fill', 'red')
39 function saveProperties(form) {
40 elementMap[lastElementSelected] = form;
41 totalJsonProperties = JSON.stringify(elementMap);
43 //Take off the red border because the element has been edited
44 if ($('g[data-element-id="' + lastElementSelected + '"]').length > 0) {
45 var _idNode = $('g[data-element-id="' + lastElementSelected + '"]')
46 _idNode.children("rect").each(function() {
47 if ($(this).attr('class') === 'djs-outline-no-property-saved') {
48 $(this).attr('class', "djs-outline")
49 $(this).attr('fill', 'none')
55 function saveGlobalProperties(form) {
56 elementMap["global"] = form;
58 var isObject = function(a) {
59 return (!!a) && (a.constructor === Object);
62 function loadPropertyWindow(type) {
63 if (readOnly || readMOnly) {
64 if ($("#add_one_more").length == 1) {
65 $("#add_one_more").off();
66 $("#add_one_more").click(function(event) {
67 event.preventDefault();
70 $("input,#savePropsBtn").attr("disabled", "");
71 $(".modal-body button").attr("disabled", "");
72 ($("select:not([multiple])")).multiselect("disable");
76 $("textarea").attr("disabled", "");
77 $("#savePropsBtn").attr("disabled", "");
80 var props = defaults_props[type];
83 if (isObject(props[p])) {
84 var mySelect = $('#' + p);
85 if (p == "operator") {
86 $.each(props[p], function(val, text) {
88 $('<option></option>').val(val).html(val)
92 $.each(props[p], function(val, text) {
94 $('<option></option>').val(val).html(text)
100 var ms = new Date().getTime();
101 props[p] = "Policy" + ms;
103 $("#" + p).val(props[p])
106 setTimeout(function() {
107 setMultiSelect(type);
114 function setMultiSelect() {
115 $("select").each(function(index, mySelect) {
116 if ($(mySelect).parents(".multiselect-native-select") &&
117 $(mySelect).parents(".multiselect-native-select").length < 1) {
118 if (!$(mySelect).attr("multiple")) {
119 if ($(mySelect).attr("enableFilter")) {
120 $(mySelect).multiselect({
125 $(mySelect).multiselect({
127 enableFiltering: true,
133 $(mySelect).multiselect({
135 includeSelectAllOption: true,
136 enableFiltering: true,
138 enableCaseInsensitiveFiltering: true
142 } else if ($(mySelect).parents(".multiselect-native-select") &&
143 $(mySelect).parents(".multiselect-native-select").length > 0) {
144 var selectDrop = $(mySelect).parent(".multiselect-native-select").find("select");
145 $(mySelect).parent(".multiselect-native-select").parent().html(selectDrop);
146 if (!$(mySelect).attr("multiple")) {
147 if ($(mySelect).attr("enableFilter")) {
148 $(mySelect).multiselect({
153 $(mySelect).multiselect({
155 enableFiltering: true,
160 $(mySelect).multiselect({
162 includeSelectAllOption: true,
163 enableFiltering: true,
165 enableCaseInsensitiveFiltering: true
170 //refeshMultiSelect();
173 function loadSharedPropertyByService(onChangeUUID, refresh, callBack) {
174 var uuid = onChangeUUID;
175 if (uuid === undefined) {
176 uuid = elementMap["global"] && elementMap["global"].length > 0 ?
177 elementMap["global"][0].value : "";
178 } else if (uuid === "") {
180 if ($("#vf").length > 0)
181 $("#vf").empty().multiselect("refresh");
182 if ($("#location").length > 0)
183 $("#location").empty().multiselect("refresh");
184 if ($("#alarmCondition").length > 0)
185 $("#alarmCondition").empty().multiselect("refresh");
189 serviceUrl = '/restservices/clds/v1/clds/properties/' + uuid;
191 serviceUrl = '/restservices/clds/v1/clds/properties/' + uuid + '?refresh=true';
198 success: function(data) {
202 $("#paramsWarnrefresh").hide();
204 if ($("#paramsWarn")) {
205 $("#paramsWarn").hide();
207 if (callBack && _.isFunction(callBack)) {
211 error: function(s, a, err) {
213 $("#paramsWarnrefresh").show();
215 if ($("#paramsWarn")) {
216 $("#paramsWarn").show();
219 $('#servName').text($("#service option:selected").text());
220 if (callBack && _.isFunction(callBack)) {
231 //vf_Services=share['shared']['byService'][uuid];
232 //location_values = share['global']['location'];
235 function loadSharedPropertyByServiceProperties(callBack) {
239 url: '/restservices/clds/v1/clds/properties/',
240 success: function(data) {
243 if (callBack && _.isFunction(callBack)) {
247 error: function(s, a, err) {
248 $('#servName').text($("#service option:selected").text());
249 if (callBack && _.isFunction(callBack)) {
258 function setASDCFields() {
259 if (vf_Services === null || vf_Services === undefined) {
260 loadSharedPropertyByService()
263 $("#vf").empty().multiselect("refresh");
264 $("#location").empty().multiselect("refresh");
265 $("#actionSet").empty().multiselect("refresh");
266 $("#vfc").empty().multiselect("refresh");
267 $("#paramsWarn").hide();
268 var uuid = Object.keys(vf_Services['shared']['byService'])[0];
270 var vf_values = vf_Services['shared']['byService'][uuid] &&
271 vf_Services['shared']['byService'][uuid]['vf'] &&
272 _.keys(vf_Services['shared']['byService'][uuid]['vf']).length > 0 ?
273 vf_Services['shared']['byService'][uuid]['vf'] : null;
276 for (let e in elementMap["global"]) {
277 if (elementMap['global'][e].name === "vf") {
278 selectedVF = elementMap['global'][e].value[0]
282 var vfc_values2 = selectedVF &&
283 vf_Services['shared']['byVf'][selectedVF] &&
284 vf_Services['shared']['byVf'][selectedVF]['vfc'] &&
285 _.keys(vf_Services['shared']['byVf'][selectedVF]['vfc']).length > 0 ?
286 vf_Services['shared']['byVf'][selectedVF]['vfc'] : null;
289 for (key in vf_values) {
290 if ($("#vf").length > 0) {
291 $("#vf").append("<option value=\"" + key + "\">" + vf_values[key] + "</opton>")
294 $("#vf").multiselect("rebuild");
297 var location_values = vf_Services['global']['location'];
298 if (location_values) {
299 for (key in location_values) {
300 if ($("#location").length > 0) {
301 $("#location").append("<option value=\"" + key + "\">" + location_values[key] + "</opton>")
304 $("#location").multiselect("rebuild");
307 var actionSet_values = vf_Services['global']['actionSet'];
308 if (actionSet_values) {
309 for (key in actionSet_values) {
310 if ($("#actionSet").length > 0) {
311 $("#actionSet").append("<option value=\"" + key + "\">" + actionSet_values[key] + "</opton>")
314 $("#actionSet").multiselect("rebuild");
318 $("#vfc").append("<option value=\"\"></opton>");
319 for (key in vfc_values2) {
320 if ($("#vfc").length > 0) {
321 $("#vfc").append("<option value=\"" + key.split("\"").join("") + "\">" + vfc_values2[key] + "</opton>")
324 $("#vfc").multiselect("rebuild");
326 if ($("#vfc").length > 0 && !vfc_values2) {
329 if ($("#vf").length > 0 && !vf_values) {
332 if ($("#location").length > 0 && !location_values) {
336 function showWarn() {
337 $("#paramsWarn").show();
338 $('#servName').text($("#service option:selected").text());
346 //Typically used when opening a new model/template
347 function reloadDefaultVariables(isTemp) {
353 $(window).load(function() {
356 url: '/restservices/clds/v1/clds/properties',
357 success: function(data) {
359 defaults_props = data;
361 error: function(s, a, err) {