X-Git-Url: http://git.onelab.eu/?p=unfold.git;a=blobdiff_plain;f=plugins%2Funivbrisfvf%2Fstatic%2Fjs%2Funivbrisfvf.js;fp=plugins%2Funivbrisfvf%2Fstatic%2Fjs%2Funivbrisfvf.js;h=0422bd7ccf845b7cac00ab6c7dd75efbf6be222f;hp=a21e5246fc53a0874e3bdff17412e27dfc744482;hb=e45ccc4c4c327a81cc6a001ceff0655358ea09c5;hpb=e494918d8e6d9dab21b9ff30c3c2db2157dc0a20 diff --git a/plugins/univbrisfvf/static/js/univbrisfvf.js b/plugins/univbrisfvf/static/js/univbrisfvf.js index a21e5246..0422bd7c 100644 --- a/plugins/univbrisfvf/static/js/univbrisfvf.js +++ b/plugins/univbrisfvf/static/js/univbrisfvf.js @@ -7,7 +7,9 @@ (function($){ var debug=false; - debug=true + debug=true; + sync_query_uuid=""; + var UnivbrisFvf = Plugin.extend({ @@ -171,55 +173,122 @@ fnCancel:function(e){ //var sData=$("#uob_fv_table_form").find("input").serialize(); //alert("add flowspace:" + sData); + //alert("cancel"); + jQuery("#uob_ofv_table_form").hide(); jQuery("#uob_fv_table_form").hide(); + jQuery( "#univbris_foam_ports_selection" ).hide(); jQuery( "#univbris_flowspace_selection" ).show(); + jQuery('#topo_plugin').hide(); + /*var port_table=$("#univbris_foam_ports_selection__table").dataTable(); + var nodes = $('input',port_table.fnGetNodes()); + for(var i=0;i "+$("#flowspace_name").val()+"

"; + this.table = $("#univbris_flowspace_selection__table").dataTable(); + var val_status=validateFvfForm(); + if (val_status == true){ + pk_flowspace_index=1+pk_flowspace_index; + flowspace=sData; + var m_form=form+","+form2; + var string = "

"+$("#flowspace_name").val()+"

"; + if(fvf_add==1){ + this.table.fnAddData([string, 'Edit', 'Delete']); + } + else{ + this.table.fnDeleteRow(fvf_nrow); this.table.fnAddData([string, 'Edit', 'Delete']); - jQuery( "#univbris_flowspace_selection" ).show(); - } + } + jQuery( "#univbris_foam_ports_selection" ).hide(); + jQuery( "#univbris_flowspace_selection" ).show(); + jQuery('#topo_plugin').hide(); + } + else{ + alert("validation failed"); + jQuery("#uob_fv_table_form").show(); + jQuery("#uob_ofv_table_form").hide(); + jQuery( "#univbris_foam_ports_selection" ).show(); + } + } + else{ + + var sData=$("#uob_ofv_table_form").find("input").serialize(); + var form =serializeAnything("#uob_ofv_table_form"); + var port_table=$("#univbris_foam_ports_selection__table").dataTable(); + var form2=$('input',port_table.fnGetNodes()).serialize(); + var nodes = $('input',port_table.fnGetNodes()); + + this.table = $("#univbris_flowspace_selection__table").dataTable(); + + var val_status=validateoFvfForm(); + if (val_status == true){ + opt_flowspace_index=1+opt_flowspace_index; + flowspace=sData; + var m_form=form+","+form2; + var string = "

"+$("#oflowspace_name").val()+"

"; + if(fvf_add==1){ + this.table.fnAddData([string, 'Edit', 'Delete']); + } + else{ + this.table.fnDeleteRow(fvf_nrow); + this.table.fnAddData([string, 'Edit', 'Delete']); + } + jQuery( "#univbris_foam_ports_selection" ).hide(); + jQuery( "#univbris_flowspace_selection" ).show(); + jQuery('#topo_plugin').hide(); + } + else{ + alert("validation failed"); + jQuery("#uob_ofv_table_form").show(); + jQuery("#uob_fv_table_form").hide(); + jQuery( "#univbris_foam_ports_selection" ).show(); + } + + } + /*} else{ jQuery("#uob_fv_table_form").hide(); + jQuery("#uob_ofv_table_form").hide(); var sData=$("#uob_fv_table_form").find("input").serialize(); var form =serializeAnything("#uob_fv_table_form"); + //var form2=serializeAnything("#uob_form"); + + var port_table=$("#univbris_foam_ports_selection__table").dataTable(); + var form2=$('input',port_table.fnGetNodes()).serialize(); this.table = $("#univbris_flowspace_selection__table").dataTable(); flowspace=sData; - - var string = "

