From: Thierry Parmentelat Date: Thu, 12 Feb 2009 12:08:25 +0000 (+0000) Subject: ckp X-Git-Tag: PLEWWW-4.3-1~46 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=120af9ebe853831222610e8914fab6ac1341edaf;p=plewww.git ckp --- diff --git a/planetlab/events/events_choser.php b/planetlab/events/events_choser.php index cd908a2..08cc193 100644 --- a/planetlab/events/events_choser.php +++ b/planetlab/events/events_choser.php @@ -52,15 +52,15 @@ $details->start(); $details->tr ($form->submit_html('submit','Show Events'),'center'); $details->space(); -$details->th_td ( $form->radio_html ('events','type','Event',true) . "Events", +$details->th_td ( $form->radio_html ('type','Event',array('id'=>'events','checked'=>true)) . "Events", $form->text_html('event','',array('width'=>30,'onSelect'=>'submit()', 'onFocus'=>'events.checked=true'))); -$details->th_td ( $form->radio_html ('sites','type','Site',false) . "Sites", +$details->th_td ( $form->radio_html ('type','Site',array('id'=>'sites')) . "Sites", $form->text_html('site','',array('width'=>30,'onSelect'=>'submit()', 'onFocus'=>'sites.checked=true'))); -$details->th_td ( $form->radio_html ('persons','type','Person',false) . "Persons", +$details->th_td ( $form->radio_html ('type','Person',array('id'=>'persons')) . "Persons", $form->text_html('person','',array('width'=>30,'onSelect'=>'submit()', 'onFocus'=>'persons.checked=true'))); -$details->th_td ( $form->radio_html ('nodes','type','Node',false) . "Nodes", +$details->th_td ( $form->radio_html ('type','Node',array('id'=>'nodes')) . "Nodes", $form->text_html('node','',array('width'=>30,'onSelect'=>'submit()', 'onFocus'=>'nodes.checked=true'))); -$details->th_td ( $form->radio_html ('slices','type','Slice',false) . "Slices", +$details->th_td ( $form->radio_html ('type','Slice',array('id'=>'slices')) . "Slices", $form->text_html('slice','',array('width'=>30,'onSelect'=>'submit()', 'onFocus'=>'slices.checked=true'))); $details->space(); diff --git a/planetlab/includes/plc_details.php b/planetlab/includes/plc_details.php index c03f756..684adf5 100644 --- a/planetlab/includes/plc_details.php +++ b/planetlab/includes/plc_details.php @@ -108,10 +108,13 @@ class PlcDetails { print $this->th_td_html ($title,$value,$form_varname,$options); } function th_td_html ($title,$value,$form_varname="",$options=NULL) { + if (!$options) $options = array(); if ( ! ($this->editable && $form_varname) ) { + // xxx hack: if input_type is select, look for the 'value' option to display current value + if ($options['input_type'] == "select") + $value=$options['value']; return "$title$value"; } else { - if (!$options) $options = array(); // use options if provided, otherwise the latest set_ function if (array_key_exists('input_type',$options)) $input_type=$options['input_type']; else $input_type=$this->input_type; @@ -123,7 +126,7 @@ class PlcDetails { $html=""; $html .= ""; $html .= ""; - // hack: if input_type is select : user provides the input field verbatim + // xxx hack: if input_type is select : user provides the input field verbatim if ( $input_type == "select" ) { $html .= $value; } else if ($input_type == "textarea") { @@ -135,11 +138,8 @@ class PlcDetails { // set id too $html .= "end_html(); } function end_html() { return ""; } - static function hidden_html ($key,$value) { - return ""; - } - static function checkbox_html ($name,$value,$selected=false) { - if ($selected) $xtra=" selected=selected"; - return ""; - } - static function submit_html ($name,$display) { - return ""; - } - static function file_html ($name,$size) { - return ""; - } - static function label_html ($name,$display) { - return ""; - } - static function radio_html ($id, $name, $value, $checked) { - $html="$value) { + if (in_array(strtolower($key),$names)) + $html .= " $key='$value'"; + } return $html; } + // options // (*) width to set the text size // (*) callbacks, e.g. onFocus=>'your javascript code' - static function text_html ($name,$value,$options=NULL) { - $default_options = array('width'=>20); + static function input_html ($type,$name,$value,$options=NULL) { if ( ! $options) $options=array(); - $options = array_merge($default_options,$options); - $html="$display"; + } static function textarea_html ($name,$value,$cols,$rows) { return ""; } diff --git a/planetlab/nodes/interface.js b/planetlab/nodes/interface.js index 1669779..08bc28d 100644 --- a/planetlab/nodes/interface.js +++ b/planetlab/nodes/interface.js @@ -104,7 +104,16 @@ function networkHelper () { } /* check one */ -function subnetChecker (args) { +function subnetChecker (id, optional) { + var error= subnetCheckerSilent([id,optional]); + if (error) { + Form.Element.focus($(id)); + alert(error); + } +} + +function subnetCheckerSilent (args) { + id=args[0]; optional=args[1]; @@ -124,13 +133,13 @@ function subnetChecker (args) { return ""; } -function formSubmit () { +function interfaceSubmit () { + alert ('submitting'); // get error strings, and remove the empty ones // dns2 is optional - var errors=['gateway','dns1'].zip ([true,true,false],subnetChecker).reject( function (s) {return s.length==0;} ); + var errors=['gateway','dns1','dns2'].zip ([true,true,false],subnetCheckerSilent).reject( function (s) {return s.length==0;} ); if ( ! errors.length) $('ip').up('form').submit(); else alert(errors.join("\n")); } - diff --git a/planetlab/nodes/interface.php b/planetlab/nodes/interface.php index 3b9fd90..0554939 100644 --- a/planetlab/nodes/interface.php +++ b/planetlab/nodes/interface.php @@ -67,8 +67,10 @@ drupal_set_title (' $details=new PlcDetails($can_update); -// hardwire network type -$form=$details->form_start(l_actions(),array('node_id'=>$node_id,'type'=>"ipv4")); +// xxx hardwire network type for now +$form_variables = array('node_id'=>$node_id,'type'=>"ipv4"); +if ($mode == "update") $form_variables['interface_id']=$interface_id; +$form=$details->form_start(l_actions(),$form_variables); $details->start(); @@ -87,25 +89,26 @@ function method_selectors ($api, $method) { } $method_select = $form->select_html ("method",method_selectors($api,$interface['method']), array('id'=>'method','onChange'=>'updateMethodFields()')); -$details->th_td("Method",$method_select,"method",array('input_type'=>'select')); +$details->th_td("Method",$method_select,"method",array('input_type'=>'select','value'=>$interface['method'])); // dont display the 'type' selector as it contains only ipv4 //>>> GetNetworkTypes() //[u'ipv4'] -$ip_options=array('width'=>15); -$ip_options_plus=array_merge($ip_options,array('onKeyup'=>'networkHelper()', - 'onChange'=>'networkHelper()', - )); -$ip_options_tmp=array_merge($ip_options,array('onKeyup'=>'subnetChecker("dns1")')); - -$details->th_td("IP",$interface['ip'],"ip",$ip_options_plus); -$details->th_td("Netmask",$interface['netmask'],"netmask",$ip_options_plus); -$details->th_td("Network",$interface['network'],"network",$ip_options); -$details->th_td("Broadcast",$interface['broadcast'],"broadcast",$ip_options); -$details->th_td("Gateway",$interface['gateway'],"gateway",$ip_options); -$details->th_td("DNS 1",$interface['dns1'],"dns1",$ip_options_tmp); -$details->th_td("DNS 2",$interface['dns2'],"dns2",$ip_options); +$details->th_td("IP",$interface['ip'],"ip",array('width'=>15, + 'onKeyup'=>'networkHelper()', + 'onChange'=>'networkHelper()')); +$details->th_td("Netmask",$interface['netmask'],"netmask",array('width'=>15, + 'onKeyup'=>'networkHelper()', + 'onChange'=>'networkHelper()')); +$details->th_td("Network",$interface['network'],"network",array('width'=>15)); +$details->th_td("Broadcast",$interface['broadcast'],"broadcast",array('width'=>15)); +$details->th_td("Gateway",$interface['gateway'],"gateway",array('width'=>15, + 'onChange'=>'subnetChecker("gateway",false)')); +$details->th_td("DNS 1",$interface['dns1'],"dns1",array('width'=>15, + 'onChange'=>'subnetChecker("dns1",false)')); +$details->th_td("DNS 2",$interface['dns2'],"dns2",array('width'=>15, + 'onChange'=>'subnetChecker("dns2",true)')); $details->space(); $details->th_td("BW limit (bps)",$interface['bwlimit'],"bwlimit",array('width'=>11)); $details->th_td("Hostname",$interface['hostname'],"hostname"); @@ -114,15 +117,16 @@ $mac=$interface['mac']; if ($mac) $details->th_td("MAC address",$mac); // the buttons -$update_button = $form->submit_html ("update-interface","Update"); -$add_button = $form->submit_html ("add-interface","Add as new"); -$dbg=""; +$update_button = $form->submit_html ("update-interface","Update", + array('onSubmit'=>'interfaceSubmit()')); +$add_button = $form->submit_html ("add-interface","Add as new", + array('onSubmit'=>'interfaceSubmit()')); switch ($mode) { case 'add': $details->tr($add_button,"right"); break; case 'update': - $details->tr($update_button . $add_button . $dbg,"right"); + $details->tr($update_button . " " . $add_button,"right"); break; } diff --git a/planetlab/persons/person.php b/planetlab/persons/person.php index 6b3f659..126dee9 100644 --- a/planetlab/persons/person.php +++ b/planetlab/persons/person.php @@ -229,7 +229,7 @@ if ($can_manage_keys) { } $table->row_start(); $table->cell($form->label_html("key","Upload new key") - . $form->file_html("key",60) + . $form->file_html("key","upload",array('size'=>60)) . $form->submit_html("upload-key","Upload key"), $table->columns(),"right"); $table->row_end(); diff --git a/planetlab/prototype/prototype-1.6.0.3.js b/planetlab/prototype/prototype-1.6.0.3.js index dfe8ab4..afb3c95 100644 --- a/planetlab/prototype/prototype-1.6.0.3.js +++ b/planetlab/prototype/prototype-1.6.0.3.js @@ -495,7 +495,7 @@ Object.extend(String.prototype, { isJSON: function() { var str = this; if (str.blank()) return false; - str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''); + str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''); /* " for fooling emacs*/ return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str); }, @@ -4317,4 +4317,4 @@ Object.extend(Element.ClassNames.prototype, Enumerable); /*--------------------------------------------------------------------------*/ -Element.addMethods(); \ No newline at end of file +Element.addMethods(); diff --git a/planetlab/tags/tag.php b/planetlab/tags/tag.php index 2112202..7d20f19 100644 --- a/planetlab/tags/tag.php +++ b/planetlab/tags/tag.php @@ -63,15 +63,12 @@ $details->th_td("Name",$tagname,"tagname"); $details->th_td("Category",$category,"category"); $details->th_td("Description",$description,"description"); -// xxx misses in PlcDetails if ($can_update) { -//tmp // select the option corresponding with min_role_id $selectors = $details->form()->role_selectors($api,"",$min_role_id); $select_field = $details->form()->select_html("min_role_id",$selectors); - $save_i=$details->set_input_type("select"); - $details->th_td("Min role",$select_field,"min_role_id"); - $details->set_input_type($save_i); + // xxx would need to turn role_id into role name + $details->th_td("Min role",$select_field,"min_role_id",array('input_type'=>'select','value'=>$min_role_id)); } else { $details->th_td("Min role",$min_role_id); }