Merge "new method for policy client"
authorSébastien Determe <sd378r@intl.att.com>
Thu, 28 Sep 2017 14:38:49 +0000 (14:38 +0000)
committerGerrit Code Review <gerrit@onap.org>
Thu, 28 Sep 2017 14:38:49 +0000 (14:38 +0000)
src/main/resources/META-INF/resources/designer/partials/portfolios/tca_properties.html
src/main/resources/clds/globalClds.properties

index 7305fd9..238e37a 100644 (file)
 }
 
 #tcaEditHolder{
-       height:260px; 
        background-color: #f5f5f5; 
-       padding:10px 0px; 
+       padding:10px 10px; 
        margin: 15px 15px 0 0; 
        float: right;
 }
+
+
+#tcaEditHolder #properties_tab>div+div {
+  margin-top: 10px;
+}
+
 .tcaErr{
        display:none; 
        text-align:center; 
        margin-bottom:20px; 
-       color:red;"
+       color:red;
 }
 
 .tcaParentItems {
                <div style="height: 10px"></div>
                <div class="panel panel-default" id="panelHolder">
                        
-                       <div class="panel-heading">
-                               <ul id="nav_Tabs" class="nav nav-tabs">
-                                       <li class><a id="add_one_more" href="#desc_tab"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></a></li>
-                               </ul>
-                       </div>
-                       
                        <span id="formSpan" style="display:none;">
                        <div class="panel-body">
                        
                                                                <input class="form-control" onkeydown="return false;" type="text" id="tuuid" name="tuuid"></input>
                                                        </div>
                                                </div>
-                                               
-                                               <div class="col-sm-8 form-group" style="display:none;">
-                                                       <label class="col-sm-3"> NF Code </label>
-                                                       <div class="col-sm-9" style="padding:0px;">
-                                                               <input class="form-control" onkeydown="return false;" type="text" id="tnfc" name="tnfc"></input>
-                                                       </div>
-                                               </div>
-                                               
-                                               <div class="col-sm-3 form-group"> 
-                                                       <label class="col-sm-8"> Enable </label>
-                                                       <input class="col-sm-4" type="checkbox" style="height:21px; 
-                                                               width:21px; margin:6px;" checked="checked" id="tcaEnab" name="tcaEnab"></input>
-                                               </div>
                                        </div>
                                        <div class="row">
                                                <div class="col-sm-8 form-group">
                                                                <select name="tcaPol" id="tcaPol" enableFilter="true"></select>
                                                        </div>
                                                </div>
+                                               <div class="col-sm-8 form-group">
+                                                       <label class="col-sm-3">EventName</label>
+                                                       <div class="col-sm-9" style="padding:0px;">
+                                                               <select name="eventName" id="eventName" enableFilter="true"></select>
+                                                       </div>
+                                               </div>            
                                                
                                                <div class="col-sm-8 form-group" style="display:none;">
                                                        <label class="col-sm-3"> Policy ID </label>
                                                                <input class="form-control" onkeydown="return false;" type="text" id="tcaPolId" name="tcaPolId"></input>
                                                        </div>
                                                </div>
-                                               
-                                               <div class="col-sm-3 form-group"> 
-                                                       <label class="col-sm-8">Max Intervals</label>
-                                                       <input class="col-sm-4 form-control" style="width:80%" type="text" maxlength="3" 
-                                                       id="tcaInt" onkeypress="return isNumberKey(event)" name="tcaInt"></input>
-                                               </div>
-                                       </div>
-                                       <div class="row">
-                                               <div class="col-sm-8 form-group">
-                                                       <label class="col-sm-3"> Severity </label>
-                                                       <div class="col-sm-9" style="padding:0px;">
-                                                               <select name="tcaSev" id="tcaSev" enableFilter="false">
-                                                               </select>
-                                                       </div>
-                                               </div>
-                                               
-                                               <div class="col-sm-3 form-group"> 
-                                                       <label class="col-sm-8">Min Violations</label>
-                                                       <input class="col-sm-4 form-control" style="width:80%" type="text" maxlength="3" 
-                                                       id="tcaVio" onkeypress="return isNumberKey(event)" name="tcaVio"></input>
-                                               </div>
+
                                        </div>
                                </form>
                                
                                        
                                        <div id="tcaEditHolder" class="panel panel-default col-sm-6">
                                                <div class="tab-content">
-                                                       <div id="properties_tab" style="padding:10px;" class="form-horizontal">
-                                                               <div style="margin-bottom:20px;">
+                                                       <div id="properties_tab" class="form-vertical">
+                                                               <div>
                                                                        <label class="control-label">Metric</label>
                                                                        <div>
                                                                                <select id="fieldPathM" name="fieldPathM"></select>
                                                                        </div>
                                                                </div>
-                                                               <div style="margin-bottom:20px;">
+                                                               <div>
                                                                        <label class="control-label">Operator</label>
                                                                        <div>
                                                                                <select id="operator" name="operator"></select>
                                                                        </div>
                                                                </div>
-                                                               <div style="margin-bottom:20px;">
+                                                               <div>
                                                                        <label class="control-label">Threshold</label>
                                                                        <div>
                                                                                <input type="text" maxlength="10" class="form-control" name="threshold" 
                                                                                onkeypress="return isNumberKey(event)" id="threshold"></input>
                                                                        </div>
                                                                </div>
+                                                               <div>
+                                                                       <label class="control-label">Control Loop Schema</label>
+                                                                       <div>
+                                                                               <select id="controlLoopSchema" name="controlLoopSchema"></select>
+                                                                       </div>
+                                                               </div>
+                                                               <div>
+                                                                       <label class="control-label">Closed Loop Event Status</label>
+                                                                       <div>
+                                                                               <select id="closedLoopEventStatus" name="closedLoopEventStatus"></select>
+                                                                       </div>
+                                                               </div>                
                                                        </div>
                                                </div>
                                        </div>
                        class="btn btn-primary">Cancel</button>
        </div>
        
-       <script>
+       <script language="javascript">
+    // helper that make jquery objects visibles or invisible
+    // to use instead of show to keep placeholder size correct
+    jQuery.fn.visible = function() {
+        return this.css('visibility', 'visible');
+    };
+    jQuery.fn.invisible = function() {
+        return this.css('visibility', 'hidden');
+    };
+
                var generateTUUID = function(count){
                        var d = new Date().getTime();
                        var tuuid = 'xxxxxxxx-xxxx-txxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function(c){
                                return (c == 'x' ? r : (r*0x3|0*8)).toString(16);
                        });
                        $("#formId" + count + " #tuuid").val(tuuid);
