svn:keywords
[plewww.git] / planetlab / nodes / interface.php
index a1f9011..471d8d3 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+// $Id$ 
+
 // Require login
 require_once 'plc_login.php';
 
@@ -9,9 +11,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';
@@ -30,10 +33,12 @@ if ( isset ($_GET['id'])) {
   $interfaces=$api->GetInterfaces(array('interface_id'=>$interface_id));
   $interface=$interfaces[0];
   $node_id=$interface['node_id'];
+  $title=('Updating interface ' . $interface['ip']);
  } else if (isset ($_GET['node_id'])) {
   $mode='add';
   $interface=array();
   $node_id=$_GET['node_id'];
+  $title=('Adding interface');
  } 
 // check
 if ( ! $node_id) {
@@ -45,7 +50,7 @@ if ( ! $node_id) {
 $tabs=array();
 $tabs[] = array('label'=>'Back to node', 'url'=>l_node($node_id),
                'bubble'=>'Cancel pending changes');
-plc_tabs($tabs);
+plekit_linetabs($tabs);
 
 $fields=array( 'method', 'type', 'ip', 'gateway', 'network', 'broadcast', 'netmask', 
               'dns1', 'dns2', 'hostname', 'mac', 'bwlimit', 'node_id' );
@@ -57,15 +62,15 @@ $site_id=$node['site_id'];
 
 $can_update= plc_is_admin() || ( plc_in_site ($site_id) && ( plc_is_pi() || plc_is_tech()));
 
-drupal_set_title("Interface on " . $node['hostname']);
+drupal_set_title($title . " on " . $node['hostname']);
 
 // include javacsript helpers
-drupal_set_title ('
-<script type="text/javascript" src="/planetlab/prototype/prototype.js"></script>
+require_once 'prototype.php';
+drupal_set_html_head ('
 <script type="text/javascript" src="/planetlab/nodes/interface.js"></script>
 ');
 
-$details=new PlcDetails($can_update);
+$details=new PlekitDetails($can_update);
 
 // xxx hardwire network type for now
 $form_variables = array('node_id'=>$node_id,'type'=>"ipv4");
@@ -74,20 +79,8 @@ $form=$details->form_start(l_actions(),$form_variables);
 
 $details->start();
 
-//>>> GetNetworkMethods()
-//[u'static', u'dhcp', u'proxy', u'tap', u'ipmi', u'unknown']
-function method_selectors ($api, $method) {
-  $builtin_methods=array("static"=>"Static", "dhcp"=>"DHCP", "proxy"=>"Proxy",  
-                        "tap"=>"TUN/TAP", "ipmi"=>"IPMI");
-  $selectors=array();
-  foreach ($builtin_methods as $value=>$display) {
-    $selector=array('display'=>$display, 'value'=>$value);
-    if ($value == $method) $selector['selected']=true;
-    $selectors []= $selector;
-  }
-  return $selectors;
-}
-$method_select = $form->select_html ("method",method_selectors($api,$interface['method']),
+$method_select = $form->select_html ("method",
+                                    interface_method_selectors($api,$interface['method'],false),
                                     array('id'=>'method','onChange'=>'updateMethodFields()'));
 $details->th_td("Method",$method_select,"method",array('input_type'=>'select','value'=>$interface['method']));
 
@@ -112,7 +105,7 @@ $details->th_td("DNS 2",$interface['dns2'],"dns2",array('width'=>15,
 $details->space();
 $details->th_td("BW limit (bps)",$interface['bwlimit'],"bwlimit",array('width'=>11));
 $details->th_td("Hostname",$interface['hostname'],"hostname");
-# should the user be allowed to change this ?
+# xxx should the user be allowed to change this ?
 $mac=$interface['mac'];
 if ($mac) $details->th_td("MAC address",$mac);
 
@@ -138,21 +131,24 @@ if ($mode == 'add') return;
 
 
 //////////////////////////////////////// tags
-$form = new PlcForm (l_actions(),array('interface_id'=>$interface_id));
+$toggle=new PlekitToggle ('tags','Tags');
+$toggle->start();
+
+$form = new PlekitForm (l_actions(),array('interface_id'=>$interface_id));
 $form->start();
 
 $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",
               );
 if ($can_update) $headers[plc_delete_icon()]="none";
   
 $table_options=array("notes_area"=>false,"pagesize_area"=>false,"search_width"=>10);
-$table=new PlcTable("interface_tags",$headers,0,$table_options);
+$table=new PlekitTable("interface_tags",$headers,0,$table_options);
 $table->start();
 if ($tags) foreach ($tags as $tag) {
   $table->row_start();
@@ -188,6 +184,9 @@ if ($can_update) {
   
 $table->end();
 $form->end();
+$toggle->end();
+
+//plekit_linetabs ($tabs,"bottom");
 
 // Print footer
 include 'plc_footer.php';