X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fresources%2FMETA-INF%2Fresources%2Fdesigner%2Fscripts%2FaOnBoot.js;h=01a39b62d8053d3e2af8e4a16cca5be696992064;hb=5fce1d5e1eaaccdd4fb219d7b370bee9af5b66e5;hp=6c58570aba450ebb82f167f571938bf9accad55a;hpb=5e9feb2a8e360b82dc2b6e4145e0fd847d2924ce;p=clamp.git diff --git a/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js b/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js index 6c58570a..01a39b62 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js +++ b/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js @@ -5,16 +5,16 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights * reserved. * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ * =================================================================== @@ -23,312 +23,321 @@ //When element is first created it should have a red box because it hasn't been edited function newElementProcessor(id) { - if ($('g[data-element-id="' + id + '"]').length > 0) { - - var _idNode = $('g[data-element-id="' + id + '"]') - _idNode.children("rect").each(function() { - if ($(this).attr('class') === 'djs-outline') { - $(this).attr('class', "djs-outline-no-property-saved") - $(this).attr('fill', 'red') - } - }); + if ($('g[data-element-id="' + id + '"]').length > 0) { - } + var _idNode = $('g[data-element-id="' + id + '"]') + _idNode.children("rect").each(function() { + if ($(this).attr('class') === 'djs-outline') { + $(this).attr('class', "djs-outline-no-property-saved") + $(this).attr('fill', 'red') + } + }); + + } } function saveProperties(form) { - elementMap[lastElementSelected] = form; - totalJsonProperties = JSON.stringify(elementMap); - - //Take off the red border because the element has been edited - if ($('g[data-element-id="' + lastElementSelected + '"]').length > 0) { - var _idNode = $('g[data-element-id="' + lastElementSelected + '"]') - _idNode.children("rect").each(function() { - if ($(this).attr('class') === 'djs-outline-no-property-saved') { - $(this).attr('class', "djs-outline") - $(this).attr('fill', 'none') - } - }); - } + elementMap[lastElementSelected] = form; + totalJsonProperties = JSON.stringify(elementMap); + + //Take off the red border because the element has been edited + if ($('g[data-element-id="' + lastElementSelected + '"]').length > 0) { + var _idNode = $('g[data-element-id="' + lastElementSelected + '"]') + _idNode.children("rect").each(function() { + if ($(this).attr('class') === 'djs-outline-no-property-saved') { + $(this).attr('class', "djs-outline") + $(this).attr('fill', 'none') + } + }); + } } function saveGlobalProperties(form) { - elementMap["global"] = form; + elementMap["global"] = form; } var isObject = function(a) { - return (!!a) && (a.constructor === Object); + return (!!a) && (a.constructor === Object); }; -function loadPropertyWindow(type) { - if (readOnly) { - if ($("#add_one_more").length == 1) { - $("#add_one_more").off(); - $("#add_one_more").click(function(event) { - event.preventDefault(); - }) - } - $("select,input").attr("disabled", ""); +function loadPropertyWindow(type) { + if (readOnly || readMOnly) { + if ($("#add_one_more").length == 1) { + $("#add_one_more").off(); + $("#add_one_more").click(function(event) { + event.preventDefault(); + }) } + $("input,#savePropsBtn").attr("disabled", ""); + $(".modal-body button").attr("disabled", ""); + ($("select:not([multiple])")).multiselect("disable"); + } - var props = defaults_props[type]; - - for (p in props) { - if (isObject(props[p])) { - var mySelect = $('#' + p); - $.each(props[p], function(val, text) { - mySelect.append( - $('').val(val).html(text) - ); - }); - } else { - if (p=="pname"){ - var ms = new Date().getTime(); - props[p] = "Policy" + ms; - } - $("#" + p).val(props[p]) - } + if (readTOnly) { + $("textarea").attr("disabled", ""); + $("#savePropsBtn").attr("disabled", ""); + } + + var props = defaults_props[type]; + + for (p in props) { + if (isObject(props[p])) { + var mySelect = $('#' + p); + if (p == "operator") { + $.each(props[p], function(val, text) { + mySelect.append( + $('').val(val).html(val) + ); + }); + } else { + $.each(props[p], function(val, text) { + mySelect.append( + $('').val(val).html(text) + ); + }); + } + } else { + if (p == "pname") { + var ms = new Date().getTime(); + props[p] = "Policy" + ms; + } + $("#" + p).val(props[p]) } - setTimeout(function(){ + } + setTimeout(function() { + setMultiSelect(type); + }, 100); + + - setMultiSelect(type); }, 100); - } function setMultiSelect() { - $("select").each(function(index, mySelect) { - if ($(mySelect).parents(".multiselect-native-select") && - $(mySelect).parents(".multiselect-native-select").length < 1) { - if (!$(mySelect).attr("multiple")) { - if ($(mySelect).attr("enableFilter")) { - $(mySelect).multiselect({ - numberDisplayed: 1, - maxHeight: 200 - }); - } else { - $(mySelect).multiselect({ - numberDisplayed: 1, - enableFiltering: true, - maxHeight: 200 - }); - } - - } else { - $(mySelect).multiselect({ - numberDisplayed: 1, - includeSelectAllOption: true, - enableFiltering: true, - maxHeight: 200, - enableCaseInsensitiveFiltering: true - }); - } - - } else if ($(mySelect).parents(".multiselect-native-select") && - $(mySelect).parents(".multiselect-native-select").length > 0) { - var selectDrop = $(mySelect).parent(".multiselect-native-select").find("select"); - $(mySelect).parent(".multiselect-native-select").parent().html(selectDrop); - if (!$(mySelect).attr("multiple")) { - if ($(mySelect).attr("enableFilter")) { - $(mySelect).multiselect({ - numberDisplayed: 1, - maxHeight: 200 - }); - } else { - $(mySelect).multiselect({ - numberDisplayed: 1, - enableFiltering: true, - maxHeight: 200 - }); - } - } else { - $(mySelect).multiselect({ - numberDisplayed: 1, - includeSelectAllOption: true, - enableFiltering: true, - maxHeight: 200, - enableCaseInsensitiveFiltering: true - }); - } - } - }); - //refeshMultiSelect(); -} -function loadSharedPropertyByService(onChangeUUID,refresh, callBack) { - var uuid = onChangeUUID - if (uuid === undefined){ - uuid = elementMap["global"] && elementMap["global"].length>0 ? - elementMap["global"][0].value : ""; - } else if (uuid === "") { - vf_Services = null - if ($("#vf").length > 0) - $("#vf").empty(); - if ($("#location").length > 0) - $("#location").empty(); - if ($("#alarmCondition").length > 0) - $("#alarmCondition").empty(); - return true; + $("select").each(function(index, mySelect) { + + var mySelectObj = $(mySelect); + if (! mySelectObj.parents(".multiselect-native-select")) { + // keep native for this one + return; } - var share = null, - serviceUrl = '/restservices/clds/v1/clds/properties/' + uuid; - if(refresh){ - serviceUrl = '/restservices/clds/v1/clds/properties/' + uuid +'?refresh=true'; + + if (mySelectObj.parents(".multiselect-native-select").length > 0) { + var selectDrop = mySelectObj.parent(".multiselect-native-select").find("select"); + mySelectObj.parent(".multiselect-native-select").parent().html(selectDrop); } - $.ajax({ - async: false, - dataType: "json", - url: serviceUrl, - success: function(data) { - vf_Services = data; - setASDCFields() - if(refresh){ - $("#paramsWarnrefresh").hide(); - } - if($("#paramsWarn")){ - $("#paramsWarn").hide(); - } - if(callBack && _.isFunction(callBack)){ - callBack(true); - } - }, - error: function(s, a, err) { - if(refresh){ - $("#paramsWarnrefresh").show(); - } - if($("#paramsWarn")){ - $("#paramsWarn").show(); - } - - $('#servName').text($("#service option:selected").text()); - if(callBack && _.isFunction(callBack)){ - callBack(false); - } - console.log(err) - console.log(s) - console.log(a) - }, - timeout: 100000 + var options = { + numberDisplayed: 1, + maxHeight: 200 + }; - }); - //vf_Services=share['shared']['byService'][uuid]; - //location_values = share['global']['location']; + if (mySelectObj.attr("multiple") + && mySelectObj.attr("multiple") != 'false') { + options.includeSelectAllOption = true; + } + + if (mySelectObj.attr("enableFilter") + && mySelectObj.attr("enableFilter") != 'false') { + options.enableCaseInsensitiveFiltering = true; + options.enableFiltering = true; + } + + mySelectObj.multiselect(options); + }); +} + +function loadSharedPropertyByService(onChangeUUID, refresh, callBack) { + var uuid = onChangeUUID; + if (uuid === undefined) { + uuid = elementMap["global"] && elementMap["global"].length > 0 ? + elementMap["global"][0].value : ""; + } else if (uuid === "") { + vf_Services = null + if ($("#vf").length > 0) + $("#vf").empty().multiselect("refresh"); + if ($("#location").length > 0) + $("#location").empty().multiselect("refresh"); + if ($("#alarmCondition").length > 0) + $("#alarmCondition").empty().multiselect("refresh"); + return true; + } + var share = null, + serviceUrl = '/restservices/clds/v1/clds/properties/' + uuid; + if (refresh) { + serviceUrl = '/restservices/clds/v1/clds/properties/' + uuid + '?refresh=true'; + } + + $.ajax({ + async: false, + dataType: "json", + url: serviceUrl, + success: function(data) { + vf_Services = data; + setASDCFields() + if (refresh) { + $("#paramsWarnrefresh").hide(); + } + if ($("#paramsWarn")) { + $("#paramsWarn").hide(); + } + if (callBack && _.isFunction(callBack)) { + callBack(true); + } + }, + error: function(s, a, err) { + if (refresh) { + $("#paramsWarnrefresh").show(); + } + if ($("#paramsWarn")) { + $("#paramsWarn").show(); + } + + $('#servName').text($("#service option:selected").text()); + if (callBack && _.isFunction(callBack)) { + callBack(false); + } + console.log(err) + console.log(s) + console.log(a) + }, + timeout: 100000 + + }); + + //vf_Services=share['shared']['byService'][uuid]; + //location_values = share['global']['location']; } function loadSharedPropertyByServiceProperties(callBack) { - $.ajax({ - async: false, - dataType: "json", - url: '/restservices/clds/v1/clds/properties/', - success: function(data) { - vf_Services = data; - setASDCFields(); - if(callBack && _.isFunction(callBack)){ - callBack(true); - } - }, - error: function(s, a, err) { - $('#servName').text($("#service option:selected").text()); - if(callBack && _.isFunction(callBack)){ - callBack(false); - } - }, - timeout: 100000 + $.ajax({ + async: false, + dataType: "json", + url: '/restservices/clds/v1/clds/properties/', + success: function(data) { + vf_Services = data; + setASDCFields(); + if (callBack && _.isFunction(callBack)) { + callBack(true); + } + }, + error: function(s, a, err) { + $('#servName').text($("#service option:selected").text()); + if (callBack && _.isFunction(callBack)) { + callBack(false); + } + }, + timeout: 100000 - }); + }); } function setASDCFields() { - if (vf_Services === null || vf_Services === undefined) { - loadSharedPropertyByService() - } else { - try { - $("#vf").empty(); - $("#location").empty(); - $("#vfc").empty(); - $("#paramsWarn").hide(); - var uuid = Object.keys(vf_Services['shared']['byService'])[0]; - var vf_values = vf_Services['shared']['byService'][uuid] && - vf_Services['shared']['byService'][uuid]['vf'] && - _.keys(vf_Services['shared']['byService'][uuid]['vf']).length > 0 ? - vf_Services['shared']['byService'][uuid]['vf'] : null; - var selectedVF = {} - for (let e in elementMap["global"]) { - if (elementMap['global'][e].name === "vf") { - selectedVF = elementMap['global'][e].value[0] - } - } - var location_values = vf_Services['global']['location']; - var vfc_values2 = selectedVF && - vf_Services['shared']['byVf'][selectedVF] && - vf_Services['shared']['byVf'][selectedVF]['vfc'] && - _.keys(vf_Services['shared']['byVf'][selectedVF]['vfc']).length > 0 ? - vf_Services['shared']['byVf'][selectedVF]['vfc'] : null; - - if (vf_values) { - for (key in vf_values) { - if ($("#vf").length > 0) { - $("#vf").append("