ckp - sites complete
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 30 Jan 2009 17:14:46 +0000 (17:14 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 30 Jan 2009 17:14:46 +0000 (17:14 +0000)
planetlab/actions.php
planetlab/addresses/index.php
planetlab/includes/plc_functions.php
planetlab/nodes/node.php
planetlab/persons/person.php
planetlab/sites/site.php

index b69af23..1d7123b 100644 (file)
@@ -57,7 +57,9 @@ else
       break;
     }
 
-//
+//debug
+//$action='debug';
+
 $person_id = $_POST['person_id'];      // usually needed
 
 if ( ! $action ) {
@@ -242,7 +244,7 @@ switch ($action) {
    }
    // update site to not allow slice creation or renewal
    $api->UpdateSite( $site_id, array( "max_slices" => 0 )) ;
-   header ("location: " l_site($site_id));
+   header ("location: " l_site($site_id));
    exit(0);
  }
 
index f5c3e23..e6aaf9b 100644 (file)
@@ -16,24 +16,8 @@ include 'plc_header.php';
 require_once 'plc_functions.php';
 require_once 'plc_sorts.php';
 
-// find person roles
-$_person= $plc->person;
-$_roles= $_person['role_ids'];
-
-//print_r( $_person );
-
-
 print "<p class='plc-warning'> This page is under construction </p>";
 
-if( !$_GET['id'] ) {
-  
-
-}
-else {
-
-
-}
-
 // Print footer
 include 'plc_footer.php';
 
index 2bcf31f..a23e1ea 100644 (file)
@@ -109,6 +109,9 @@ function l_person_register()                { return "/db/persons/register.php"; }
 function l_site_register()             { return "/db/sites/register.php"; }
 function l_sites_pending()             { return "/db/sites/join_request.php"; }
 
