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"; }
//////////////////////////////////////////////////////////// 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();
// 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');
}
$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);
$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'];
$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();
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();
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'] ) {
$headers['N']="int";
$headers['U']="int";
$headers['S']="int";
+ $headers['I']='int';
$headers['?']="string";
}
$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();
$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) {
$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();
////////////////////
// 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 .= "<td";
$option=$options['class']; if ($option) $html .= " class='$option'";