From d7cc4e048eea83c6bb75bef519723a918a9c44d0 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 11 Mar 2009 07:32:57 +0000 Subject: [PATCH] ckp --- planetlab/common/actions.php | 26 ++ planetlab/css/plc_style.css | 2 +- planetlab/includes/plc_functions.php | 25 +- planetlab/nodes/node.php | 14 +- planetlab/nodes/nodes.php | 49 ++- planetlab/persons/person.php | 15 +- planetlab/sites/site.php | 13 +- planetlab/slices/index.php | 503 +------------------------- planetlab/slices/renew_slice.php | 171 --------- planetlab/slices/slice.php | 522 +++++++++++++++++++++++++++ planetlab/slices/slices.php | 139 +++++++ planetlab/tags/nodegroup.php | 2 +- plekit/details/details.css | 2 +- plekit/php/table.php | 31 +- plekit/php/toggle.php | 2 +- plekit/table/table.css | 22 +- plekit/toggle/toggle.css | 7 +- 17 files changed, 802 insertions(+), 743 deletions(-) delete mode 100644 planetlab/slices/renew_slice.php create mode 100644 planetlab/slices/slice.php create mode 100644 planetlab/slices/slices.php diff --git a/planetlab/common/actions.php b/planetlab/common/actions.php index 0a0bec4..b7b2bc8 100644 --- a/planetlab/common/actions.php +++ b/planetlab/common/actions.php @@ -66,6 +66,10 @@ $known_actions []= "expire-all-slices-in-site"; $known_actions []= "update-site"; // expects: site_id & name abbreviated_name url latitude longitude [login_base max_slices] +//////////////////////////////////////// slices +$known_actions []= "renew-slice"; +// expects: slice_id & expires + //////////////////////////////////////// tag types $known_actions []= "update-tag-type"; // expects: tag_type_id & name & description & category & min_role_id @@ -425,6 +429,28 @@ switch ($action) { break; } +//////////////////////////////////////////////////////////// slices + case 'renew_slice': { + $slice_id = intval ($_POST['slice_id']); + $expires = intval ($_POST['expires']); + // 8 weeks from now + // xxx + $now=date(); + $WEEKS=8; + $MAX_FUTURE=$WEEKS*7*24*3600; + if ( ($expires-$now) > $MAX_FUTURE) { + drupal_set_error("Cannot renew slice that far in the future, max is $WEEKS from now"); + plc_redirect(l_slice($slice_id)); + } + if ($api->UpdateSlice ($slice_id, array('expires'=>$expires)) == 1) + drupal_set_message("Slice renewed"); + else + drupal_set_error("Could not update slice $slice_id"); + plc_redirect(l_slice($slice_id)); + break; + } + + //////////////////////////////////////////////////////////// tag types case 'update-tag-type': { diff --git a/planetlab/css/plc_style.css b/planetlab/css/plc_style.css index 1740333..32869ea 100644 --- a/planetlab/css/plc_style.css +++ b/planetlab/css/plc_style.css @@ -28,7 +28,7 @@ body { background: #e0e0e0; } .plc-warning { - background: orange; + background: #ffa223; } .plc-error { background: red; diff --git a/planetlab/includes/plc_functions.php b/planetlab/includes/plc_functions.php index 5e8fcc2..d5de8a5 100644 --- a/planetlab/includes/plc_functions.php +++ b/planetlab/includes/plc_functions.php @@ -58,6 +58,7 @@ function l_node_t ($node_id,$text) { return href (l_node($node_id),$text); } function l_node_obj($node) { return href(l_node($node['node_id']),$node['hostname']); } function l_node_add () { return "/db/nodes/node_add.php"; } function l_nodes_site ($site_id) { return "/db/nodes/index.php?site_id=$site_id"; } +function l_nodes_slice ($slice_id) { return "/db/nodes/index.php?slice_id=$slice_id"; } function l_interface ($interface_id) { return "/db/nodes/interface.php?id=$interface_id"; } function l_interface_t ($interface_id,$text) { @@ -68,6 +69,7 @@ function l_sites () { return "/db/sites/index.php"; } function l_sites_peer ($peer_id) { return "/db/sites/index.php?peerscope=$peer_id"; } function l_site ($site_id) { return "/db/sites/index.php?id=$site_id"; } function l_site_t ($site_id,$text) { return href (l_site($site_id),$text); } +function l_site_obj($site) { return href (l_site($site['site_id']),$site['name']); } function l_slices () { return "/db/slices/index.php"; } function l_slices_peer ($peer_id) { return "/db/slices/index.php?peerscope=$peer_id"; } @@ -75,6 +77,7 @@ function l_slice ($slice_id) { return "/db/slices/index.php?id=$slice_id"; } function l_slice_t ($slice_id,$text) { return href (l_slice($slice_id),$text); } function l_slice_add () { return "/db/slices/slice_add.php"; } function l_slices_site($site_id) { return "/db/slices/index.php?site_id=$site_id"; } +function l_slices_local() { return "/db/slices/index.php?peerscope=local"; } // from an object function l_slice_obj ($slice) { return l_slice_t ($slice['slice_id'],$slice['name']); } @@ -128,21 +131,30 @@ function tab_nodes_local () { return array ('label'=>'Local nodes', 'url'=>l_nod 'bubble'=>'Display local nodes only'); } function tab_nodes_site($site_id){ return array ('label'=>'Site nodes', 'url'=>l_nodes_site($site_id), 'bubble'=>'Display nodes on that site'); } +function tab_nodes_slice($slice_id){ return array ('label'=>'Slice nodes', 'url'=>l_nodes_slice($slice_id), + 'bubble'=>'Display nodes for that slice'); } function tab_nodes_mysite () { return array ('label'=>'My nodes', 'url'=>l_nodes_site(plc_my_site_id()), - 'bubble'=>'Display nodes on that site'); } -function tab_node($node) { return array ('label'=>'Node '.$node['hostname'], 'url'=>l_node($node_id), + 'bubble'=>'Display nodes on my site'); } +function tab_node($node) { return array ('label'=>'Node '.$node['hostname'], 'url'=>l_node($node['node_id']), 'bubble'=>'Details for ' . $node['hostname']); } ////////// -function tab_site($site) { return array ('label'=>'Site '.$site['login_base'], 'url'=>l_site($site_id), +function tab_site($site) { return array ('label'=>'Site '.$site['login_base'], 'url'=>l_site($site['site_id']), 'bubble'=>'Details for ' . $site['name']); } function tab_mysite() { return array ('label'=>'My site', 'url'=>l_site(plc_my_site_id()), 'bubble'=>'Details for site ' . plc_my_site_id()); } function tab_sites () { return array ('label'=>'All sites' , 'url'=>l_sites(), 'bubble'=> 'Display all sites'); } -function tab_sites_local () { return array ('label'=>'Local sites' , 'url'=>l_sites_peer('local'), 'bubble'=> 'Display local sites'); } +function tab_sites_local () { return array ('label'=>'Local sites' , 'url'=>l_sites_peer('local'), + 'bubble'=> 'Display local sites'); } ////////// function tab_slices() { return array ('label'=>'All slices', 'url'=>l_slices(), 'bubble' => 'Display all slices'); } -function tab_slice($slice) { return array ('label'=>'Slice '.$slice['name'], 'url'=>l_slice($slice_id), +function tab_slices_mysite () { return array ('label'=>'My site slices', 'url'=>l_slices_site(plc_my_site_id()), + 'bubble'=>'Display all slices on my site'); } +function tab_slices_mine () { return array ('label'=>'My site slices', 'url'=>l_slices_site(plc_my_site_id()), + 'bubble'=>'Display all slices on my site'); } +function tab_slices_local () { return array ('label'=>'Local slices', 'url'=>l_slices_local(), + 'bubble'=>'Display all slices on my site'); } +function tab_slice($slice) { return array ('label'=>'Slice '.$slice['name'], 'url'=>l_slice($slice['slice_id']), 'bubble' => 'Details for ' . $slice['name']); } ////////// function tab_persons() { return array ('label'=>'All accounts', 'url'=>l_persons(), @@ -151,6 +163,8 @@ function tab_persons_local() { return array ('label'=>'Local accounts', 'url'=>l 'bubble'=>'Display local users'); } function tab_persons_mysite() { return array ('label'=>'My accounts' , 'url'=>l_persons_site(plc_my_site_id()), 'bubble'=>'Display accounts on site ' . plc_my_site_id()); } +function tab_person($person) { return array ('label'=>'Account '.$person['email'], 'url'=>l_person($person['person_id']), + 'bubble'=>'Details for ' . $person['email']); } ////////// function tab_tags() { return array ('label'=>'Tag Types', 'url'=>l_tags(), 'bubble' => 'Display and create tag types'); } @@ -273,6 +287,7 @@ function plc_nodegroup_global_hash ($api,$tagnames=NULL) { //////////////////////////////////////////////////////////// titles function t_site($site) { return " on site " . $site['name'] . " (" . $site['login_base'] .")"; } function t_slice ($slice) { return " running slice " . $slice['name'] . " (" . $slice['slice_id'] . ")"; } +function t_person ($person) { return " belonging to " . $person['email'] . " (" . $person['person_id'] . ")"; } //////////////////////////////////////////////////////////// html fragments function plc_vertical_table ($messages, $class="") { diff --git a/planetlab/nodes/node.php b/planetlab/nodes/node.php index 2ebc3f4..06d0792 100644 --- a/planetlab/nodes/node.php +++ b/planetlab/nodes/node.php @@ -111,18 +111,17 @@ $tabs=array(); // available actions $tabs [] = tab_nodes_site($site_id); $tabs [] = tab_site($site_id); -$tabs [] = tab_nodes(); +//$tabs [] = tab_nodes(); if ( $local_peer && $privileges ) { + $tabs["Add Interface"]=array('url'=>l_interface_add($node_id), + 'bubble'=>"Define new network interface on $hostname"); $tabs['Delete'] = array ('url'=>l_actions(), 'method'=>'POST', 'values'=>array('action'=>'delete-node','node_id'=>$node_id), 'bubble'=>"Delete node $hostname", - 'confirm'=>'Are you sure to delete ' . $hostname. ' ?'); - // xxx subject to roles - $tabs["Add Interface"]=array('url'=>l_interface_add($node_id), - 'bubble'=>"Define new network interface on $hostname"); + 'confirm'=>'Are you sure to delete ' . $hostname); $tabs["Events"]=array_merge(tablook_event(), array('url'=>l_event("Node","node",$node_id), 'bubble'=>"Events for node $hostname")); @@ -136,6 +135,10 @@ plekit_linetabs($tabs); // show gray background on foreign objects : start a
with proper class $peers->block_start ($peer_id); +$toggle = new PlekitToggle ('node',"Details", + array('trigger-bubble'=>'Display and modify details for that node')); +$toggle->start(); + $details=new PlekitDetails($privileges); $details->start(); if ( ! $local_peer) { @@ -213,6 +216,7 @@ foreach ($site_node_hash as $hash_node_id => $hash_hostname) { $details->th_tds ("All site nodes",$nodes_area); $details->end (); +$toggle->end(); $form=new PlekitForm (l_actions(), array('node_id'=>$node_id)); $form->start(); diff --git a/planetlab/nodes/nodes.php b/planetlab/nodes/nodes.php index 6c57cf5..5aea940 100644 --- a/planetlab/nodes/nodes.php +++ b/planetlab/nodes/nodes.php @@ -29,7 +29,6 @@ $slice_id=intval($_GET['slice_id']); // --- decoration $title="Nodes"; $tabs=array(); -$mysite_id=plc_my_site_id(); $tabs []= tab_nodes_mysite(); $tabs []= tab_nodes_local(); @@ -141,30 +140,30 @@ $table->start(); $peers = new Peers ($api); // write rows foreach ($nodes as $node) { - $hostname=$node['hostname']; - $node_id=$node['node_id']; - $site_id=$node['site_id']; - $site=$site_hash[$site_id]; - $login_base = $site['login_base']; - $node_id=$node['node_id']; - $ip=$interface_hash[$node['node_id']]['ip']; - $interface_id=$interface_hash[$node['node_id']]['interface_id']; - $peer_id=$node['peer_id']; - $shortname = $peers->shortname($peer_id); - $node_type = $node['node_type']; - - $table->row_start(); - $table->cell ($peers->link($peer_id,$shortname)); - $table->cell (topdomain($hostname)); - $table->cell (l_site_t($site_id,$login_base)); - $table->cell ($node['boot_state']); - $table->cell (l_node_t($node_id,$hostname)); - $table->cell (l_interface_t($interface_id,$ip)); - $table->cell ($node_type); - $table->cell ($node['arch']); - $table->cell (node_status($node)); - $table->row_end(); - + $hostname=$node['hostname']; + $node_id=$node['node_id']; + $site_id=$node['site_id']; + $site=$site_hash[$site_id]; + $login_base = $site['login_base']; + $node_id=$node['node_id']; + $ip=$interface_hash[$node['node_id']]['ip']; + $interface_id=$interface_hash[$node['node_id']]['interface_id']; + $peer_id=$node['peer_id']; + $shortname = $peers->shortname($peer_id); + $node_type = $node['node_type']; + + $table->row_start(); + $table->cell ($peers->link($peer_id,$shortname)); + $table->cell (topdomain($hostname)); + $table->cell (l_site_t($site_id,$login_base)); + $table->cell ($node['boot_state']); + $table->cell (l_node_t($node_id,$hostname)); + $table->cell (l_interface_t($interface_id,$ip)); + $table->cell ($node_type); + $table->cell ($node['arch']); + $table->cell (node_status($node)); + $table->row_end(); + } $table->end(); diff --git a/planetlab/persons/person.php b/planetlab/persons/person.php index ff630e8..3154035 100644 --- a/planetlab/persons/person.php +++ b/planetlab/persons/person.php @@ -127,6 +127,12 @@ $enabled_label="Yes"; if ( ! $enabled ) $enabled_label = plc_warning_html("Disabled"); $can_update = (plc_is_admin() && $local_peer) || $is_my_account; + +$toggle = new PlekitToggle ('person',"Details", + array('trigger-bubble'=>'Display and modify details for that account', + 'start-visible'=>false)); +$toggle->start(); + $details = new PlekitDetails($can_update); $details->form_start(l_actions(),array("action"=>"update-person", @@ -158,9 +164,10 @@ if ( ! $local_peer ) { $details->end(); $details->form_end(); +$toggle->end(); //////////////////// slices -$toggle=new PlekitToggle ('slices','Slices'); +$toggle=new PlekitToggle ('slices','Slices',array('start-visible'=>false)); $toggle->start(); if( ! $slices) { @@ -192,7 +199,7 @@ $form=new PlekitForm(l_actions(), array("person_id"=>$person_id)); $form->start(); //////////////////// keys -$toggle=new PlekitToggle ('keys',"Keys"); +$toggle=new PlekitToggle ('keys',"Keys",array('start-visible'=>false)); $toggle->start(); $can_manage_keys = ( $local_peer && ( plc_is_admin() || $is_my_account) ); @@ -240,7 +247,7 @@ $table->end(); $toggle->end(); //////////////////// sites -$toggle=new PlekitToggle('sites','Sites'); +$toggle=new PlekitToggle('sites','Sites',array('start-visible'=>false)); $toggle->start(); if (empty( $sites ) ) { @@ -293,7 +300,7 @@ $table->end(); $toggle->end(); //////////////////// roles -$toggle=new PlekitToggle ('roles','Roles'); +$toggle=new PlekitToggle ('roles','Roles',array('start-visible'=>false)); $toggle->start(); if (! $roles) plc_warning ("This user has no role !"); diff --git a/planetlab/sites/site.php b/planetlab/sites/site.php index 81cb990..aa2c660 100644 --- a/planetlab/sites/site.php +++ b/planetlab/sites/site.php @@ -144,6 +144,12 @@ if ( ! $enabled ) " to review pending applications."); $can_update=(plc_is_admin () && $local_peer) || ( plc_in_site($site_id) && plc_is_pi()); + + +$toggle = new PlekitToggle ('site',"Details", + array('trigger-bubble'=>'Display and modify details for that site')); +$toggle->start(); + $details = new PlekitDetails($can_update); if ( ! $site['is_public']) @@ -176,6 +182,7 @@ if ( ! $local_peer) { } $details->end(); $details->form_end(); +$toggle->end(); //////////////////// mode details - for local object if ( $local_peer ) { @@ -185,7 +192,7 @@ if ( $local_peer ) { $nb_boot = 0; if ($nodes) foreach ($nodes as $node) if ($node['boot_state'] == 'boot') $nb_boot ++; - $nodes_title = "# Nodes : "; + $nodes_title = "Nodes : "; $nodes_title .= count($nodes) . " total"; $nodes_title .= " / " . $nb_boot . " boot"; if ($nb_boot < 2 ) @@ -218,12 +225,12 @@ if ( $local_peer ) { $toggle->end(); //////////////////// Users - $persons_title = "# Users : "; + $persons_title = "Users : "; $persons_title .= count($person_ids) . " total"; $persons_title .= " / " . count ($pis) . " PIs"; $persons_title .= " / " . count ($techs) . " Techs"; if ($has_disabled_persons) - $persons_title .= " / " . ($disabled_persons) . " Disabled"; + $persons_title .= " / " . count($disabled_persons) . " Disabled"; if ( (count ($pis) == 0) || (count ($techs) == 0) || (count($person_ids) >= 30) || count($disabled_persons) != 0 ) $persons_title = plc_warning_html ($persons_title); $persons_title .= href(l_persons_site($site_id)," (See as users)"); diff --git a/planetlab/slices/index.php b/planetlab/slices/index.php index 67b7b62..4aebbbf 100644 --- a/planetlab/slices/index.php +++ b/planetlab/slices/index.php @@ -1,510 +1,11 @@ person; -$_roles= $_person['role_ids']; - -//print_r( $_person ); - - -// if node_host is set then set id to that node's id. -if( $_POST['slicename'] ) { - $slicename= $_POST['slicename']; - - $slices= $api->GetSlices( array( $slicename ), array( "slice_id" ) ); - $slice=$slices[0]; - $slice_id=$slice['slice_id']; - - plc_redirect(l_slice($slice_id)); - -} - - -// if no slice id, display list of slices -if( !$_GET['id'] ) { - // diplay site select list for admins - if( in_array( 10, $_roles ) ) { - // auto complete box for finding a slice - - // xxx dismantle this - drupal_set_html_head(' - - '); - - echo "
\n -
\n"; - if( $slicename ) echo "'$slicename' is not a valid slice name.\n"; - echo "

\n - \n - \n -

\n -
\n"; - - // get site info - $site_info= $api->GetSites( NULL, array( "site_id", "name", "peer_id" ) ); - sort_sites( $site_info ); - - // Thierry -- try to select only one entry - // xxx still not right if _person in several sites, but that is good enough - //if( $site['site_id'] == $_POST['site_id'] || in_array( $site['site_id'], $_person['site_ids'] ) ) - if ($_POST['site_id']) - $selected_site_id = $_POST['site_id']; - else if ($_GET['site_id']) - $selected_site_id = $_GET['site_id']; - else - $selected_site_id = $_person['site_ids'][0]; - - echo "Select a site to view slices from:  "; - echo "\n"; - - } - - if( $_POST['site_id'] ) { - $selection="Site"; - $site= array( intval( $_POST['site_id'] ) ); - } elseif( $_GET['site_id'] ) { - $selection="Site"; - $site= array( intval( $_GET['site_id'] ) ); - } else { - $selection="Person"; - $site= $_person['site_ids']; - } - - // get site's slices - $site_info= $api->GetSites( $site, array( "slice_ids","name" ) ); - - if ( $selection == "Site" ) - drupal_set_title ("Slices for site " . $site_info[0]['name']); - else - drupal_set_title ("Slices for " . $_person['email'] . "'s sites"); - - // make an array of all slices - foreach( $site_info as $site ) { - foreach( $site['slice_ids'] as $slice_id ) { - $slice_ids[]= $slice_id; - } - - } - - if (empty ($slice_ids)) { - echo "

No slice found, or all are expired."; - } else { - - $slices= $api->GetSlices( $slice_ids, array( "slice_id", "name", "site_id", "person_ids", "expires", "peer_id" ) ); - $slice=$slices[0]; - //print '

'; print_r( $api->trace() ) ; print '
'; - - if ( ! $slices) { - echo "

No Slices on site, or all are expired.\n"; - } else { - echo "\n"; - echo "\n"; - echo ""; - echo ""; - echo ""; - echo "\n"; - - // create a list of person_ids - $person_ids = array(); - foreach( $slices as $slice ) { - if ( !empty($slice['person_ids']) ) - $person_ids = array_merge($person_ids, $slice['person_ids']); - } - - // create an associative array of persons with person_id as the key - $person_list = $api->GetPersons( $person_ids, array("person_id", "email") ); - $persons = array(); - foreach( $person_list as $person) - { - $persons[$person['person_id']] = $person; - } - - foreach( $slices as $slice ) { - $slice_id= $slice['slice_id']; - $slice_name= $slice['name']; - $slice_expires= date( "M j, Y", $slice['expires'] ); - $peer_id = $slice['peer_id']; - - $extraclass=""; - if ( $peer_id ) - $extraclass="plc-foreign"; - - echo "\n"; - - } - - echo "
Slice list
Slice NameUsersExpiration
$slice_name"; - - if( !empty( $slice['person_ids'] ) ) { - foreach( $slice['person_ids'] as $person_id ) { - $person = $persons[$person_id]; - $id= $person['person_id']; - $email= $person['email']; - echo "$email
\n"; - } - } else { - echo "None"; - } - - echo "
$slice_expires
\n"; - - } - } - - - echo "\n"; - - echo "\n"; - -} -// if nothing else then show slice info -else { - $slice_id= intval( $_GET['id'] ); - - // GetSlices API call - $slices= $api->GetSlices( array( $slice_id ) ); - - if( empty( $slices ) ) - plc_redirect(l_slices()); - - // pull all slice info to vars - $instantiation= $slice['instantiation']; - $name= $slice['name']; - $url= $slice['url']; - $expires= date( "M j, Y", $slice['expires'] ); - $site_id= $slice['site_id']; - $description= $slice['description']; - $max_nodes= $slice['max_nodes']; - $node_ids=$slice['node_ids']; - $person_ids=$slice['node_ids']; - - // get peer id - $peer_id= $slice['peer_id']; - - $person_ids= $slice['person_ids']; - $node_ids= $slice['node_ids']; - $slice_tag_ids= $slice['slice_tag_ids']; - - - // node info -// looks unused -// if( !empty( $node_ids ) ) -// $nodes= $api->GetNodes( $node_ids, array( "node_id", "hostname" ) ); - - // site info - $site_info= $api->GetSites( array( $site_id ), array( "site_id", "name", "person_ids" ) ); - - // gets all persons from site_id - // person info - if( !empty( $person_ids ) ) - $persons= $api->GetPersons( $site_info[0]['person_ids'] , array( "person_id", "role_ids", "first_name", "last_name", "email" ) ); - - if( $persons ) { - // gets site contacts pis stores in dict - foreach( $persons as $person ) - if( in_array( "20", $person['role_ids'] ) ) { - $pis[]= array( "email" => $person['email'], "first_name" => $person['first_name'], "last_name" => $person['last_name'], "person_id" => $person['person_id'] ); - - } - if ($pis) { - sort_persons( $pis ); - } - } - - // slice tag info - if( !empty( $slice_tag_ids ) ) - $slice_attibs= $api->GetSliceTags( $slice_tag_ids, - array( "slice_tag_id", "tag_type_id", "value", "description", "min_role_id", "node_id" ) ); - - // gets tag type info and combines it to form all tag info array - if( $slice_attibs ) { - foreach( $slice_attibs as $slice_attib ) { - $tag_type= $api->GetTagTypes( array( $slice_attib['tag_type_id'] ), - array( "tag_type_id", "tagname", "description" ) ); - - $tags[]= array( "slice_tag_id" => $slice_attib['slice_tag_id'], - "tag_type_id" => $slice_attib['tag_type_id'], - "tagname" => $tag_type[0]['tagname'], - "value" => $slice_attib['value'], - "description" => $slice_attib['description'], - "min_role_id" => $slice_attib['min_role_id'], - "node_id" => $slice_attib['node_id'] ); - } - - } - - drupal_set_title("Slice details for " . $name); - // start form - - if( $peer_id ) { - echo "

\n"; - } - - // basic slice menu - if( ! $peer_id ) { - - $actions= array( ''=>'Choose Action' ); - - if( in_array( 10, $_roles ) - || ( in_array( 20, $_roles ) && in_array( $site_id, $_person['site_ids'] ) ) - || in_array( $slice_id, $_person['slice_ids'] ) ) { - $actions['renew']= "Renew $name"; - $actions['nodes']= "Manage Nodes"; - } - if ( in_array( 10, $_roles ) - || ( in_array( 20, $_roles ) && in_array( $site_id, $_person['site_ids'] ) ) ) { - $actions['users']= "Manage Users"; - $actions['delete']= "Delete $name"; - } - - echo "
\n"; - if (in_array( 10, $_roles )) { - echo plc_event_button("slices","slice",$slice_id); - echo ""; - } - echo plc_comon_button("slice_id",$slice_id); - echo "\n"; - - echo "
\n"; - echo "\n"; - - echo "
\n"; - echo "
\n"; - - echo "
\n"; - } - - echo "\n - \n - \n - \n"; - - if( gmmktime() > $slice['expires'] ) { - $class1= ' style="color:red;"'; - $msg1= '(slice is expired)'; - } - echo "Expiration: $expires   $msg1\n"; - echo "\n"; - echo "\n"; - $href="'/db/nodes/index.php?slice_id=" . $slice_id . "'"; - printf ("\n",$href,$href,count($node_ids)); - $href="'/db/persons/index.php?slice_id=" . $slice_id . "'"; - printf ("\n",$href,$href,count($person_ids)); - echo "
Slice Name: $name
Description: $description
URL: $url
Instantiation: "; - - echo "
Site: ". $site_info[0]['name'] ."
# NodesTotal %d nodes
# UsersTotal %d users
\n"; - - if ( (!$class1) && in_array( $slice_id, $_person['slice_ids'] ) && (! $peer_id) ) - echo "

Update Information\n"; - - echo "


\n"; - - - // slice tags - if( $tags ) { - - // builds 2 arrays, one for tags, one for slivers - foreach( $tags as $tag ) { - if( empty( $tag['node_id'] ) ) { - $slice_tag[]= $tag; - } - else { - $sliver_tag[]= $tag; - $sliver_nodes[]= $tag['node_id']; - } - } - } - - // Get node info for those slivers - $sliver_node_info= $api->GetNodes( $sliver_nodes, array( "node_id", "hostname" ) ); - - if( $sliver_node_info ) { - foreach( $sliver_node_info as $sliv_node ) { - $new_sliver_node_info[$sliv_node['node_id']]= $sliv_node; - } - } - - if( $peer_id ) { - echo "
\n"; - } - - // slice tags - $is_admin=in_array( 10, $_roles ); - $is_in_slice=in_array( $slice_id, $_person['slice_ids'] ); - $is_pi=in_array( 20, $_roles ); - if( $slice_tag ) { - echo ""; - echo ""; - if( $is_admin ) - echo ""; - echo ""; - echo "\n"; - - foreach( $tags as $tag ) { - // ignore sliver tags at this stage - if( empty( $tag['node_id'] ) ) { - echo(""); - if( $is_admin ) { - printf(""; - } - if( $is_admin || ($is_pi && $is_in_slice) ) { - printf ("", - $tag['slice_tag_id'],$tag['tagname']); - } else { - printf("",$tag['tagname']); - } - printf("", - $tag['value'],$tag['description']); - echo ""; - } - } - - - echo "
Slice Tags
TagValueDescription
"); - sprintf($label,"\\n [ %s = %s] \\n from %s",$tag['tagname'],$tag['value'],$name); - // xxx this is deprecated - echo plc_delete_link_button ('tag_action.php?rem_id=' . $tag['slice_tag_id'], - $label); - echo "%s%s%s%s
\n"; - - } - if( $is_admin || ($is_pi && $is_in_slice) ) - echo "Add a Slice Tag\n"; - - - - // sliver tags - if( $sliver_tag ) { - echo ""; - echo ""; - if( $is_admin ) - echo ""; - echo ""; - echo "\n"; - - foreach( $tags as $tag ) { - $nodename=$new_sliver_node_info[$tag['node_id']]['hostname']; - // consider only sliver tags at this stage - if( !empty( $tag['node_id'] ) ) { - echo(""); - if( $is_admin ) { - echo(""; - } - if( $is_admin ) { - printf("",$tag['slice_tag_id'],$tag['tagname']); - } else { - printf("",$tag['tagname']); - } - printf("", - $tag['value'],$tag['description'],$tag['node_id'],$nodename); - - echo ""; - } - } - - echo "
Sliver Tags
TagValueDescriptionNode
"); - $label=sprintf("\\n [ %s = %s ] \\n from %s \\n on node %s", - $tag['tagname'],$tag['value'],$name,$nodename); - echo plc_delete_link_label('/db/nodes/sliver_action.php?rem_id=' . $tag['slice_tag_id'], - $label); - echo "%s%s%s%s%s
\n"; - - } - - echo "

\n"; - - if( $pis && !$peer_id ) { - // site contacts - echo "
Contacts
\n"; - - $pi_rows= count( $pis ); - $tech_rows= count( $techs ); - $table_row= 0; - - echo ""; - if( $pis ) { - echo "\n"; - - foreach( $pis as $pi ) { - if( $table_row != 0 ) - echo ""; - printf("\n", - $pi['person_id'],$pi['first_name'],$pi['last_name'],$pi['email'],$pi['email']); - $table_row++; - } - - } - - echo "
PI's:  
%s %s%s
\n

\n"; - - } - - - echo "

Back to slice list

\n"; - } - -// Print footer -include 'plc_footer.php'; +if ($_GET['id']) require ('slice.php') ; +else require ('slices.php'); ?> diff --git a/planetlab/slices/renew_slice.php b/planetlab/slices/renew_slice.php deleted file mode 100644 index a106b17..0000000 --- a/planetlab/slices/renew_slice.php +++ /dev/null @@ -1,171 +0,0 @@ -person; -$_roles= $_person['role_ids']; - - -// Constants -$week= 7 * 24 * 60 * 60; // seconds -$max_renewal_length= 8; // weeks from today -$max_expiration= mktime() + ($max_renewal_length * $week); // seconds since epoch -$max_expiration_date= gmstrftime("%A %b-%d-%y %T %Z", $max_expiration); - -// if submitted validate input -if( $_POST['submitted'] ) { - // get post vars - $expire_len= $_POST['expire_len']; - $expires= $_POST['expires']; - $slice_id= intval( $_POST['id'] ); - - // create empty error array - $error= array( ); - - // check input - - $url= $_POST['url']; - if( $url == '' || empty( $url ) ) - $error['url']= "Provide a link to a project website."; - - $description= htmlspecialchars( $_POST['description'] ); - if ( $description == '' || empty( $description ) ) - $error['description']= "Provide a short description of the slice."; - - // if no errors update slice info - if( empty( $error ) ) { - // set new expiration - - $expires+= ( $expire_len * $week ); - - // make slice field array - $slice_fields= array( "url" => $url, "description" => $description, "expires" => $expires ); - - // Update it! - $api->UpdateSlice( $slice_id, $slice_fields ); - - plc_redirect( l_slice($slice_id)); - - } - -} - -// if no id is set redirect back to slice index -if( !$_POST['id'] && !$_GET['id'] ) { - plc_redirect( l_slices()); - } - -// Print header -require_once 'plc_drupal.php'; -drupal_set_title('Slice Renewal'); -include 'plc_header.php'; - - - - -// get id -if( $_GET['id'] ) - $slice_id= intval( $_GET['id'] ); -if( $_POST['id'] ) - $slice_id= intval( $_POST['id'] ); - -// get slice info -$slice_info= $api->GetSlices( array( $slice_id ), array( "expires", "name", "site_id", "description", "url" ) ); - -echo "

Slice ". $slice_info[0]['name'] ." Renewal

\n"; - -// get site info -if( !empty( $slice_info[0]['site_id'] ) ) { - // get sliver/slice site info - $site_info= $api->GetSites( array( $slice_info[0]['site_id'] ), array( "max_slivers", "max_slices" ) ); - - // do not allow renew if max_slices are 0 - if( $site_info[0]['max_slices'] <= 0 ) { - $support= ''; - $site_id= $slice_info[0]['site_id']; - - echo "

Slice creation and renewal have been temporarily disabled for your site. This may have occurred because your site's nodes have been down or unreachable for several weeks, and multiple attempts to contact your site's PI(s) and Technical Contact(s) have all failed. If so, contact your site's PI(s) and Technical Contact(s) and ask them to bring up your site's nodes. If you believe that your site's nodes are up and reachable. Visit your site's Site Details page to find out more about your site's nodes, and how to contact your site's PI(s) and Technical Contact(s).

"; - - } - // else start renewal form - else { - // Calculate possible extension lengths - $renewal_lengths = array(); - foreach ( array( 1 => "One more week", 2 => "Two more weeks", 4 => "One more month" ) as $weeks => $text ) { - if ( ( $slice_info[0]['expires'] + ( $weeks * $week ) ) < $max_expiration ) { - $renewal_lengths[$weeks]= "$text (". gmstrftime( "%A %b-%d-%y %T %Z", $slice_info[0]['expires'] + ( $weeks * $week ) ) .")"; - } - } - - - if ( empty( $renewal_lengths ) ) { - echo "Slice cannot be renewed any further into the future, try again closer to expiration date. Go back to ". $slice_info[0]['name'] .".\n"; - } - else { - // clean vars - $expiration_date = gmstrftime( "%A %b-%d-%y %T %Z", $slice_info[0]['expires'] ); - - // display form - echo "
\n"; - echo "\n"; - - echo "

You must provide a short description as well as a link to a project website before renewing it. Do not provide bogus information; if a complaint is lodged against your slice and PlanetLab Operations is unable to determine what the normal behavior of your slice is, your slice may be deleted to resolve the complaint.

\n"; - - echo "

NOTE: Slices cannot be renewed beyond $max_renewal_length weeks of today ($max_expiration_date).

\n"; - - echo "\n"; - - echo "\n"; - - if( $error['url'] ) - $url_style= " style='border: 1px solid red;'"; - echo "URL: ". $error['url'] ."\n"; - - if( $error['description'] ) - $desc_style= " style='border: 1px solid red;'"; - echo "Description: ". $error['description'] ."\n"; - - echo "\n"; - - echo "\n\n
Name:". $slice_info[0]['name'] ."
Expiration Date: $expiration_date
Renewal Length:
\n"; - - } - - } - -} -else - echo "No data for this slice ID. Go back to slices.\n"; - - - - - - - - - -// Print footer -include 'plc_footer.php'; - -?> diff --git a/planetlab/slices/slice.php b/planetlab/slices/slice.php new file mode 100644 index 0000000..4e23205 --- /dev/null +++ b/planetlab/slices/slice.php @@ -0,0 +1,522 @@ +"Enter this zone if you wish to renew your slice", + 'start-visible'=>true)); + $toggle->start(); + + // xxx message could take roles into account + if ($site['max_slices']<=0) { + $message= <<< EOF +

Slice creation and renewal have been temporarily disabled for your +site. This may have occurred because your site's nodes have been down +or unreachable for several weeks, and multiple attempts to contact +your site's PI(s) and Technical Contact(s) have all failed. If so, +contact your site's PI(s) and Technical Contact(s) and ask them to +bring up your site's nodes. Please visit your site details page to find +out more about your site's nodes, and how to contact your site's PI(s) +and Technical Contact(s).

+EOF; + echo $message; + + } else { + // xxx this is a rough cut and paste from the former UI + // Showing a datepicker view could be considered as well with some extra work + // Calculate possible extension lengths + $renewal_lengths = array(); + foreach ( array ( 1 => "One more week", + 2 => "Two more weeks", + 4 => "One more month" ) as $weeks => $text ) { + if (($slice [ 'expires' ] + ($weeks * $week)) < $max_expiration) { + $renewal_lengths [ $weeks ] = "$text (" . + gmstrftime( "%A %b-%d-%y %T %Z", $slice [ 'expires' ] + ( $weeks * $week ) ) + . ")"; + } + } + + if ( empty( $renewal_lengths ) ) { + plc_warning("Slice cannot be renewed any further into the future, try again closer to expiration date."); + } else { + // clean vars + $expiration_date = gmstrftime( "%A %b-%d-%y %T %Z", $slice [ 'expires' ] ); + echo '

area under construction '; + + // // display form + // echo "\n"; + // echo "\n"; + +// $message = <<< EOF +//

You must provide a short description as well as a link to a project website before renewing it. +// Do not provide bogus information; if a complaint is lodged against your slice +// and PlanetLab Operations is unable to determine what the normal behavior of your slice is, +// your slice may be deleted to resolve the complaint.

+// EOF; +// echo $message; +// +// echo "

NOTE: +// Slices cannot be renewed beyond $max_renewal_length weeks of today ($max_expiration_date).

\n"; +// +// echo "\n"; +// +// echo "\n"; +// +// if( $error['url'] ) +// $url_style= " style='border: 1px solid red;'"; +// echo "URL: ". $error['url'] ."\n"; +// +// if( $error['description'] ) +// $desc_style= " style='border: 1px solid red;'"; +// echo "Description: ". $error['description'] ."\n"; +// +// echo "\n"; +// +// echo "\n\n
Name:". $slice['name'] ."
Expiration Date: $expiration_date
Renewal Length:
\n"; +// +// } +// + } + + $toggle->end(); +} + +//////////////////// +// Get all columns as we focus on only one entry +$slices= $api->GetSlices( array($slice_id)); + +if (empty($slices)) { + drupal_set_message ("Slice " . $slice_id . " not found"); + return; + } + +$slice=$slices[0]; + +// pull all node info to vars +$name= $slice['name']; +$expires = date( "d/m/Y", $slice['expires'] ); +$site_id= $slice['site_id']; + +//$node_ids=$slice['node_ids']; +$person_ids=$slice['person_ids']; +//$slice_tag_ids= $slice['slice_tag_ids']; + +// get peers +$peer_id= $slice['peer_id']; +$peers=new Peers ($api); + +// gets site info +$sites= $api->GetSites( array( $site_id ) ); +$site=$sites[0]; +$site_name= $site['name']; +$max_slices = $site['max_slices']; + +// get all persons info +if (!empty($person_ids)) + $persons=$api->GetPersons($person_ids,array('email','enabled')); + +////////// +drupal_set_title("Details for slice " . $name); +$local_peer= ! $peer_id; + +$am_in_slice = in_array(plc_my_person_id(),$person_ids); + +$privileges = (plc_is_admin() || $am_in_slice); + +$tabs=array(); +$tabs [] = tab_nodes_slice($slice_id); +$tabs [] = tab_site($site_id); + +// are these the right privileges for deletion ? +if ($privileges) { + $tabs ['Delete']= array('url'=>l_actions(), + 'method'=>'post', + 'values'=>array('action'=>'delete-slice','slice_id'=>$slice_id), + 'bubble'=>"Delete slice $name", + 'confirm'=>'Are you sure to delete $name'); + + $tabs["Events"]=array_merge(tablook_event(), + array('url'=>l_event("Slice","slice",$slice_id), + 'bubble'=>"Events for slice $name")); + $tabs["Comon"]=array_merge(tablook_comon(), + array('url'=>l_comon("slice_id",$slice_id), + 'bubble'=>"Comon page about slice $name")); +} + +plekit_linetabs($tabs); + +//////////////////////////////////////// +$peers->block_start($peer_id); + +$toggle = new PlekitToggle ('slice',"Details", + array('trigger-bubble'=>'Display and modify details for that slice')); +$toggle->start(); + +$details=new PlekitDetails($privileges); +$details->form_start(l_actions(),array('action'=>'update-slice','slice_id'=>$slice_id)); + +$details->start(); +if (! $local_peer) { + $details->th_td("Peer",$peers->peer_link($peer_id)); + $details->space(); + } + + +$details->th_td('Name',$slice['name']); +$details->th_td('Description',$slice['description'],'description', + array('input_type'=>'textarea', + 'width'=>50,'height'=>5)); +$details->th_td('URL',$slice['url'],'url',array('width'=>50)); +$details->th_td('Expires',$expires); +$details->th_td('Instantiation',$slice['instantiation']); +$details->th_td('Site',l_site_obj($site)); +$details->end(); + +$details->form_end(); +$toggle->end(); + +renew_area ($slice,$site); + +$peers->block_end($peer_id); + +//////////////////// users + +//////////////////// nodes + +//////////////////// tags + +// Print footer +include 'plc_footer.php'; + +return; + +?> + + + + + + + + + + + + + + + // gets all persons from site_id + // person info + if( !empty( $person_ids ) ) + $persons= $api->GetPersons( $site_info[0]['person_ids'] , array( "person_id", "role_ids", "first_name", "last_name", "email" ) ); + + if( $persons ) { + // gets site contacts pis stores in dict + foreach( $persons as $person ) + if( in_array( "20", $person['role_ids'] ) ) { + $pis[]= array( "email" => $person['email'], "first_name" => $person['first_name'], "last_name" => $person['last_name'], "person_id" => $person['person_id'] ); + + } + if ($pis) { + sort_persons( $pis ); + } + } + + // slice tag info + if( !empty( $slice_tag_ids ) ) + $slice_attibs= $api->GetSliceTags( $slice_tag_ids, + array( "slice_tag_id", "tag_type_id", "value", "description", "min_role_id", "node_id" ) ); + + // gets tag type info and combines it to form all tag info array + if( $slice_attibs ) { + foreach( $slice_attibs as $slice_attib ) { + $tag_type= $api->GetTagTypes( array( $slice_attib['tag_type_id'] ), + array( "tag_type_id", "tagname", "description" ) ); + + $tags[]= array( "slice_tag_id" => $slice_attib['slice_tag_id'], + "tag_type_id" => $slice_attib['tag_type_id'], + "tagname" => $tag_type[0]['tagname'], + "value" => $slice_attib['value'], + "description" => $slice_attib['description'], + "min_role_id" => $slice_attib['min_role_id'], + "node_id" => $slice_attib['node_id'] ); + } + + } + + drupal_set_title("Slice details for " . $name); + // start form + + if( $peer_id ) { + echo "
\n"; + } + + // basic slice menu + if( ! $peer_id ) { + + $actions= array( ''=>'Choose Action' ); + + if( in_array( 10, $_roles ) + || ( in_array( 20, $_roles ) && in_array( $site_id, $_person['site_ids'] ) ) + || in_array( $slice_id, $_person['slice_ids'] ) ) { + $actions['renew']= "Renew $name"; + $actions['nodes']= "Manage Nodes"; + } + if ( in_array( 10, $_roles ) + || ( in_array( 20, $_roles ) && in_array( $site_id, $_person['site_ids'] ) ) ) { + $actions['users']= "Manage Users"; + $actions['delete']= "Delete $name"; + } + + echo "
\n"; + if (in_array( 10, $_roles )) { + echo plc_event_button("slices","slice",$slice_id); + echo ""; + } + echo plc_comon_button("slice_id",$slice_id); + echo "\n"; + + echo "\n"; + echo "\n"; + + echo "
\n"; + echo "\n"; + + echo "
\n"; + } + + echo "\n + \n + \n + \n"; + + if( gmmktime() > $slice['expires'] ) { + $class1= ' style="color:red;"'; + $msg1= '(slice is expired)'; + } + echo "Expiration: $expires   $msg1\n"; + echo "\n"; + echo "\n"; + $href="'/db/nodes/index.php?slice_id=" . $slice_id . "'"; + printf ("\n",$href,$href,count($node_ids)); + $href="'/db/persons/index.php?slice_id=" . $slice_id . "'"; + printf ("\n",$href,$href,count($person_ids)); + echo "
Slice Name: $name
Description: $description
URL: $url
Instantiation: "; + + echo "
Site: ". $site_info[0]['name'] ."
# NodesTotal %d nodes
# UsersTotal %d users
\n"; + + if ( (!$class1) && in_array( $slice_id, $_person['slice_ids'] ) && (! $peer_id) ) + echo "

Update Information\n"; + + echo "


\n"; + + + // slice tags + if( $tags ) { + + // builds 2 arrays, one for tags, one for slivers + foreach( $tags as $tag ) { + if( empty( $tag['node_id'] ) ) { + $slice_tag[]= $tag; + } + else { + $sliver_tag[]= $tag; + $sliver_nodes[]= $tag['node_id']; + } + } + } + + // Get node info for those slivers + $sliver_node_info= $api->GetNodes( $sliver_nodes, array( "node_id", "hostname" ) ); + + if( $sliver_node_info ) { + foreach( $sliver_node_info as $sliv_node ) { + $new_sliver_node_info[$sliv_node['node_id']]= $sliv_node; + } + } + + if( $peer_id ) { + echo "
\n"; + } + + // slice tags + $is_admin=in_array( 10, $_roles ); + $is_in_slice=in_array( $slice_id, $_person['slice_ids'] ); + $is_pi=in_array( 20, $_roles ); + if( $slice_tag ) { + echo ""; + echo ""; + if( $is_admin ) + echo ""; + echo ""; + echo "\n"; + + foreach( $tags as $tag ) { + // ignore sliver tags at this stage + if( empty( $tag['node_id'] ) ) { + echo(""); + if( $is_admin ) { + printf(""; + } + if( $is_admin || ($is_pi && $is_in_slice) ) { + printf ("", + $tag['slice_tag_id'],$tag['tagname']); + } else { + printf("",$tag['tagname']); + } + printf("", + $tag['value'],$tag['description']); + echo ""; + } + } + + + echo "
Slice Tags
TagValueDescription
"); + sprintf($label,"\\n [ %s = %s] \\n from %s",$tag['tagname'],$tag['value'],$name); + // xxx this is deprecated + echo plc_delete_link_button ('tag_action.php?rem_id=' . $tag['slice_tag_id'], + $label); + echo "%s%s%s%s
\n"; + + } + if( $is_admin || ($is_pi && $is_in_slice) ) + echo "Add a Slice Tag\n"; + + + + // sliver tags + if( $sliver_tag ) { + echo ""; + echo ""; + if( $is_admin ) + echo ""; + echo ""; + echo "\n"; + + foreach( $tags as $tag ) { + $nodename=$new_sliver_node_info[$tag['node_id']]['hostname']; + // consider only sliver tags at this stage + if( !empty( $tag['node_id'] ) ) { + echo(""); + if( $is_admin ) { + echo(""; + } + if( $is_admin ) { + printf("",$tag['slice_tag_id'],$tag['tagname']); + } else { + printf("",$tag['tagname']); + } + printf("", + $tag['value'],$tag['description'],$tag['node_id'],$nodename); + + echo ""; + } + } + + echo "
Sliver Tags
TagValueDescriptionNode
"); + $label=sprintf("\\n [ %s = %s ] \\n from %s \\n on node %s", + $tag['tagname'],$tag['value'],$name,$nodename); + echo plc_delete_link_label('/db/nodes/sliver_action.php?rem_id=' . $tag['slice_tag_id'], + $label); + echo "%s%s%s%s%s
\n"; + + } + + echo "

\n"; + + if( $pis && !$peer_id ) { + // site contacts + echo "
Contacts
\n"; + + $pi_rows= count( $pis ); + $tech_rows= count( $techs ); + $table_row= 0; + + echo ""; + if( $pis ) { + echo "\n"; + + foreach( $pis as $pi ) { + if( $table_row != 0 ) + echo ""; + printf("\n", + $pi['person_id'],$pi['first_name'],$pi['last_name'],$pi['email'],$pi['email']); + $table_row++; + } + + } + + echo "
PI's:  
%s %s%s
\n

\n"; + + } + + + echo "

Back to slice list\n"; + } + diff --git a/planetlab/slices/slices.php b/planetlab/slices/slices.php new file mode 100644 index 0000000..28cba3b --- /dev/null +++ b/planetlab/slices/slices.php @@ -0,0 +1,139 @@ +filter()); +$title .= ' - ' . $peerscope->label(); + + +if ($site_id) { + $sites=$api->GetSites(array($site_id)); + $site=$sites[0]; + $name=$site['name']; + $login_base=$site['login_base']; + $title .= t_site($site); + $tabs []= tab_site($site); + $slice_filter['site_id']=array($site_id); +} + +if ($person_id) { + $persons=$api->GetPersons(array('person_id'=>$person_id,array('email','person_id','slice_ids'))); + $person=$persons[0]; + $title .= t_person($person); + $tabs .= tab_person($person); + $slice_filter['slice_id']=$person['slice_ids']; + } + +// go +$slices=$api->GetSlices($slice_filter,$slice_columns); + +// build person_hash +$person_ids=array(); +if ($slices) foreach ($slices as $slice) { + $person_ids = array_merge ($person_ids,$slice['person_ids']); +} +$persons=$api->GetPersons($person_ids,array('person_id','email')); +global $person_hash; +$person_hash=array(); +if ($persons) foreach ($persons as $person) $person_hash[$person['person_id']]=$person; + +function email_link_from_hash($person_id) { + global $person_hash; + return l_person_obj($person_hash[$person_id]); +} + +// -------------------- +drupal_set_title($title); + +plekit_linetabs($tabs); + +if ( ! $slices ) { + drupal_set_message ('No slice found'); + return; + } + +$headers = array ("Peer"=>"string", + "Name"=>"string", + "Users"=>"string", + "N"=>"int", + "Exp. d/m/y"=>"date-dmy"); + +# initial sort on hostnames +$table=new PlekitTable ("slices",$headers,2, + array('search_width'=>20)); +$table->start(); + +$peers = new Peers ($api); +// write rows +foreach ($slices as $slice) { + $peer_id=$slice['peer_id']; + $shortname = $peers->shortname($peer_id); + $users=plc_vertical_table (array_map ("email_link_from_hash",$slice['person_ids'])); + $expires= date( "d/m/Y", $slice['expires'] ); + + $table->row_start(); + $table->cell ($peers->link($peer_id,$shortname)); + $table->cell (l_slice_obj($slice)); + $table->cell ($users); + $table->cell (href(l_nodes_slice($slice['slice_id']),count($slice['node_ids']))); + $table->cell ($expires); + $table->row_end(); +} + +$table->end(); + +//plekit_linetabs ($tabs,"bottom"); + +// Print footer +include 'plc_footer.php'; + +?> diff --git a/planetlab/tags/nodegroup.php b/planetlab/tags/nodegroup.php index 86b7e6d..cb97270 100644 --- a/planetlab/tags/nodegroup.php +++ b/planetlab/tags/nodegroup.php @@ -62,7 +62,7 @@ $details->end(); // xxx : add & delete buttons would make sense here too $toggle=new PlekitToggle('nodes',"Nodes"); -$toggle=>start(); +$toggle->start(); $headers["Hostname"]="string"; diff --git a/plekit/details/details.css b/plekit/details/details.css index d7808a2..bbedc8f 100644 --- a/plekit/details/details.css +++ b/plekit/details/details.css @@ -8,5 +8,5 @@ table.plc_details { table.plc_details>tbody>tr>th { text-align: right; - font: bold 14px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; + font: 12px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; } diff --git a/plekit/php/table.php b/plekit/php/table.php index 7adcb5f..a475bee 100644 --- a/plekit/php/table.php +++ b/plekit/php/table.php @@ -103,14 +103,15 @@ EOF; print ""; foreach ($this->headers as $label => $type) { - if ($type == "none" ) { - $class=""; - } else { - if ($type == "string") $type=""; - if ($type == "int") $type=""; - if ($type == "float") $type=""; - $class="sortable"; - if ( ! empty($type)) $class .= "-sort" . $type; + switch ($type) { + case "none" : + $class=""; break; + case "string": case "int": case "float": + $class="sortable"; break; + case ( strpos($type,"date-") == 0): + $class="sortable-" . $type; break; + default: + $class="sortable-sort" . $type; break; } printf ('%s',$class,$label); } @@ -144,7 +145,7 @@ EOF; onkeyup='plekit_pagesize_set("$this->table_id","$pagesize_text_id", $this->pagesize);' size='3' maxlength='3' /> - reset visible size EOF; @@ -159,16 +160,16 @@ EOF; $search_and_id = $this->table_id . "_search_and"; $result = <<< EOF -