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) {
117 var mySelectObj = $(mySelect);
118 if (! mySelectObj.parents(".multiselect-native-select")) {
119 // keep native for this one
123 if (mySelectObj.parents(".multiselect-native-select").length > 0) {
124 var selectDrop = mySelectObj.parent(".multiselect-native-select").find("select");
125 mySelectObj.parent(".multiselect-native-select").parent().html(selectDrop);
133 if (mySelectObj.attr("multiple")
134 && mySelectObj.attr("multiple") != 'false') {
135 options.includeSelectAllOption = true;
138 if (mySelectObj.attr("enableFilter")
139 && mySelectObj.attr("enableFilter") != 'false') {
140 options.enableCaseInsensitiveFiltering = true;
141 options.enableFiltering = true;
144 mySelectObj.multiselect(options);
148 function loadSharedPropertyByService(onChangeUUID, refresh, callBack) {
149 var uuid = onChangeUUID;
150 if (uuid === undefined) {
151 uuid = elementMap["global"] && elementMap["global"].length > 0 ?
152 elementMap["global"][0].value : "";
153 } else if (uuid === "") {
155 if ($("#vf").length > 0)
156 $("#vf").empty().multiselect("refresh");
157 if ($("#location").length > 0)
158 $("#location").empty().multiselect("refresh");
159 if ($("#alarmCondition").length > 0)
160 $("#alarmCondition").empty().multiselect("refresh");
164 serviceUrl = '/restservices/clds/v1/clds/properties/' + uuid;
166 serviceUrl = '/restservices/clds/v1/clds/properties/' + uuid + '?refresh=true';
173 success: function(data) {
177 $("#paramsWarnrefresh").hide();
179 if ($("#paramsWarn")) {
180 $("#paramsWarn").hide();
182 if (callBack && _.isFunction(callBack)) {
186 error: function(s, a, err) {
188 $("#paramsWarnrefresh").show();
190 if ($("#paramsWarn")) {
191 $("#paramsWarn").show();
194 $('#servName').text($("#service option:selected").text());
195 if (callBack && _.isFunction(callBack)) {
206 //vf_Services=share['shared']['byService'][uuid];
207 //location_values = share['global']['location'];
210 function loadSharedPropertyByServiceProperties(callBack) {
214 url: '/restservices/clds/v1/clds/properties/',
215 success: function(data) {
218 if (callBack && _.isFunction(callBack)) {
222 error: function(s, a, err) {
223 $('#servName').text($("#service option:selected").text());
224 if (callBack && _.isFunction(callBack)) {
233 function setASDCFields() {
234 if (vf_Services === null || vf_Services === undefined) {
235 loadSharedPropertyByService()
238 $("#vf").empty().multiselect("refresh");
239 $("#location").empty().multiselect("refresh");
240 $("#actionSet").empty().multiselect("refresh");
241 $("#vfc").empty().multiselect("refresh");
242 $("#paramsWarn").hide();
243 var uuid = Object.keys(vf_Services['shared']['byService'])[0];
245 var vf_values = vf_Services['shared']['byService'][uuid] &&
246 vf_Services['shared']['byService'][uuid]['vf'] &&
247 _.keys(vf_Services['shared']['byService'][uuid]['vf']).length > 0 ?
248 vf_Services['shared']['byService'][uuid]['vf'] : null;
251 for (let e in elementMap["global"]) {
252 if (elementMap['global'][e].name === "vf") {
253 selectedVF = elementMap['global'][e].value[0]
257 var vfc_values2 = selectedVF &&
258 vf_Services['shared']['byVf'][selectedVF] &&
259 vf_Services['shared']['byVf'][selectedVF]['vfc'] &&
260 _.keys(vf_Services['shared']['byVf'][selectedVF]['vfc']).length > 0 ?
261 vf_Services['shared']['byVf'][selectedVF]['vfc'] : null;
264 for (key in vf_values) {
265 if ($("#vf").length > 0) {
266 $("#vf").append("<option value=\"" + key + "\">" + vf_values[key] + "</opton>")
269 $("#vf").multiselect("rebuild");
272 var location_values = vf_Services['global']['location'];
273 if (location_values) {
274 for (key in location_values) {
275 if ($("#location").length > 0) {
276 $("#location").append("<option value=\"" + key + "\">" + location_values[key] + "</opton>")
279 $("#location").multiselect("rebuild");
282 var actionSet_values = vf_Services['global']['actionSet'];
283 if (actionSet_values) {
284 for (key in actionSet_values) {
285 if ($("#actionSet").length > 0) {
286 $("#actionSet").append("<option value=\"" + key + "\">" + actionSet_values[key] + "</opton>")
289 $("#actionSet").multiselect("rebuild");
293 $("#vfc").append("<option value=\"\"></opton>");
294 for (key in vfc_values2) {
295 if ($("#vfc").length > 0) {
296 $("#vfc").append("<option value=\"" + key.split("\"").join("") + "\">" + vfc_values2[key] + "</opton>")
299 $("#vfc").multiselect("rebuild");
301 if ($("#vfc").length > 0 && !vfc_values2) {
304 if ($("#vf").length > 0 && !vf_values) {
307 if ($("#location").length > 0 && !location_values) {
311 function showWarn() {
312 $("#paramsWarn").show();
313 $('#servName').text($("#service option:selected").text());
321 //Typically used when opening a new model/template
322 function reloadDefaultVariables(isTemp) {
328 $(window).load(function() {
331 url: '/restservices/clds/v1/clds/properties',
332 success: function(data) {
334 defaults_props = data;
336 error: function(s, a, err) {