X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fsites%2Fsite.php;h=12e8849ebe61f16e8134ec65cddd82b3fe113b71;hb=1a2eb1bf447e1e3cccf35959ad10ffaaa9790032;hp=eac14ef7fbdfd83753efe0518676d3a2e3349dd3;hpb=19ea00f9f677acff2b94f9c066c2949cc63d435c;p=plewww.git diff --git a/planetlab/sites/site.php b/planetlab/sites/site.php index eac14ef..12e8849 100644 --- a/planetlab/sites/site.php +++ b/planetlab/sites/site.php @@ -1,6 +1,6 @@ GetSites( array($site_id)); +$sites = $api->GetSites( array($site_id)); if (empty($sites)) { drupal_set_message ("Site " . $site_id . " not found"); @@ -51,11 +52,11 @@ $enabled = $site['enabled']; // extra privileges to admins, and (pi||tech) on this site $privileges = plc_is_admin () || ( plc_in_site($site_id) && ( plc_is_pi() || plc_is_tech())); -// get peer details +// get peer $peer_id= $site['peer_id']; $peers = new Peers ($api); -$adress_ids= $site['address_ids']; +$address_ids= $site['address_ids']; $pcu_ids= $site['pcu_ids']; $node_ids= $site['node_ids']; $person_ids= $site['person_ids']; @@ -63,7 +64,7 @@ $slice_ids= $site['slice_ids']; $api->begin(); // gets address info -$api->GetAddresses( $adress_ids ); +$api->GetAddresses( $address_ids ); // gets pcu info // GetPCUs is not accessible to the 'user' role @@ -92,6 +93,8 @@ foreach( $persons as $person ) { } +$has_disabled_persons = count ($disabled_persons) !=0; + drupal_set_title("Details for site " . $sitename); $local_peer = ! $peer_id; @@ -99,6 +102,9 @@ $local_peer = ! $peer_id; $privileges = plc_is_admin () || ( plc_in_site($site_id) && plc_is_pi()); $tabs=array(); + +$tabs []= tab_sites_local(); + // available actions if ( $local_peer && $privileges ) { @@ -115,10 +121,10 @@ if ( $local_peer && $privileges ) { 'action'=>'delete-site'), 'bubble'=>"Delete site $sitename", 'confirm'=>"Are you sure you want to delete site $login_base"); - $tabs["Events"]=array_merge (tabs_events(), + $tabs["Events"]=array_merge (tablook_event(), array('url'=>l_event("Site","site",$site_id), 'bubble'=>"Events for site $sitename")); - $tabs["Comon"]=array_merge(tabs_comon(), + $tabs["Comon"]=array_merge(tablook_comon(), array('url'=>l_comon("site_id",$site_id), 'bubble'=>"Comon page for $sitename")); @@ -127,9 +133,7 @@ if ( $local_peer && $privileges ) { 'bubble'=>'Review pending join requests'); } -$tabs["All sites"]=l_sites(); - -plc_tabs($tabs); +plekit_linetabs($tabs); // show gray background on foreign objects : start a
with proper class $peers->block_start ($peer_id); @@ -139,83 +143,152 @@ if ( ! $enabled ) href (l_sites_pending(),"this page") . " to review pending applications."); -$can_update=plc_is_admin () || ( plc_in_site($site_id) && plc_is_pi()); -$details = new PlcDetails($can_update); +$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']) plc_warning("This site is not public!"); +$details->form_start(l_actions(),array('action'=>'update-site','site_id'=>$site_id)); + $details->start(); -$details->line("Peer",$peers->peer_link($peer_id)); -$details->space(); -$details->form_start(l_actions(),array('action'=>'update-site','site_id'=>$site_id)); -$save_w=$details->set_field_width(30); -$details->line("Full name",$sitename,'name'); -$details->set_field_width($save_w); -$details->line("Abbreviated name",$abbreviated_name,'abbreviated_name'); -$details->line("URL",$site_url,'url'); -$details->line("Latitude",$site_lat,'latitude'); -$details->line("Longitude",$site_long,'longitude'); +$details->th_td("Full name",$sitename,'name',array('width'=>50)); +$details->th_td("Abbreviated name",$abbreviated_name,'abbreviated_name',array('width'=>15)); +$details->th_td("URL",$site_url,'url',array('width'=>40)); +$details->th_td("Latitude",$site_lat,'latitude'); +$details->th_td("Longitude",$site_long,'longitude'); + +// modifiable by admins only if (plc_is_admin()) - $details->line("Login base",$login_base,'login_base'); + $details->th_td("Login base",$login_base,'login_base',array('width'=>12)); else - $details->line("Login base",$login_base); + $details->th_td("Login base",$login_base); if (plc_is_admin()) - $details->line("Max slices",$max_slices,'max_slices'); + $details->th_td("Max slices",$max_slices,'max_slices'); else - $details->line("Max slices",$max_slices); -$details->line("",$details->submit_html("submit","Update Site")); + $details->th_td("Max slices",$max_slices); +$details->tr_submit("submit","Update Site"); + +if ( ! $local_peer) { + $details->space(); + $details->th_td("Peer",$peers->peer_link($peer_id)); + } +$details->end(); $details->form_end(); +$toggle->end(); +//////////////////// mode details - for local object if ( $local_peer ) { - // Nodes - $details->space(); + //////////////////// nodes + // xxx missing : would need to add columns on attached PCU name and port if avail $nb_boot = 0; if ($nodes) foreach ($nodes as $node) if ($node['boot_state'] == 'boot') $nb_boot ++; - $node_label = $nb_boot . " boot / " . count($nodes) . " total"; - $details->line("# 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->line ("Hostnames",$nodes_label); - $button=new PlcFormButton (l_node_add(),"add_node","Add node","POST"); - $details->line("",$button->html()); - - // 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->line ("# Users",href(l_persons_site($site_id),$user_label)); - function p_link ($p) { return l_person_t($p['person_id'],$p['email']); } - // PIs - $details->line("PI's",plc_vertical_table (array_map ("p_link",$pis))); - // techs - $details->line("Techs's",plc_vertical_table (array_map ("p_link",$techs))); - if (count ($disabled_persons)) - $details->line("Disabled",plc_vertical_table (array_map ("p_link",$disabled_persons))); - - // Slices - $details->space(); + + $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); + $toggle->start(); + + $headers=array(); + $headers['hostname']='string'; + $headers['state']='string'; + + $table = new PlekitTable ('nodes',$headers,'0',array('search_area'=>false, + 'notes_area'=>false, + 'pagesize_area'=>false)); + $table->start(); + foreach ($nodes as $node) { + $table->row_start(); + $table->cell (l_node_obj($node)); + $table->cell ($node['boot_state']); + $table->row_end(); + } + $table->tfoot_start(); + $table->row_start(); + $button=new PlekitFormButton (l_node_add(),"node_add","Add node","POST"); + $table->cell($button->html(),$table->columns(),"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); + $toggle->start(); + + $headers = array (); + $headers["email"]='string'; + $headers["PI"]='string'; + $headers['User']='string'; + $headers["Tech"]='string'; + if ($has_disabled_persons) $headers["Disabled"]='string'; + $table=new PlekitTable('persons',$headers,'1r-3r-0',array('search_area'=>false, + 'notes_area'=>false, + 'pagesize_area'=>false)); + $table->start(); + foreach ($persons as $person) { + $table->row_start(); + $table->cell(l_person_obj($person)); + $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" : "yes"); + $table->row_end(); + } + $table->end(); + $toggle->end(); + + //////////////////// Slices + // xxx to review after slices gets reworked + $toggle=new PlekitToggle ('slices',"Slices"); + $toggle->start(); + $details=new PlekitDetails (false); + $details->start(); // summary on slices $slice_label = count($slice_ids) . " running / " . $max_slices . " max"; if (count($slice_ids) >= $max_slices) $slice_label = plc_warning_html ($slice_label); - $details->line("# Slices", href(l_slices_site($site_id),$slice_label)); + $details->th_td("# Slices", href(l_slices_site($site_id),$slice_label)); if ($slices) foreach ($slices as $slice) - $details->line($slice['instantiation'],l_slice_obj($slice)); - $button=new PlcFormButton (l_slice_add(),"slice_add","Add slice","POST"); - $details->line("",$button->html()); + $details->th_td($slice['instantiation'],l_slice_obj($slice)); + $button=new PlekitFormButton (l_slice_add(),"slice_add","Add slice","POST"); + $details->tr($button->html(),"right"); + $details->end(); + $toggle->end(); // Addresses - if ($addresses) { - $details->space(); - $details->line("Addresses",""); + $toggle=new PlekitToggle ('addresses',"Addresses",array('start-visible'=>false)); + $toggle->start(); + if ( ! $addresses) { + print "

No known address for this site

"; + } else { + $details=new PlekitDetails (false); + $details->start(); + $details->th_td("Addresses",""); foreach ($addresses as $address) { - $details->line(plc_vertical_table($address['address_types']), + $details->th_td(plc_vertical_table($address['address_types']), plc_vertical_table(array($address['line1'], $address['line2'], $address['line3'], @@ -224,15 +297,17 @@ if ( $local_peer ) { $address['postalcode'], $address['country']))); } + $details->end(); } + $toggle->end(); } -$details->end(); - //////////////////////////////////////// $peers->block_end($peer_id); +//plekit_linetabs ($tabs,"bottom"); + // Print footer include 'plc_footer.php';