+function tabs_events()                 { return array('image'=>'/planetlab/icons/event.png','height'=>18);}
+function tabs_comon()                  { return array('image'=>'/planetlab/icons/comon.png','height'=>18);}
+
 // returns array ['url' => path, 'values' => hash (key=>value)* ]
 function split_url ($full_url) {
   list($url,$args) = explode("?",$full_url);
@@ -395,9 +398,9 @@ function plc_errors ($list) {
   print( "</ul></div>\n" );
 }
 
-function plc_warning_text ($text)      { return "<div class='plc-warning'>" . $text . "</div>";}
+function plc_warning_text ($text)      { return "<span class='plc-warning'>" . $text . "</span>";}
 function plc_warning ($text)           { print plc_warning_text("Warning " . $text); }
-function plc_foreign_text($text)       { return "<div class=plc-foreign>$text</div>"; }
+function plc_foreign_text($text)       { return "<span class=plc-foreign>$text</span>"; }
 
 // shows a php variable verbatim with a heading message
 function plc_debug ($message,$object) {
index 842b8b7..0c15c8a 100644 (file)
@@ -102,7 +102,7 @@ if( !empty( $pcu_ids ) )
 // fetches peers and initialize hash peer_id->peer
 $peer_hash = plc_peer_global_hash ($api);
 // show gray background on foreign objects : start a <div> with proper class
-plc_peer_block_start ($peer_hash,$peer_id);
+$local_peer = plc_peer_block_start ($peer_hash,$peer_id);
   
 drupal_set_title("Details for node " . $hostname);
   
@@ -111,7 +111,7 @@ $privileges = plc_is_admin () || ( plc_in_site($site_id) && ( plc_is_pi() || plc
   
 $tabs=array();
 // available actions
-if ( ! $peer_id  && $privileges ) {
+if ( $local_peer  && $privileges ) {
     
   $tabs['Update'] = array ('url'=>"/db/nodes/node_actions.php",
                           'method'=>'POST',
@@ -120,14 +120,17 @@ if ( ! $peer_id  && $privileges ) {
   $tabs['Delete'] = array ('url'=>"/db/nodes/node_actions.php",
                           'method'=>'POST',
                           'values'=>array('action'=>'delete','node_id'=>$node_id),
-                          'bubble'=>"Delete $hostname",
+                          'bubble'=>"Delete node $hostname",
                           'confirm'=>'Are you sure to delete ' . $hostname. ' ?');
   // xxx subject to roles
-  $tabs["Add Interface"]=l_interface_add($node_id);
-  $tabs["Comon"]=array('url'=>l_comon("node_id",$node_id),
-                      'buble'=>"Comon page for $hostname");
-  $tabs["Events"]=array('url'=>l_event("Node","node",$node_id),
-                       'bubble'=>"Events for node $hostname");
+  $tabs["Add Interface"]=array('url'=>l_interface_add($node_id),
+                              'bubble'=>"Declare new network interface on $hostname");
+  $tabs["Events"]=array_merge(tabs_events(),
+                             array('url'=>l_event("Node","node",$node_id),
+                                   'bubble'=>"Events for node $hostname"));
+  $tabs["Comon"]=array_merge(tabs_comon(),
+                            array('url'=>l_comon("node_id",$node_id),
+                                  'bubble'=>"Comon page about node $hostname"));
  }
 
 $tabs["All nodes"]=l_nodes();
@@ -135,16 +138,16 @@ $tabs["All nodes"]=l_nodes();
 plc_tabs($tabs);
 
 plc_details_start ();
-plc_details_line("Peer",plc_peer_label($peer));
 plc_details_line("Hostname",$hostname);
 plc_details_line("Type",$node_type);
 plc_details_line("Model",$model);
 plc_details_line("Version",$version);
+plc_details_line("Peer",plc_peer_label($peer));
 
 // no tool to implement this multiple-choice setting yet
 // xxx would need at least to use the proper class, like plc_details_class() or something
 echo "<tr><th>Boot State: </th><td>";
-if ($peer_id) {
+if ( ! $local_peer) {
   echo $boot_state;
  } else {
   echo "<form name='bootstate' action='/db/nodes/node_actions.php' method=post>\n";
@@ -168,7 +171,7 @@ if ($peer_id) {
 echo "</td></tr>\n";
 
 // same here for the download area
-if ( ! $peer_id  && $privileges) {
+if ( $local_peer  && $privileges) {
 
   echo "<tr><th>Download </th><td>";
   echo "<form name='download' action='/db/nodes/node_actions.php' method='post'>\n";
@@ -234,13 +237,18 @@ plc_table_end("node_tags");
 
 plc_section ("Slices");
 if ( ! $slices  ) {
-  echo "<p><span class='plc-warning'>This node is not associated to any slice.</span></p>\n";
+  plc_warning ("This node is not associated to any slice");
  } else {
   $headers=array();
   $headers['Peer']="string";
   $headers['Name']="string";
   $headers['Slivers']="string";
-  $table_options = array('notes_area'=>false,"search_width"=>10);
+  $reasonable_page=10;
+  $table_options = array('notes_area'=>false,"search_width"=>10,'pagesize'=>$reasonable_page);
+  if (count ($slices) <= $reasonable_page) {
+    $table_options['search_area']=false;
+    $table_options['pagesize_area']=false;
+  }
   plc_table_start ("node_slices",$headers,1,$table_options);
 
   foreach ($slices as $slice) {
@@ -254,7 +262,7 @@ if ( ! $slices  ) {
  }
 
 //////////////////////////////////////////////////////////// interfaces
-if ( ! $peer_id ) {
+if ( $local_peer ) {
 
   // display interfaces
   if( ! $interfaces ) {
index 87b6827..74dd797 100644 (file)
@@ -65,6 +65,10 @@ $keys= $api->GetKeys( $key_ids );
 drupal_set_title("Details for account " . $first_name . " " . $last_name);
 
 $plc_hash=plc_peer_global_hash($api);
+if ($peer_id) {
+  $peers=$api->GetPeers(array($peer_id));
+  $peer=$peers[0];
+}
 
 $local_peer = plc_peer_block_start ($peer_hash,$peer_id);
 $is_my_account = plc_my_person_id() == $person_id;
@@ -117,8 +121,7 @@ if ( $privileges)
   $tabs['Events'] = array('url'=>l_events(),
                          'values'=>array('type'=>'Person','person'=>$person_id),
                          'bubble'=>"Events about $first_name $last_name",
-                         'image'=>'/planetlab/icons/event.png',
-                         'height'=>18);
+                         'image'=>'/planetlab/icons/event.png','height'=>18);
 
 // Back button
 $tabs['All Users'] = array ('url'=>l_persons(),
@@ -141,6 +144,7 @@ plc_details_line("URL",$url);
 plc_details_line("Phone",$phone);
 plc_details_line("Title",$title);
 plc_details_line("Bio",wordwrap($bio,50,"<br/>"));
+plc_details_line("Peer",plc_peer_label($peer));
 plc_details_end();
 
 //////////////////// slices
@@ -150,7 +154,12 @@ if( ! $slices) {
   plc_warning ("User has no slice");
  } else {
   $headers=array('Slice name'=>'string');
-  $table_options=array('notes_area'=>false, 'pagesize_area'=>false, 'pagesize'=>999, 'search_width'=>10);
+  $reasonable_page=5;
+  $table_options = array('notes_area'=>false,"search_width"=>10,'pagesize'=>$reasonable_page);
+  if (count ($slices) <= $reasonable_page) {
+    $table_options['search_area']=false;
+    $table_options['pagesize_area']=false;
+  }
   plc_table_start("person_slices",$headers,1,$table_options);
 
   foreach( $slices as $slice ) {
index 822ed4c..cdce78e 100644 (file)
@@ -103,7 +103,8 @@ $tabs=array();
 // available actions
 if ( ! $peer_id  && $privileges ) {
   
-  $tabs['Update']=array('url'=>l_site_update($site_id));
+  $tabs['Update']=array('url'=>l_site_update($site_id),
+                       'bubble'=>"Update details of $sitename");
   // not avail to PI
   $tabs['Expire slices'] = array('url'=>l_actions(),
                                 'values'=>array('site_id'=>$site_id,
@@ -114,12 +115,14 @@ if ( ! $peer_id  && $privileges ) {
     $tabs['Delete']=array('url'=>l_actions(),
                          'values'=>array('site_id'=>$site_id,
                                          'action'=>'delete-site'),
-                         'bubble'=>"Delete site $login_base",
+                         'bubble'=>"Delete site $sitename",
                          'confirm'=>"Are you sure you want to delete site $login_base");
-  $tabs["Events"]=array('url'=>l_event("Site","site",$site_id),
-                       'bubble'=>"Events for site $hostname");
-  $tabs["Comon"]=array('url'=>l_comon("site_id",$site_id),
-                      'buble'=>"Comon page for $hostname");
+  $tabs["Events"]=array_merge (tabs_events(),
+                              array('url'=>l_event("Site","site",$site_id),
+                                    'bubble'=>"Events for site $sitename"));
+  $tabs["Comon"]=array_merge(tabs_comon(),
+                            array('url'=>l_comon("site_id",$site_id),
+                                  'bubble'=>"Comon page for $sitename"));
 
   if (plc_is_admin()) 
     $tabs['Pending'] = array ('url'=>l_sites_pending(),
@@ -136,16 +139,32 @@ if ( ! $enabled )
               " to review pending applications.");
 
 plc_details_start();
-plc_details_line("Peer",plc_peer_label($peer));
 plc_details_line("Full name",$sitename);
 plc_details_line("Login base",$login_base);
 plc_details_line("Abbreviated name",$abbrev_name);
 plc_details_line("URL",$site_url);
 plc_details_line("Latitude",$site_lat);
 plc_details_line("Longitude",$site_long);
+plc_details_line("Peer",plc_peer_label($peer));
 
 if ( ! $peer_id ) {
 
+  // Addresses
+  if ($addresses) {
+    plc_details_space_line();
+    plc_details_line("Addresses","");
+    foreach ($addresses as $address) {
+      plc_details_line(plc_vertical_table($address['address_types']),
+                      plc_vertical_table($address['line1'],
+                                         $address['line2'],
+                                         $address['line3'],
+                                         $address['city'],
+                                         $address['state'],
+                                         $address['postalcode'],
+                                         $address['country']));
+    }
+  }
+
   // Nodes
   plc_details_space_line();
   $nb_boot = 0;