"+$("#flowspace_name").val()+"

"; + var m_form=form+","+form2; + var string = "

"+$("#flowspace_name").val()+"

"; this.table.fnDeleteRow(fvf_nrow); this.table.fnAddData([string, 'Edit', 'Delete']); + + jQuery( "#univbris_foam_ports_selection" ).hide(); jQuery( "#univbris_flowspace_selection" ).show(); + jQuery('#topo_plugin').hide(); - } + }*/ }, - fnModflowspace:function(e){ - //alert("modify"); - - jQuery("#uob_fv_table_form").hide(); - var sData=$("#uob_fv_table_form").find("input").serialize(); - var form =serializeAnything("#uob_fv_table_form"); - this.table = $("#univbris_flowspace_selection__table").dataTable(); - flowspace=sData; - alert(form+"\n"+sData); - - var string = "

"+$("#flowspace_name").val()+"

"; - this.table.fnDeleteRow(fvf_nrow); - this.table.fnAddData([string, 'Edit', 'Delete']); - jQuery( "#univbris_flowspace_selection" ).show(); - }, - /** * @brief Determine index of key in the table columns * @param key @@ -311,24 +380,6 @@ line.push("first"); } - - /*if (typeof colnames[j] == 'undefined') { - line.push('...'); - } else if (colnames[j] == 'hostname') { - if (record['type'] == 'resource,link') - //TODO: we need to add source/destination for links - line.push(''); - else - line.push(record['hostname']); - - } else if (colnames[j] == 'hrn' && typeof(record) != 'undefined') { - line.push(' '+record['hrn']); - } else { - if (record[colnames[j]]) - line.push(record[colnames[j]]); - else - line.push(''); - }*/ } // catch up with the last column if checkboxes were requested @@ -635,9 +686,9 @@ $("#addflowspaceform").unbind('click').click(this, this.fnAddflowspace); } else{ - $("[id='addflowspaceform'").unbind('click').click(this, this.fnModflowspace); + $("[id='addflowspaceform']").unbind('click').click(this, this.fnModflowspace); } - $("#cancel_addflowspaceform").unbind('click').click(this,this.fnCancel); + $("#cancel_addflowspaceform").unbind('click').click(this,this.fnCancel); if (!this.table) return; @@ -717,38 +768,521 @@ })(jQuery); +function deserializeDT(d){ -function fnPopTable(e){ - //alert("e: "+e); - //this.table = $("#univbris_flowspace_selection__table").dataTable(); - //alert(this.table); - /**var rows = $("#univbris_flowspace_selection__table").dataTable().fnGetNodes(); - for(var i=0;i= 19) { + status=true; + } + + if (port_selected==false & checked == 18){ + alert("you need to select at least one port"); + } + else if (port_selected==false & checked <= 18){ + alert("you need to select at least one port and correct other flowspace parameter errors"); + } + else if (port_selected==true & checked <= 18){ + alert("you need to correct other flowspace parameter errors"); + } + + //alert("validator status:"+status+" checked:"+checked); + return status; +} + +function validateoFvfForm(){ + var status = false; + var checked =0; + + //row 1 validation + if (wavelengthValidator($('#uob_ofv_table_wavelength').val())==false){ + $("#uob_ofv_table_wavelength").addClass('error'); + $("#uob_ofv_table_wavelength_error").show(); + } + else { + checked++; + } + + + + //validate that at least one port is selected + var port_table=$("#univbris_foam_ports_selection__table").dataTable(); + var nodes = $('input',port_table.fnGetNodes()); + + var port_selected=false; + for(var i=0;i= 2) { + status=true; + } + + if (port_selected==false & checked == 1){ + alert("you need to select at least one port"); + } + else if (port_selected==false & checked <= 1){ + alert("you need to select at least one port and correct other flowspace parameter errors"); + } + else if (port_selected==true & checked <= 1){ + alert("you need to correct other flowspace parameter errors"); + } + + //alert("validator status:"+status+" checked:"+checked); + return status; +} + + function fnGetSelected( oTableLocal ) { @@ -777,7 +1311,28 @@ function serializeAnything (form){ }); return toReturn.join("&").replace(/%20/g, "+"); +} + +function hideFvfError(){ + $("[id*=_error]").hide(); + console + $("#uob_fv_table_form :input").each(function(){ + try{ + $(this).removeClass('error'); + } + catch (err){ + } + + }); + + $("#uob_ofv_table_form :input").each(function(){ + try{ + $(this).removeClass('error'); + } + catch (err){ + } + }); }