From: Thierry Parmentelat Date: Mon, 6 Apr 2009 08:39:20 +0000 (+0000) Subject: consitency X-Git-Tag: PLEWWW-4.3-3~3 X-Git-Url: http://git.onelab.eu/?p=plewww.git;a=commitdiff_plain;h=020d87fb03fa696009143b9158e2d9db65880f23 consitency --- diff --git a/planetlab/includes/plc_functions.php b/planetlab/includes/plc_functions.php index 8309f34..34f9f3e 100644 --- a/planetlab/includes/plc_functions.php +++ b/planetlab/includes/plc_functions.php @@ -90,6 +90,7 @@ function l_persons_peer ($peer_id) { return "/db/persons/index.php?peerscope=$pe function l_person ($person_id) { return "/db/persons/index.php?id=$person_id"; } function l_person_t ($person_id,$text) { return href (l_person($person_id),$text); } function l_persons_site ($site_id) { return "/db/persons/index.php?site_id=$site_id"; } +function l_persons_slice ($slice_id) { return "/db/persons/index.php?slice_id=$slice_id"; } function l_person_obj ($person) { return l_person_t($person['person_id'],$person['email']); } function l_tags () { return "/db/tags/index.php"; } diff --git a/planetlab/nodes/node.php b/planetlab/nodes/node.php index e5ce205..6825f16 100644 --- a/planetlab/nodes/node.php +++ b/planetlab/nodes/node.php @@ -328,7 +328,7 @@ if ( $local_peer ) { //////////////////////////////////////////////////////////// interfaces if ( $local_peer ) { - $toggle=new PlekitToggle ('interfaces',count_english_warning($interfaces,'interfaces'), + $toggle=new PlekitToggle ('interfaces',count_english_warning($interfaces,'interface'), array('bubble'=>'Inspect and tune interfaces on that node', 'visible'=>get_arg('show_interfaces',false))); $toggle->start(); diff --git a/planetlab/nodes/nodes.php b/planetlab/nodes/nodes.php index 43b994f..fca8214 100644 --- a/planetlab/nodes/nodes.php +++ b/planetlab/nodes/nodes.php @@ -42,14 +42,14 @@ $node_filter=array(); // performs sanity check and summarize the result in a single column function node_status ($node) { - $messages=array(); - // do all this stuff on local nodes only - if ( ! $node['peer_id'] ) { - // check that the node has keys - if (count($node['interface_ids']) == 0) { - $messages [] = "No interface"; - } + if ( $node['peer_id'] ) + return "n/a"; + + $messages=array(); + // check that the node has interfaces + if (count($node['interface_ids']) == 0) { + $messages [] = "No interface"; } return plc_vertical_table($messages,'plc-warning'); } @@ -127,17 +127,18 @@ if ( ! $nodes ) { $nifty=new PlekitNifty ('','objects-list','big'); $nifty->start(); -$headers = array ("P"=>"string", - "Region"=>"string", - "Site"=>"string", - "State"=>"string", - "Hostname"=>"string", - "IP"=>"IPAddress", - "Type"=>"string", - "Arch"=>"string", - "S"=>'int', - "?"=>"string", - ); +$headers = array (); +$headers["P"]="string"; +$headers["R"]="string"; +$headers["Site"]="string"; +$headers["State"]="string"; +$headers["Hostname"]="string"; +$headers["Type"]="string"; +$headers["IP"]="IPAddress"; +$headers["A"]="string"; +$headers["S"]='int'; +if (plc_is_admin()) $headers["I"]="int"; +$headers["?"]="string"; # initial sort on hostnames $table=new PlekitTable ("nodes",$headers,4); @@ -151,7 +152,6 @@ foreach ($nodes as $node) { $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']; @@ -163,16 +163,21 @@ foreach ($nodes as $node) { $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 (l_interface_t($interface_id,$ip),array('only-if'=> !$peer_id)); + $table->cell ($node['arch'],array('only-if'=> !$peer_id)); $table->cell (count($node['slice_ids'])); + if (plc_is_admin()) $table->cell(l_node_t($node_id,$node_id)); $table->cell (node_status($node)); $table->row_end(); } -$notes=array("S = number of slivers"); +$notes=array(); +$notes []= "R = region"; +$notes []= "A = arch"; +$notes []= "S = number of slivers"; +if (plc_is_admin()) $notes []= "I = node_id"; $table->end(array('notes'=>$notes)); $nifty->end(); diff --git a/planetlab/persons/persons.php b/planetlab/persons/persons.php index 5282d7a..00b70bb 100644 --- a/planetlab/persons/persons.php +++ b/planetlab/persons/persons.php @@ -158,26 +158,28 @@ $peers=new Peers ($api); foreach ($persons as $person) { $person_id=$person['person_id']; $email=$person['email']; - $shortname = $peers->shortname($person['peer_id']); $site_id=$person['site_ids'][0]; $site=$site_hash[$site_id]; $login_base = $site['login_base']; $roles = plc_vertical_table ($person['roles']); + $peer_id=$person['peer_id']; $table->row_start(); - $table->cell($shortname); - $table->cell ($person['first_name']); - $table->cell ($person['last_name']); + $peers->cell($table,$peer_id); + $table->cell (href(l_person($person_id),$person['first_name'])); + $table->cell (href(l_person($person_id),$person['last_name'])); $table->cell(l_person_t($person_id,$email)); - $table->cell(l_site_t($site_id,$login_base)); - $table->cell($roles); + $table->cell(l_site_t($site_id,$login_base),array('only-if'=>!$peer_id)); + $table->cell($roles,array('only-if'=>!$peer_id)); $table->cell(count($person['slice_ids'])); $table->cell(person_status($person)); $table->row_end(); } -$notes=array("S = number of slices"); +$notes = array(); +$notes []= "R = roles"; +$notes []= "S = number of slices"; $table->end(array('notes'=>$notes)); $nifty->end(); diff --git a/planetlab/sites/sites.php b/planetlab/sites/sites.php index 752c248..3009824 100644 --- a/planetlab/sites/sites.php +++ b/planetlab/sites/sites.php @@ -36,13 +36,13 @@ $site_filter=array(); function site_status ($site) { + $class=($site['peer_id']) ? 'plc-foreign' : 'plc-warning'; + $messages=array(); if (empty ($site['node_ids'])) $messages [] = "No node"; - $class=($site['peer_id']) ? 'plc-foreign' : 'plc-warning'; - // do all this stuff on local sites only if ( ! $site['peer_id'] ) { @@ -120,6 +120,7 @@ if (plc_is_admin()) { $headers['N']="int"; $headers['U']="int"; $headers['S']="int"; + $headers['I']='int'; $headers['?']="string"; } @@ -127,21 +128,31 @@ $table=new PlekitTable("sites",$headers,2); $table->start(); if ($sites) foreach ($sites as $site) { - $shortname = $peers->shortname($site['peer_id']); + $peer_id=$site['peer_id']; + $site_id=$site['site_id']; + $login_base=$site['login_base']; $table->row_start(); - $table->cell($shortname); - $table->cell (l_site_t($site['site_id'],htmlentities($site['name']))); - $table->cell ($site['login_base']); + $peers->cell($table,$peer_id); + $table->cell (l_site_t($site_id,htmlentities($site['name']))); + $table->cell (l_site_t($site_id,$login_base)); $table->cell (htmlentities($site['abbreviated_name'])); if (plc_is_admin()) { - $table->cell(count($site['node_ids'])); - $table->cell(count($site['person_ids'])); - $table->cell(count($site['slice_ids'])); + $table->cell(href(l_nodes_site($site_id),count($site['node_ids']))); + $table->cell(href(l_persons_site($site_id),count($site['person_ids']))); + $table->cell(href(l_slices_site($site_id),count($site['slice_ids']))); + $table->cell(l_site_t($site_id,$site_id)); $table->cell(site_status($site)); } $table->row_end(); } -$notes=array("N = number of sites / U = number of users / S = number of slices"); +$notes=array(); +if (plc_is_admin()) { + $notes []= "N = number of sites"; + $notes []= "U = number of users"; + $notes []= "S = number of slices"; + $notes []= "I = site_id"; + $notes []= "? = status"; + } $table->end(array('notes'=>$notes)); $nifty->end(); diff --git a/planetlab/slices/slice.php b/planetlab/slices/slice.php index de6098e..61ee99e 100644 --- a/planetlab/slices/slice.php +++ b/planetlab/slices/slice.php @@ -129,7 +129,7 @@ EOF; $selectors = array(); foreach ( array ( 1 => "One more week", 2 => "Two more weeks", - 3 => "Two more weeks", + 3 => "Three more weeks", 4 => "One more month" ) as $weeks => $text ) { $candidate_exp = $current_exp + $weeks*$WEEK; if ( $candidate_exp < $max_exp) { diff --git a/planetlab/slices/slices.php b/planetlab/slices/slices.php index 974b95b..ce870df 100644 --- a/planetlab/slices/slices.php +++ b/planetlab/slices/slices.php @@ -119,22 +119,24 @@ $table->start(); $peers = new Peers ($api); // write rows foreach ($slices as $slice) { + $slice_id=$slice['slice_id']; $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)); + $peers->cell($table,$peer_id); $table->cell (l_slice_obj($slice)); $table->cell ($users); - $table->cell(count($slice['person_ids'])); - $table->cell (href(l_nodes_slice($slice['slice_id']),count($slice['node_ids']))); + $table->cell(href(l_persons_slice($slice_id),count($slice['person_ids']))); + $table->cell (href(l_nodes_slice($slice_id),count($slice['node_ids']))); $table->cell ($expires); $table->row_end(); } -$notes=array("U = number of users / N = number of nodes"); +$notes=array(); +$notes []= "U = number of users"; +$notes []= "N = number of nodes"; $table->end(array('notes'=>$notes)); $nifty->end(); diff --git a/plekit/php/table.php b/plekit/php/table.php index c913127..e2b24c4 100644 --- a/plekit/php/table.php +++ b/plekit/php/table.php @@ -233,12 +233,15 @@ EOF; //////////////////// // supported options: + // (*) only-if : if set and false, then print 'n/a' instead of (presumably void) $text // (*) class // (*) columns // (*) hfill // (*) align public function cell ($text,$options=NULL) { print $this->cell_html ($text,$options); } public function cell_html ($text,$options=NULL) { + if (isset ($options['only-if']) && ! $options['only-if'] ) + $text="n/a"; $html=""; $html .= "