split in two
[plewww.git] / planetlab / nodes / interface.php
index 3b9fd90..70afd19 100644 (file)
@@ -9,9 +9,10 @@ global $plc, $api;
 
 // Common functions
 require_once 'plc_functions.php';
-require_once 'plc_minitabs.php';
-require_once 'plc_details.php';
-require_once 'plc_tables.php';
+require_once 'linetabs.php';
+require_once 'details.php';
+require_once 'table.php';
+require_once 'toggle.php';
 
 require_once 'plc_drupal.php';
 include 'plc_header.php';
@@ -43,8 +44,8 @@ if ( ! $node_id) {
  }
 
 $tabs=array();
-$tabs['Back to node']=array('url'=>l_node($node_id),
-                           'bubble'=>'Cancel pending changes');
+$tabs[] = array('label'=>'Back to node', 'url'=>l_node($node_id),
+               'bubble'=>'Cancel pending changes');
 plc_tabs($tabs);
 
 $fields=array( 'method', 'type', 'ip', 'gateway', 'network', 'broadcast', 'netmask', 
@@ -61,14 +62,15 @@ drupal_set_title("Interface on " . $node['hostname']);
 
 // include javacsript helpers
 drupal_set_title ('
-<script type="text/javascript" src="/planetlab/prototype/prototype.js"></script>
 <script type="text/javascript" src="/planetlab/nodes/interface.js"></script>
 ');
 
 $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="<input type=button onclick='formSubmit()' value='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 . "&nbsp" . $add_button,"right");
    break;
  }
 
@@ -134,6 +138,9 @@ if ($mode == 'add') return;
 
 
 //////////////////////////////////////// tags
+$toggle=new PlcToggle ('tags','Tags',array('trigger-tagname'=>'h2'));
+$toggle->start();
+
 $form = new PlcForm (l_actions(),array('interface_id'=>$interface_id));
 $form->start();
 
@@ -141,7 +148,7 @@ $tags=$api->GetInterfaceTags (array('interface_id'=>$interface_id));
 function get_tagname ($tag) { return $tag['tagname'];}
 $tagnames = array_map ("get_tagname",$tags);
   
-plc_section("Tags");
+
 $headers=array("Name"=>"string",
               "Value"=>"string",
               );
@@ -184,6 +191,9 @@ if ($can_update) {
   
 $table->end();
 $form->end();
+$toggle->end();
+
+//plc_tabs ($tabs,"bottom");
 
 // Print footer
 include 'plc_footer.php';