From 1fee509dbe62c3db0a5d21264efad73963c7e635 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Fri, 30 Jan 2009 17:14:46 +0000 Subject: [PATCH] ckp - sites complete --- planetlab/actions.php | 6 +++-- planetlab/addresses/index.php | 16 ------------- planetlab/includes/plc_functions.php | 7 ++++-- planetlab/nodes/node.php | 36 +++++++++++++++++----------- planetlab/persons/person.php | 15 +++++++++--- planetlab/sites/site.php | 33 +++++++++++++++++++------ 6 files changed, 69 insertions(+), 44 deletions(-) diff --git a/planetlab/actions.php b/planetlab/actions.php index b69af23..1d7123b 100644 --- a/planetlab/actions.php +++ b/planetlab/actions.php @@ -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); } diff --git a/planetlab/addresses/index.php b/planetlab/addresses/index.php index f5c3e23..e6aaf9b 100644 --- a/planetlab/addresses/index.php +++ b/planetlab/addresses/index.php @@ -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 "

This page is under construction

"; -if( !$_GET['id'] ) { - - -} -else { - - -} - // Print footer include 'plc_footer.php'; diff --git a/planetlab/includes/plc_functions.php b/planetlab/includes/plc_functions.php index 2bcf31f..a23e1ea 100644 --- a/planetlab/includes/plc_functions.php +++ b/planetlab/includes/plc_functions.php @@ -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( "\n" ); } -function plc_warning_text ($text) { return "
" . $text . "
";} +function plc_warning_text ($text) { return "" . $text . "";} function plc_warning ($text) { print plc_warning_text("Warning " . $text); } -function plc_foreign_text($text) { return "
$text
"; } +function plc_foreign_text($text) { return "$text"; } // shows a php variable verbatim with a heading message function plc_debug ($message,$object) { diff --git a/planetlab/nodes/node.php b/planetlab/nodes/node.php index 842b8b7..0c15c8a 100644 --- a/planetlab/nodes/node.php +++ b/planetlab/nodes/node.php @@ -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
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 "Boot State: "; -if ($peer_id) { +if ( ! $local_peer) { echo $boot_state; } else { echo "
\n"; @@ -168,7 +171,7 @@ if ($peer_id) { echo "\n"; // same here for the download area -if ( ! $peer_id && $privileges) { +if ( $local_peer && $privileges) { echo "Download "; echo "\n"; @@ -234,13 +237,18 @@ plc_table_end("node_tags"); plc_section ("Slices"); if ( ! $slices ) { - echo "

This node is not associated to any slice.

\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 ) { diff --git a/planetlab/persons/person.php b/planetlab/persons/person.php index 87b6827..74dd797 100644 --- a/planetlab/persons/person.php +++ b/planetlab/persons/person.php @@ -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,"
")); +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 ) { diff --git a/planetlab/sites/site.php b/planetlab/sites/site.php index 822ed4c..cdce78e 100644 --- a/planetlab/sites/site.php +++ b/planetlab/sites/site.php @@ -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; -- 2.47.0