-               }
-               
-               $("#add_one_more").click(function(event) {
-                       event.preventDefault();
-                       if ($("#nav_Tabs li.active").length>0){
-                               var oldCount = $("#nav_Tabs li.active").find("a").attr("id").slice(-1);
-                               if (($('#formId'+oldCount+' #tcaTable .highlight').length > 0 ) &&
-                                               (!($('#formId'+oldCount+' #threshold').val()) || !($('#formId'+oldCount+' #fieldPathM').val())) ) {
-                                       $('#formId'+oldCount+' #tcaError').show();
-                                       return;
-                               } else {
-                                       $('#formId'+oldCount+' .tcaErr').hide();
-                                       if ($('#formId'+oldCount+' #tcaTable .highlight').length > 0){
-                                               $('#formId'+oldCount+' #tcaTable .highlight td').text(
-                                                               $('#formId'+oldCount+' #fieldPathM').val() + ' ' +
-                                                               $('#formId'+oldCount+' #operator').val() + ' ' +
-                                                               $('#formId'+oldCount+' #threshold').val());
-                                       }
-                                       $("#formId"+oldCount+" #tcaTable .highlight").removeClass("highlight")
-                               }
-                       }
-                       var count = add_one_more();     
-                       generateTUUID(count);
-               })
+               };
+
+
+    var propertiesToString = function(formIdNum) {
+      return $('#formId'+formIdNum+' #fieldPathM').find(':selected').text() + ' ' +
+                               $('#formId'+formIdNum+' #operator').val() + ' ' +
+                               $('#formId'+formIdNum+' #threshold').val() + ' ' +
+        $('#formId'+formIdNum+' #controlLoopSchema').val() + ' ' +
+        $('#formId'+formIdNum+' #closedLoopEventStatus').val();
+    };
+
                loadPropertyWindow("tca");
                
                //load dropdown with policy options
                                }
                        }
                }
