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 : "";
155 serviceUrl = '/restservices/clds/v1/clds/properties/' + uuid;
157 serviceUrl = '/restservices/clds/v1/clds/properties/' + uuid + '?refresh=true';
164 success: function(data) {
168 $("#paramsWarnrefresh").hide();
170 if ($("#paramsWarn")) {
171 $("#paramsWarn").hide();
173 if (callBack && _.isFunction(callBack)) {
177 error: function(s, a, err) {
179 $("#paramsWarnrefresh").show();
181 if ($("#paramsWarn")) {
182 $("#paramsWarn").show();
185 $('#servName').text($("#service option:selected").text());
186 if (callBack && _.isFunction(callBack)) {
197 //vf_Services=share['shared']['byService'][uuid];
198 //location_values = share['global']['location'];
201 function loadSharedPropertyByServiceProperties(callBack) {
205 url: '/restservices/clds/v1/clds/properties/',
206 success: function(data) {
209 if (callBack && _.isFunction(callBack)) {
213 error: function(s, a, err) {
214 $('#servName').text($("#service option:selected").text());
215 if (callBack && _.isFunction(callBack)) {
224 function setASDCFields() {
225 if (vf_Services === null || vf_Services === undefined) {
226 loadSharedPropertyByService()
229 $("#vf").empty().multiselect("refresh");
230 $("#location").empty().multiselect("refresh");
231 $("#actionSet").empty().multiselect("refresh");
232 $("#vfc").empty().multiselect("refresh");
233 $("#paramsWarn").hide();
234 var uuid = Object.keys(vf_Services['shared']['byService'])[0];
236 var vf_values = vf_Services['shared']['byService'][uuid] &&
237 vf_Services['shared']['byService'][uuid]['vf'] &&
238 _.keys(vf_Services['shared']['byService'][uuid]['vf']).length > 0 ?
239 vf_Services['shared']['byService'][uuid]['vf'] : null;
242 for (let e in elementMap["global"]) {
243 if (elementMap['global'][e].name === "vf") {
244 selectedVF = elementMap['global'][e].value[0]
248 var vfc_values2 = selectedVF &&
249 vf_Services['shared']['byVf'][selectedVF] &&
250 vf_Services['shared']['byVf'][selectedVF]['vfc'] &&
251 _.keys(vf_Services['shared']['byVf'][selectedVF]['vfc']).length > 0 ?
252 vf_Services['shared']['byVf'][selectedVF]['vfc'] : null;
255 for (key in vf_values) {
256 if ($("#vf").length > 0) {
257 $("#vf").append("<option value=\"" + key + "\">" + vf_values[key] + "</opton>")
260 $("#vf").multiselect("rebuild");
263 var location_values = vf_Services['global']['location'];
264 if (location_values) {
265 for (key in location_values) {
266 if ($("#location").length > 0) {
267 $("#location").append("<option value=\"" + key + "\">" + location_values[key] + "</opton>")
270 $("#location").multiselect("rebuild");
273 var actionSet_values = vf_Services['global']['actionSet'];
274 if (actionSet_values) {
275 for (key in actionSet_values) {
276 if ($("#actionSet").length > 0) {
277 $("#actionSet").append("<option value=\"" + key + "\">" + actionSet_values[key] + "</opton>")
280 $("#actionSet").multiselect("rebuild");
284 $("#vfc").append("<option value=\"\"></opton>");
285 for (key in vfc_values2) {
286 if ($("#vfc").length > 0) {
287 $("#vfc").append("<option value=\"" + key.split("\"").join("") + "\">" + vfc_values2[key] + "</opton>")
290 $("#vfc").multiselect("rebuild");
292 if ($("#vfc").length > 0 && !vfc_values2) {
295 if ($("#vf").length > 0 && !vf_values) {
298 if ($("#location").length > 0 && !location_values) {
302 function showWarn() {
303 $("#paramsWarn").show();
304 $('#servName').text($("#service option:selected").text());
312 //Typically used when opening a new model/template
313 function reloadDefaultVariables(isTemp) {
319 $(window).load(function() {
322 url: '/restservices/clds/v1/clds/properties',
323 success: function(data) {
325 defaults_props = data;
327 error: function(s, a, err) {