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 * ===================================================================
25 //When element is first created it should have a red box because it hasn't been edited
26 function newElementProcessor(id) {
27 if ($('g[data-element-id="' + id + '"]').length > 0) {
29 var _idNode = $('g[data-element-id="' + id + '"]')
30 _idNode.children("rect").each(function() {
31 if ($(this).attr('class') === 'djs-outline') {
32 $(this).attr('class', "djs-outline-no-property-saved")
33 $(this).attr('fill', 'red')
40 function saveProperties(form) {
41 elementMap[lastElementSelected] = form;
42 totalJsonProperties = JSON.stringify(elementMap);
44 //Take off the red border because the element has been edited
45 if ($('g[data-element-id="' + lastElementSelected + '"]').length > 0) {
46 var _idNode = $('g[data-element-id="' + lastElementSelected + '"]')
47 _idNode.children("rect").each(function() {
48 if ($(this).attr('class') === 'djs-outline-no-property-saved') {
49 $(this).attr('class', "djs-outline")
50 $(this).attr('fill', 'none')
56 function saveGlobalProperties(form) {
57 elementMap["global"] = form;
59 var isObject = function(a) {
60 return (!!a) && (a.constructor === Object);
63 function loadPropertyWindow(type) {
65 if ($("#add_one_more").length == 1) {
66 $("#add_one_more").off();
67 $("#add_one_more").click(function(event) {
68 event.preventDefault();
71 $("input,#savePropsBtn").attr("disabled", "");
72 $(".modal-body button").attr("disabled", "");
73 ($("select:not([multiple])")).multiselect("disable");
76 var props = defaults_props[type];
79 if (isObject(props[p])) {
80 var mySelect = $('#' + p);
81 if (p == "operator") {
82 $.each(props[p], function(val, text) {
84 $('<option></option>').val(val).html(val)
88 $.each(props[p], function(val, text) {
90 $('<option></option>').val(val).html(text)
96 var ms = new Date().getTime();
97 props[p] = "Policy" + ms;
99 $("#" + p).val(props[p])
102 setTimeout(function() {
103 setMultiSelect(type);
110 function setMultiSelect() {
111 $("select").each(function(index, mySelect) {
113 var mySelectObj = $(mySelect);
114 if (! mySelectObj.parents(".multiselect-native-select")) {
115 // keep native for this one
119 if (mySelectObj.parents(".multiselect-native-select").length > 0) {
120 var selectDrop = mySelectObj.parent(".multiselect-native-select").find("select");
121 mySelectObj.parent(".multiselect-native-select").parent().html(selectDrop);
129 if (mySelectObj.attr("multiple")
130 && mySelectObj.attr("multiple") != 'false') {
131 options.includeSelectAllOption = true;
134 if (mySelectObj.attr("enableFilter")
135 && mySelectObj.attr("enableFilter") != 'false') {
136 options.enableCaseInsensitiveFiltering = true;
137 options.enableFiltering = true;
140 mySelectObj.multiselect(options);
144 function loadSharedPropertyByService(onChangeUUID, refresh, callBack) {
145 var uuid = onChangeUUID;
146 if (uuid === undefined) {
147 uuid = elementMap["global"] && elementMap["global"].length > 0 ?
148 elementMap["global"][0].value : "";
151 serviceUrl = '/restservices/clds/v1/clds/properties/' + uuid;
153 serviceUrl = '/restservices/clds/v1/clds/properties/' + uuid + '?refresh=true';
160 success: function(data) {
161 vf_Services = JSON.parse(data);
164 $("#paramsWarnrefresh").hide();
166 if ($("#paramsWarn")) {
167 $("#paramsWarn").hide();
169 if (callBack && _.isFunction(callBack)) {
173 error: function(s, a, err) {
175 $("#paramsWarnrefresh").show();
177 if ($("#paramsWarn")) {
178 $("#paramsWarn").show();
181 $('#servName').text($("#service option:selected").text());
182 if (callBack && _.isFunction(callBack)) {
193 //vf_Services=share['shared']['byService'][uuid];
194 //location_values = share['global']['location'];
197 function loadSharedPropertyByServiceProperties(callBack) {
201 url: '/restservices/clds/v1/clds/properties/',
202 success: function(data) {
203 vf_Services = JSON.parse(data);
205 if (callBack && _.isFunction(callBack)) {
209 error: function(s, a, err) {
210 $('#servName').text($("#service option:selected").text());
211 if (callBack && _.isFunction(callBack)) {
220 function setASDCFields() {
221 if (vf_Services === null || vf_Services === undefined) {
222 loadSharedPropertyByService()
225 $("#vf").empty().multiselect("refresh");
226 $("#location").empty().multiselect("refresh");
227 $("#actionSet").empty().multiselect("refresh");
228 $("#vfc").empty().multiselect("refresh");
229 $("#paramsWarn").hide();
230 var uuid = Object.keys(vf_Services['shared']['byService'])[0];
232 var vf_values = vf_Services['shared']['byService'][uuid] &&
233 vf_Services['shared']['byService'][uuid]['vf'] &&
234 _.keys(vf_Services['shared']['byService'][uuid]['vf']).length > 0 ?
235 vf_Services['shared']['byService'][uuid]['vf'] : null;
238 for (let e in elementMap["global"]) {
239 if (elementMap['global'][e].name === "vf") {
240 selectedVF = elementMap['global'][e].value[0]
244 var vfc_values2 = selectedVF &&
245 vf_Services['shared']['byVf'][selectedVF] &&
246 vf_Services['shared']['byVf'][selectedVF]['vfc'] &&
247 _.keys(vf_Services['shared']['byVf'][selectedVF]['vfc']).length > 0 ?
248 vf_Services['shared']['byVf'][selectedVF]['vfc'] : null;
251 for (key in vf_values) {
252 if ($("#vf").length > 0) {
253 $("#vf").append("<option value=\"" + key + "\">" + vf_values[key] + "</opton>")
256 $("#vf").multiselect("rebuild");
259 var location_values = vf_Services['global']['location'];
260 if (location_values) {
261 for (key in location_values) {
262 if ($("#location").length > 0) {
263 $("#location").append("<option value=\"" + key + "\">" + location_values[key] + "</opton>")
266 $("#location").multiselect("rebuild");
269 var actionSet_values = vf_Services['global']['actionSet'];
270 if (actionSet_values) {
271 for (key in actionSet_values) {
272 if ($("#actionSet").length > 0) {
273 $("#actionSet").append("<option value=\"" + key + "\">" + actionSet_values[key] + "</opton>")
276 $("#actionSet").multiselect("rebuild");
280 $("#vfc").append("<option value=\"\"></opton>");
281 for (key in vfc_values2) {
282 if ($("#vfc").length > 0) {
283 $("#vfc").append("<option value=\"" + key.split("\"").join("") + "\">" + vfc_values2[key] + "</opton>")
286 $("#vfc").multiselect("rebuild");
288 if ($("#vfc").length > 0 && !vfc_values2) {
291 if ($("#vf").length > 0 && !vf_values) {
294 if ($("#location").length > 0 && !location_values) {
298 function showWarn() {
299 $("#paramsWarn").show();
300 $('#servName').text($("#service option:selected").text());
308 //Typically used when opening a new model/template
309 function reloadDefaultVariables(isTemp) {
314 $(window).on('load',function() {
317 url: '/restservices/clds/v1/clds/properties',
318 success: function(data) {
319 defaults_props = JSON.parse(data);
321 error: function(s, a, err) {