- $node_label = $nb_boot . " boot / " . count($nodes) . " total";
- $details->th_td("# Nodes", href(l_nodes_site($site_id),$node_label));
- function n_link ($n) { return l_node_t($n['node_id'],$n['hostname'] . " (" . $n['boot_state'] . ")");}
- $nodes_label= plc_vertical_table(array_map ("n_link",$nodes));
- $details->th_td ("Hostnames",$nodes_label);
- $button=new PlcFormButton (l_node_add(),"add_node","Add node","POST");
- $details->tr($button->html(),"right");
-
- // Users
- $details->space();
- $user_label = count($person_ids) . " Total / " .
- count ($pis) . " PIs / " .
- count ($techs) . " Techs";
- if ( (count ($pis) == 0) || (count ($techs) == 0) || (count($person_ids) >=50))
- $user_label = plc_warning_html ($user_label);
- $details->th_td ("# Users",href(l_persons_site($site_id),$user_label));
- function p_link ($p) { return l_person_t($p['person_id'],$p['email']); }
- // PIs
- $details->th_td("PI's",plc_vertical_table (array_map ("p_link",$pis)));
- // techs
- $details->th_td("Techs's",plc_vertical_table (array_map ("p_link",$techs)));
- if (count ($disabled_persons))
- $details->th_td("Disabled",plc_vertical_table (array_map ("p_link",$disabled_persons)));
-
- // Slices
- $details->space();
- // summary on slices
- $slice_label = count($slice_ids) . " running / " . $max_slices . " max";
+
+ $nodes_title = "Nodes : ";
+ $nodes_title .= count($nodes) . " total";
+ $nodes_title .= " / " . $nb_boot . " boot";
+ if ($nb_boot < 2 )
+ $nodes_title = plc_warning_html ($nodes_title);
+ $nodes_title .= href(l_nodes_site($site_id)," (See as nodes)");
+
+ $toggle=new PlekitToggle ('nodes',$nodes_title,
+ array('visible'=>get_arg('show_nodes')));
+ $toggle->start();
+
+ $headers=array();
+ $sort_column = '0';
+ if ($display_pcus) { $headers['PCU']='string'; $sort_column = '1' ; }
+ $headers['hostname']='string';
+ $headers['state']='string';
+
+ $table = new PlekitTable ('nodes',$headers,$sort_column,array('search_area'=>false,
+ 'notes_area'=>false,
+ 'pagesize_area'=>false));
+ // hash pcus on pcu_id
+ if ($display_pcus) {
+ global $pcu_hash;
+ $pcu_hash= array();
+ if ($pcus) foreach ($pcus as $pcu) $pcu_hash[$pcu['pcu_id']]=$pcu;
+ }
+ // search the pcu, return the string to display and mark the pcu as displayed
+ // function display_and_mark ($pcu_hash,$pcu_ids,$ports) {
+ function display_and_mark ($pcu_ids,$ports) {
+ global $pcu_hash;
+ if (empty($pcu_ids)) return plc_warning_html('None');
+ $pcu_id=$pcu_ids[0];
+ if (empty($ports)) return plc_error_html('???');
+ $port=$ports[0];
+ $pcu=$pcu_hash[$pcu_id];
+ $display= l_pcu_href($pcu_id, $pcu['hostname'] . ' : ' . $port);
+ $pcu_hash[$pcu_id]['displayed']=true;
+ return $display;
+ }
+
+ $table->start();
+ foreach ($nodes as $node) {
+ $table->row_start();
+ if ($display_pcus) {
+ // $table->cell(display_and_mark($pcu_hash,$node['pcu_ids'],$node['ports']));
+ $table->cell(display_and_mark($node['pcu_ids'],$node['ports']));
+ }
+ $table->cell (l_node_obj($node));
+ $table->cell ($node['boot_state']);
+ $table->row_end();
+ }
+ // show undisplayed PCU's if any
+ if ($display_pcus)
+ if ($pcu_hash) foreach ($pcu_hash as $id=>$pcu) {
+ if (!$pcu['displayed']) {
+ $table->row_start();
+ $table->cell($pcu['hostname']); $table->cell(''); $table->cell('');
+ $table->row_end();
+ }
+ }
+
+ $table->tfoot_start();
+ $table->row_start();
+ $button=new PlekitFormButton (l_node_add(),"node_add","Add node","POST");
+ $table->cell($button->html(),array('hfill'=>true,'align'=>'right'));
+ $table->row_end();
+ $table->end();
+ $toggle->end();
+
+ //////////////////// 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 .= " / " . 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)");
+
+ $toggle=new PlekitToggle ('persons',$persons_title,
+ array('visible'=>get_arg('show_persons')));
+ $toggle->start();
+
+ $headers = array ();
+ $headers["email"]='string';
+ $headers["S"]='int';
+ $headers["PI"]='string';
+ $headers['User']='string';
+ $headers["Tech"]='string';
+ if ($has_disabled_persons) $headers["Disabled"]='string';
+ $notes=array('S = slices');
+ $table=new PlekitTable('persons',$headers,'1r-3r-0',array('search_area'=>false,
+ 'notes'=>$notes,
+ 'pagesize_area'=>false));
+ $table->start();
+ if ($persons) foreach ($persons as $person) {
+ $table->row_start();
+ $table->cell(l_person_obj($person));
+ $table->cell(count($person['slice_ids']));
+ $table->cell( in_array ('20',$person['role_ids']) ? "yes" : "no");
+ $table->cell( in_array ('30',$person['role_ids']) ? "yes" : "no");
+ $table->cell( in_array ('40',$person['role_ids']) ? "yes" : "no");
+ if ($has_disabled_persons) $table->cell( $person['enabled'] ? "no" : plc_warning_html("yes"));
+ $table->row_end();
+ }
+ $table->end();
+ $toggle->end();
+
+ //////////////////// Slices
+ $slices_title="Slices : ";
+ $slices_title .= $max_slices . " max";
+ $slices_title .= " / " . count($slice_ids) . " running";
+ $slices_title .= " / $slivers_count slivers";