X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fresources%2FMETA-INF%2Fresources%2Fdesigner%2Fscripts%2FaOnBoot.js;h=347d747201d3117353306171b0600d6736aaeaf7;hb=refs%2Fchanges%2F56%2F83156%2F2;hp=01a39b62d8053d3e2af8e4a16cca5be696992064;hpb=3d2759d4aea35d6d1891fe36b136ccd12a05b422;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 01a39b62..347d7472 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js +++ b/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,9 +18,10 @@ * limitations under the License. * ============LICENSE_END============================================ * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ + //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) { @@ -36,81 +37,6 @@ function newElementProcessor(id) { } } -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') - } - }); - } -} - -function saveGlobalProperties(form) { - elementMap["global"] = form; -} -var isObject = function(a) { - return (!!a) && (a.constructor === Object); -}; - -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"); - } - - 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() { - setMultiSelect(type); - }, 100); - - - -} - function setMultiSelect() { $("select").each(function(index, mySelect) { @@ -145,169 +71,46 @@ function setMultiSelect() { }); } -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 - - }); -} - -function setASDCFields() { - if (vf_Services === null || vf_Services === undefined) { - loadSharedPropertyByService() - } else { +function setPolicyOptions() { +console.log("reset policy default options"); try { - $("#vf").empty().multiselect("refresh"); - $("#location").empty().multiselect("refresh"); - $("#actionSet").empty().multiselect("refresh"); - $("#vfc").empty().multiselect("refresh"); - $("#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 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("