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);
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); }, 100);
113 function setMultiSelect() {
114 $("select").each(function(index, mySelect) {
115 if ($(mySelect).parents(".multiselect-native-select") &&
116 $(mySelect).parents(".multiselect-native-select").length < 1) {
117 if (!$(mySelect).attr("multiple")) {
118 if ($(mySelect).attr("enableFilter")) {
119 $(mySelect).multiselect({
124 $(mySelect).multiselect({
126 enableFiltering: true,
132 $(mySelect).multiselect({
134 includeSelectAllOption: true,
135 enableFiltering: true,
137 enableCaseInsensitiveFiltering: true
141 } else if ($(mySelect).parents(".multiselect-native-select") &&
142 $(mySelect).parents(".multiselect-native-select").length > 0) {
143 var selectDrop = $(mySelect).parent(".multiselect-native-select").find("select");
144 $(mySelect).parent(".multiselect-native-select").parent().html(selectDrop);
145 if (!$(mySelect).attr("multiple")) {
146 if ($(mySelect).attr("enableFilter")) {
147 $(mySelect).multiselect({
152 $(mySelect).multiselect({
154 enableFiltering: true,
159 $(mySelect).multiselect({
161 includeSelectAllOption: true,
162 enableFiltering: true,
164 enableCaseInsensitiveFiltering: true
169 //refeshMultiSelect();
171 function loadSharedPropertyByService(onChangeUUID,refresh, callBack) {
172 var uuid = onChangeUUID;
173 if (uuid === undefined){
174 uuid = elementMap["global"] && elementMap["global"].length>0 ?
175 elementMap["global"][0].value : "";
176 } else if (uuid === "") {
178 if ($("#vf").length > 0)
179 $("#vf").empty().multiselect("refresh");
180 if ($("#location").length > 0)
181 $("#location").empty().multiselect("refresh");
182 if ($("#alarmCondition").length > 0)
183 $("#alarmCondition").empty().multiselect("refresh");
187 serviceUrl = '/restservices/clds/v1/clds/properties/' + uuid;
189 serviceUrl = '/restservices/clds/v1/clds/properties/' + uuid +'?refresh=true';
196 success: function(data) {
200 $("#paramsWarnrefresh").hide();
202 if($("#paramsWarn")){
203 $("#paramsWarn").hide();
205 if(callBack && _.isFunction(callBack)){
209 error: function(s, a, err) {
211 $("#paramsWarnrefresh").show();
213 if($("#paramsWarn")){
214 $("#paramsWarn").show();
217 $('#servName').text($("#service option:selected").text());
218 if(callBack && _.isFunction(callBack)){
229 //vf_Services=share['shared']['byService'][uuid];
230 //location_values = share['global']['location'];
233 function loadSharedPropertyByServiceProperties(callBack) {
237 url: '/restservices/clds/v1/clds/properties/',
238 success: function(data) {
241 if(callBack && _.isFunction(callBack)){
245 error: function(s, a, err) {
246 $('#servName').text($("#service option:selected").text());
247 if(callBack && _.isFunction(callBack)){
256 function setASDCFields() {
257 if (vf_Services === null || vf_Services === undefined) {
258 loadSharedPropertyByService()
261 $("#vf").empty().multiselect("refresh");
262 $("#location").empty().multiselect("refresh");
263 $("#actionSet").empty().multiselect("refresh");
264 $("#vfc").empty().multiselect("refresh");
265 $("#paramsWarn").hide();
266 var uuid = Object.keys(vf_Services['shared']['byService'])[0];
268 var vf_values = vf_Services['shared']['byService'][uuid] &&
269 vf_Services['shared']['byService'][uuid]['vf'] &&
270 _.keys(vf_Services['shared']['byService'][uuid]['vf']).length > 0 ?
271 vf_Services['shared']['byService'][uuid]['vf'] : null;
274 for (let e in elementMap["global"]) {
275 if (elementMap['global'][e].name === "vf") {
276 selectedVF = elementMap['global'][e].value[0]
280 var vfc_values2 = selectedVF &&
281 vf_Services['shared']['byVf'][selectedVF] &&
282 vf_Services['shared']['byVf'][selectedVF]['vfc'] &&
283 _.keys(vf_Services['shared']['byVf'][selectedVF]['vfc']).length > 0 ?
284 vf_Services['shared']['byVf'][selectedVF]['vfc'] : null;
287 for (key in vf_values) {
288 if ($("#vf").length > 0) {
289 $("#vf").append("<option value=\"" + key + "\">" + vf_values[key] + "</opton>")
292 $("#vf").multiselect("rebuild");
295 var location_values = vf_Services['global']['location'];
296 if (location_values) {
297 for (key in location_values) {
298 if ($("#location").length > 0) {
299 $("#location").append("<option value=\"" + key + "\">" + location_values[key] + "</opton>")
302 $("#location").multiselect("rebuild");
305 var actionSet_values = vf_Services['global']['actionSet'];
306 if (actionSet_values) {
307 for (key in actionSet_values) {
308 if ($("#actionSet").length > 0) {
309 $("#actionSet").append("<option value=\"" + key + "\">" + actionSet_values[key] + "</opton>")
312 $("#actionSet").multiselect("rebuild");
316 $("#vfc").append("<option value=\"\"></opton>");
317 for (key in vfc_values2) {
318 if ($("#vfc").length > 0) {
319 $("#vfc").append("<option value=\"" + key.split("\"").join("") + "\">" + vfc_values2[key] + "</opton>")
322 $("#vfc").multiselect("rebuild");
324 if($("#vfc").length > 0 && !vfc_values2){
327 if($("#vf").length > 0 && !vf_values){
330 if($("#location").length > 0 && !location_values){
334 function showWarn() {
335 $("#paramsWarn").show();
336 $('#servName').text($("#service option:selected").text());
344 //Typically used when opening a new model/template
345 function reloadDefaultVariables(isTemp) {
351 $(window).load(function() {
354 url: '/restservices/clds/v1/clds/properties',
355 success: function(data) {
357 defaults_props = data;
359 error: function(s, a, err) {