-               
+
+               var fieldPathMLabel2Value = function(label) {
+                       return Object.keys(defaults_props['tca']['fieldPathM']).find(key => defaults_props['tca']['fieldPathM'][key] == label)
+               }
+               var fieldPathMValue2Label = function(value) {
+                       return defaults_props['tca']['fieldPathM'][value];
+               }
+
                setASDCFields();
-               
-               //load metrics dropdown
-               if (elementMap["global"]){
-                       for (var i = 0; i < (elementMap["global"].length); i++){
-                               if ((elementMap["global"][i]["name"]) == "vf"){
-                                       var vfSel = elementMap["global"][i]["value"];   
-                                       if (vf_Services["shared"]["byVf"][vfSel]["kpi"]){
-                                               $.each((vf_Services["shared"]["byVf"][vfSel]["kpi"]), function(val, text) {
-                                       $('#fieldPathM').append(
-                                           $('<option></option>').val(val).html(text)
-                                       );
-                                   });
-                                       }
-                                       break;
-                               };
-                       };
-               };
-               
+
                var arr = elementMap[lastElementSelected];
-               
+
                if (arr !== undefined) {
                        for (var x in arr){
                                var num = add_one_more();
-                               var setCheck = true;
                                for (var i=0; i< arr[x].length; i++){
-                                       if (arr[x][i].name=='tcaEnab'){
-                                               $("#formId" + num + " #tcaEnab").prop("checked","true");
-                                               setCheck = false;
-                                       }
                                        
                                        if (arr[x][i].hasOwnProperty('serviceConfigurations')){
                                                for (var j=0; j<arr[x][i]["serviceConfigurations"].length; j++){
                                                        $("#formId" + num + " #tcaTable").prepend("<tr><td>"
-                                                                       +arr[x][i]["serviceConfigurations"][j][0]+" "
-                                                                       //+(defaults_props['tca']['operator']).getKey(arr[x][i]["serviceConfigurations"][j][1])+" "
-                                                                       +(Object.keys(defaults_props['tca']['operator']).find(key => defaults_props['tca']['operator'][key] == (arr[x][i]["serviceConfigurations"][j][1])))+ " " 
-                                                                       +arr[x][i]["serviceConfigurations"][j][2]+"</td></tr>");
+                                                                       +fieldPathMValue2Label(arr[x][i]["serviceConfigurations"][j][0])+ " "
+                                                                       +(Object.keys(defaults_props['tca']['operator']).find(key => defaults_props['tca']['operator'][key] == (arr[x][i]["serviceConfigurations"][j][1])))+ " "
+                                                                       +arr[x][i]["serviceConfigurations"][j][2]+" "
+                                                                       +arr[x][i]["serviceConfigurations"][j][3]+" "
+                                                                       +arr[x][i]["serviceConfigurations"][j][4]+"</td></tr>");
                                                }
                                        } else {
                                                $("#formId" + num + " #"+arr[x][i].name).val(arr[x][i].value);
                                        }
                                }
-                               if (setCheck){
-                                       $("#formId" + num + " #tcaEnab").prop("checked",false);
-                               }
                                $('#go_properties_tab'+num).text($('#formId' +num+ ' #tname').val());
-                               $("#formId"+num + " #properties_tab").hide();
+                               $("#formId"+num + " #properties_tab").invisible();
                        }
                } 
        
                $("#savePropsBtn").click(function(event) {
-                       var num = $('#nav_Tabs .active a').attr('id').slice(-1);
-                       var tabs = [];
-                       $('#nav_Tabs li:not(:last)').each(function(){
-                               tabs.push($(this).text());
-                       });
-                       var nonunique = uniquet(tabs);
+                       var num = 1
                        if (($('#formId'+num+' #tcaTable .highlight').length > 0 ) &&
                                        (!($('#formId'+num+' #threshold').val()) || !($('#formId'+num+' #fieldPathM').val())) ) {
                                $('#formId'+num+' #tcaError').show();
                                return;
-                       } else if (nonunique){
-                               $('#formId'+num+' #tcaUnique').show();
-                               return;
                        } else {
                                $('#formId'+num+' .tcaErr').hide();
                                if ($('#formId'+num+' #tcaTable .highlight').length > 0){
-                                       $('#formId'+num+' #tcaTable .highlight td').text(
-                                                       $('#formId'+num+' #fieldPathM').val() + ' ' +
-                                                       $('#formId'+num+' #operator').val() + ' ' +
-                                                       $('#formId'+num+' #threshold').val());
+                                       $('#formId'+num+' #tcaTable .highlight td').text(propertiesToString(num));
                                }
                                var saveP = {};
                                $('.formId').each(function(){
                                        var header = $(this).find('.tcaParentItems').serializeArray();
                                        var sconf = {};
                                        var sconfa = [];
-                                       var checkNF = true;
                                        $('#formId' +count+' #tcaTable tr').each(function(){
                                                $('td', this).each(function(){
                                                        var splitTd = $(this).text().split(' ');
+              splitTd[0]=fieldPathMLabel2Value(splitTd[0]);
                                                        splitTd[1]=defaults_props['tca']['operator'][splitTd[1]];
-                                                       var checkByKpi = vf_Services["shared"]["byKpi"][splitTd[0].replace(/\s/g, "")];
-                                                       if (checkByKpi["fieldPath"]){
-                                                               splitTd.push(Object.keys(vf_Services["shared"]["byKpi"][splitTd[0].replace(/\s/g, "")]["fieldPath"])[0]);
-                                                       };
-                                                       if ((checkByKpi["nfNamingCode"]) && (checkNF)){
-                                                               $.grep(header, function(e,i){ 
-                                                                       if (e.name == "tnfc"){
-                                                                               header[i]["value"] = (Object.keys(checkByKpi["nfNamingCode"])[0]);
-                                                                       }
-                                                               });
-                                                               checkNF = false;
-                                                       }
                                                        sconfa.push(splitTd);
                                                });
                                                
                        
                        $("#add_one_more").parent().before(' <li class="active"><a id="go_properties_tab'+count+'">New_Set</a><button id="tab_close'+count+'" type="button" class="close tab-close-popup" aria-hidden="true" style="margin-top: -30px;margin-right: 5px">&times;</button></li>');
                        $("#formId"+count).append(form);
-                       $('#formId'+count+ ' #properties_tab').hide();
+                       $('#formId'+count+ ' #properties_tab').invisible();
                        $(".formId").not($("#formId"+count)).css("display","none");
                        addCustListen(count);
                        setMultiSelect();
                                        } else {
                                                $('#formId'+oldCount+' .tcaErr').hide();
                                                if ($('#formId'+oldCount+' #tcaTable .highlight').length > 0){
-                                                       $('#formId'+oldCount+' #tcaTable .highlight td').text(
-                                                                       $('#formId'+oldCount+' #fieldPathM').val() + ' ' +
-                                                                       $('#formId'+oldCount+' #operator').val() + ' ' +
-                                                                       $('#formId'+oldCount+' #threshold').val());
+                                                       $('#formId'+oldCount+' #tcaTable .highlight td').text(propertiesToString(oldCount));
                                                }
                                                $("#formId"+oldCount+" #tcaTable .highlight").removeClass("highlight")
                                        }
                                } else {
                                        $('#formId'+count+' .tcaErr').hide();
                                        if ($('#formId'+count+' #tcaTable .highlight').length > 0){
-                                               $('#formId'+count+' #tcaTable .highlight td').text(
-                                                               $('#formId'+count+' #fieldPathM').val() + ' ' +
-                                                               $('#formId'+count+' #operator').val() + ' ' +
-                                                               $('#formId'+count+' #threshold').val());
+                                               $('#formId'+count+' #tcaTable .highlight td').text(propertiesToString(num));
                                        }
                                        //$('#formId'+count+' #tcaTable .highlight').text();
                                        $(this).addClass('highlight').siblings().removeClass('highlight');
                                        var str = $(this).text().split(' ');
-                                       $('#formId'+count + ' #properties_tab').show();
-                                       if (str.length == 3){
-                                               $('#formId'+count+' #fieldPathM').val(str[0]).multiselect('refresh');
+                                       $('#formId'+count + ' #properties_tab').visible();
+                                       if (str.length == 5){
+                                               $('#formId'+count+' #fieldPathM').val(fieldPathMLabel2Value(str[0])).multiselect('refresh');
                                                $('#formId'+count+' #operator').val(str[1]).multiselect('refresh');
                                                $('#formId'+count+' #threshold').val(str[2]);
+            $('#formId'+count+' #controlLoopSchema').val(str[3]).multiselect('refresh');
+            $('#formId'+count+' #closedLoopEventStatus').val(str[4]).multiselect('refresh');
                                        }
                                        
                                        if ((!(readOnly||readMOnly)) && ($('#formId'+count + ' #deleteThresh').prop('disabled'))) {
                        
                        $('#formId'+count+' #deleteThresh').on('click', function(){
                                $('#formId'+num+' .tcaErr').hide();
-                               $('#formId'+count+ ' #properties_tab').hide();
+                               $('#formId'+count+ ' #properties_tab').invisible();
                                $('#formId'+count+ ' #tcaTable .highlight').remove();
                                $('#formId'+count+ ' #deleteThresh').prop('disabled', true);
                        });
                                } else {
                                        $('#formId'+count+' .tcaErr').hide();
                                        if ($('#formId'+count+' #tcaTable .highlight').length > 0){
-                                               $('#formId'+count+' #tcaTable .highlight td').text(
-                                                               $('#formId'+count+' #fieldPathM').val() + ' ' +
-                                                               $('#formId'+count+' #operator').val() + ' ' +
-                                                               $('#formId'+count+' #threshold').val());
+                                               $('#formId'+count+' #tcaTable .highlight td').text(propertiesToString(count));
                                        }
-                                       $('#formId'+count+ ' #properties_tab').show();
+                                       $('#formId'+count+ ' #properties_tab').visible();
                                        if (('#formId'+count+' #tcaTable .highlight').length > 0 ){
                                                $('#formId'+count+' #tcaTable tr.highlight').removeClass('highlight');
                                        }
                                        $('#formId'+count+' #fieldPathM').prop("selectedIndex", 0).multiselect('refresh');
                                        $('#formId'+count+' #operator').prop("selectedIndex", 0).multiselect('refresh');
                                        $('#formId'+count+' #threshold').val("");
-                                       
+                                       $('#formId'+count+' #controlLoopSchema').prop("selectedIndex", 0).multiselect('refresh');
+                                       $('#formId'+count+' #closedLoopEventStatus').prop("selectedIndex", 0).multiselect('refresh');
+
                                        if ($('#formId'+count + ' #deleteThresh').prop('disabled')) {
                                                $('#formId'+count + ' #deleteThresh').prop('disabled', false);
                                        }
index ac4f0cf..d21afbc 100644 (file)
@@ -21,4 +21,4 @@
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 ###
 
-globalCldsProps ={"tca":{"tname":"New_Set","tcaInt":"1","tcaVio":"1","tcaSev":{"NORMAL":"NORMAL","CRITICAL":"CRITICAL","MAJOR":"MAJOR","MINOR":"MINOR","WARNING":"WARNING"},"fieldPath":{"FIELDPATH_test_1":"FIELDPATH_test_1","FIELDPATH_test_2":"FIELDPATH_test_2"},"operator":{">":"GREATER","=":"EQUAL","<":"LESS"},"opsPolicy":{"POLICY_test_X":"POLICY_test_X","POLICY_test_Y":"POLICY_test_Y"}},"global":{"actionSet":{"vnfRecipe":"VNF", "enbRecipe":"eNodeB"},"location":{"SNDGCA64":"San Diego SAN3","ALPRGAED":"Alpharetta PDK1","LSLEILAA":"Lisle DPA3","MDTWNJC1":"FTL_C_location1","MDTWNJC2":"FTL_C_location2","MDTWNJ21":"FTL_L_location1","MDTWNJ22":"FTL_L_location2","RDM2WAGPLCP":"ISTFTL_location","RDM3":"RDM3WAGPLCP"}},"policy":{"pname":"0","timeout":345,"vnfRecipe":{"":"","restart":"Restart","rebuild":"Rebuild","migrate":"Migrate","healthCheck":"Health Check"},"enbRecipe":{"":"","reset":"Reset"},"maxRetries":"3","retryTimeLimit":180,"resource":{"vCTS":"vCTS","v3CDB":"v3CDB","vUDR":"vUDR","vCOM":"vCOM","vRAR":"vRAR","vLCS":"vLCS","vUDR-BE":"vUDR-BE","vDBE":"vDBE"},"parentPolicyConditions":{"Failure_Retries":"Failure: Max Retries Exceeded","Failure_Timeout":"Failure: Time Limit Exceeded","Failure_Guard":"Failure: Guard","Failure_Exception":"Failure: Exception","Failure":"Failure: Other","Success":"Success"}},"shared":{"byService":{"":{"vf":{"":""},"location":{"":""},"alarmCondition":{"":""}}},"byVf":{"":{"vfc":{"":""}}}}}
\ No newline at end of file
+globalCldsProps ={"tca":{"tname":"New_Set","tcaInt":"1","tcaVio":"1","eventName":{"vCPEvGMUXPacketLoss":"vCPEvGMUXPacketLoss","vLoadBalancer":"vLoadBalancer","vFirewallBroadcastPackets":"vFirewallBroadcastPackets"},"fieldPathM":{"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated":"receivedBroadcastPacketsAccumulated","$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsDelta":"receivedDiscardedPacketsDelta"},"operator":{">":"GREATER",">=":"GREATER_OR_EQUAL","=":"EQUAL","<=":"LESS_OR_EQUAL","<":"LESS"},"opsPolicy":{"POLICY_test_X":"POLICY_test_X","POLICY_test_Y":"POLICY_test_Y"},"controlLoopSchema":{"":"","VM":"VM","VNF":"VNF"},"closedLoopEventStatus":{"":"","ONSET":"ONSET","ABATED":"ABATED"}},"global":{"actionSet":{"vnfRecipe":"VNF", "enbRecipe":"eNodeB"},"location":{"SNDGCA64":"San Diego SAN3","ALPRGAED":"Alpharetta PDK1","LSLEILAA":"Lisle DPA3","MDTWNJC1":"FTL_C_location1","MDTWNJC2":"FTL_C_location2","MDTWNJ21":"FTL_L_location1","MDTWNJ22":"FTL_L_location2","RDM2WAGPLCP":"ISTFTL_location","RDM3":"RDM3WAGPLCP"}},"policy":{"pname":"0","timeout":345,"vnfRecipe":{"":"","restart":"Restart","rebuild":"Rebuild","migrate":"Migrate","healthCheck":"Health Check"},"enbRecipe":{"":"","reset":"Reset"},"maxRetries":"3","retryTimeLimit":180,"resource":{"vCTS":"vCTS","v3CDB":"v3CDB","vUDR":"vUDR","vCOM":"vCOM","vRAR":"vRAR","vLCS":"vLCS","vUDR-BE":"vUDR-BE","vDBE":"vDBE"},"parentPolicyConditions":{"Failure_Retries":"Failure: Max Retries Exceeded","Failure_Timeout":"Failure: Time Limit Exceeded","Failure_Guard":"Failure: Guard","Failure_Exception":"Failure: Exception","Failure":"Failure: Other","Success":"Success"}},"shared":{"byService":{"":{"vf":{"":""},"location":{"":""},"alarmCondition":{"":""}}},"byVf":{"":{"vfc":{"":""}}}}}