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) {
64 if ($("#add_one_more").length == 1) {
65 $("#add_one_more").off();
66 $("#add_one_more").click(function(event) {
67 event.preventDefault();
70 $("select,input").attr("disabled", "");
73 var props = defaults_props[type];
76 if (isObject(props[p])) {
77 var mySelect = $('#' + p);
78 $.each(props[p], function(val, text) {
80 $('<option></option>').val(val).html(text)
85 var ms = new Date().getTime();
86 props[p] = "Policy" + ms;
88 $("#" + p).val(props[p])
91 setTimeout(function(){
93 setMultiSelect(type); }, 100);
97 function setMultiSelect() {
98 $("select").each(function(index, mySelect) {
99 if ($(mySelect).parents(".multiselect-native-select") &&
100 $(mySelect).parents(".multiselect-native-select").length < 1) {
101 if (!$(mySelect).attr("multiple")) {
102 if ($(mySelect).attr("enableFilter")) {
103 $(mySelect).multiselect({
108 $(mySelect).multiselect({
110 enableFiltering: true,
116 $(mySelect).multiselect({
118 includeSelectAllOption: true,
119 enableFiltering: true,
121 enableCaseInsensitiveFiltering: true
125 } else if ($(mySelect).parents(".multiselect-native-select") &&
126 $(mySelect).parents(".multiselect-native-select").length > 0) {
127 var selectDrop = $(mySelect).parent(".multiselect-native-select").find("select");
128 $(mySelect).parent(".multiselect-native-select").parent().html(selectDrop);
129 if (!$(mySelect).attr("multiple")) {
130 if ($(mySelect).attr("enableFilter")) {
131 $(mySelect).multiselect({
136 $(mySelect).multiselect({
138 enableFiltering: true,
143 $(mySelect).multiselect({
145 includeSelectAllOption: true,
146 enableFiltering: true,
148 enableCaseInsensitiveFiltering: true
153 //refeshMultiSelect();
155 function loadSharedPropertyByService(onChangeUUID,refresh, callBack) {
156 var uuid = onChangeUUID
157 if (uuid === undefined){
158 uuid = elementMap["global"] && elementMap["global"].length>0 ?
159 elementMap["global"][0].value : "";
160 } else if (uuid === "") {
162 if ($("#vf").length > 0)
164 if ($("#location").length > 0)
165 $("#location").empty();
166 if ($("#alarmCondition").length > 0)
167 $("#alarmCondition").empty();
171 serviceUrl = '/restservices/clds/v1/clds/properties/' + uuid;
173 serviceUrl = '/restservices/clds/v1/clds/properties/' + uuid +'?refresh=true';
180 success: function(data) {
184 $("#paramsWarnrefresh").hide();
186 if($("#paramsWarn")){
187 $("#paramsWarn").hide();
189 if(callBack && _.isFunction(callBack)){
193 error: function(s, a, err) {
195 $("#paramsWarnrefresh").show();
197 if($("#paramsWarn")){
198 $("#paramsWarn").show();
201 $('#servName').text($("#service option:selected").text());
202 if(callBack && _.isFunction(callBack)){
212 //vf_Services=share['shared']['byService'][uuid];
213 //location_values = share['global']['location'];
216 function loadSharedPropertyByServiceProperties(callBack) {
220 url: '/restservices/clds/v1/clds/properties/',
221 success: function(data) {
224 if(callBack && _.isFunction(callBack)){
228 error: function(s, a, err) {
229 $('#servName').text($("#service option:selected").text());
230 if(callBack && _.isFunction(callBack)){
239 function setASDCFields() {
240 if (vf_Services === null || vf_Services === undefined) {
241 loadSharedPropertyByService()
245 $("#location").empty();
247 $("#paramsWarn").hide();
248 var uuid = Object.keys(vf_Services['shared']['byService'])[0];
249 var vf_values = vf_Services['shared']['byService'][uuid] &&
250 vf_Services['shared']['byService'][uuid]['vf'] &&
251 _.keys(vf_Services['shared']['byService'][uuid]['vf']).length > 0 ?
252 vf_Services['shared']['byService'][uuid]['vf'] : null;
254 for (let e in elementMap["global"]) {
255 if (elementMap['global'][e].name === "vf") {
256 selectedVF = elementMap['global'][e].value[0]
259 var location_values = vf_Services['global']['location'];
260 var vfc_values2 = selectedVF &&
261 vf_Services['shared']['byVf'][selectedVF] &&
262 vf_Services['shared']['byVf'][selectedVF]['vfc'] &&
263 _.keys(vf_Services['shared']['byVf'][selectedVF]['vfc']).length > 0 ?
264 vf_Services['shared']['byVf'][selectedVF]['vfc'] : null;
267 for (key in vf_values) {
268 if ($("#vf").length > 0) {
269 $("#vf").append("<option value=\"" + key + "\">" + vf_values[key] + "</opton>")
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>")
281 $("#vfc").append("<option value=\"\"></opton>");
282 for (key in vfc_values2) {
283 if ($("#vfc").length > 0) {
284 $("#vfc").append("<option value=\"" + key.split("\"").join("") + "\">" + vfc_values2[key] + "</opton>")
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) {
313 runningInstances = {}
316 $(window).load(function() {
319 url: '/restservices/clds/v1/clds/properties',
320 success: function(data) {
321 console.log("success");
322 defaults_props = data;
324 error: function(s, a, err) {