ckp
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 30 Jan 2009 09:52:43 +0000 (09:52 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 30 Jan 2009 09:52:43 +0000 (09:52 +0000)
planetlab/css/plc_details.css
planetlab/includes/plc_functions.php
planetlab/includes/plc_tables.php
planetlab/nodes/node.php
planetlab/persons/person.php
planetlab/tags/tag_form.php

index 416cdfa..7f028cd 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: plc_tables.css 11750 2009-01-29 10:11:53Z thierry $ */
+/* $Id$ */
 table.plc_details {
     width:auto;
     padding: 0;
index c703b14..44bf9d9 100644 (file)
@@ -79,8 +79,8 @@ function l_tag ($tag_type_id)         { return "/db/tags/index.php"; }
 function l_tag_add()                   { return "/db/tags/tag_form.php"; }
 function l_tag_update($id)             { return "/db/tags/tag_form.php&action=update-tag-type&id=$id"; }
 
-function l_nodegroups ()               { return "/db/tags/node_groups.php"; }
-function l_nodegroup ($nodegroup_id)   { return "/db/tags/node_groups.php?id=$nodegroup_id"; }
+function l_nodegroups ()               { return "/db/tags/nodegroups.php"; }
+function l_nodegroup ($nodegroup_id)   { return "/db/tags/nodegroups.php?id=$nodegroup_id"; }
 function l_nodegroup_t ($nodegroup_id,$text) { 
                                          return href(l_nodegroup($nodegroup_id),$text); }
 
@@ -283,6 +283,22 @@ function plc_peer_info ($api,$peerscope) {
   return array ($peer_filter,$peer_label);
 }
 
+//////////////////////////////////////////////////////////// nodegroups
+// hash by 'tagname=value'
+function plc_nodegroup_global_hash ($api,$tagnames=NULL) {
+  $filter=NULL;
+  // xxx somehow this does not work; I've checked that the feature is working from plcsh
+  // but I suspect the php marshalling or something; no time to fix, get all nodegroups for now
+  // if ($tagnames) $filter=array("tagname"=>$tagnames);
+  $nodegroups=$api->GetNodeGroups($filter);
+  $hash=array();
+  if ($nodegroups) foreach ($nodegroups as $nodegroup) {
+      $key=$nodegroup['tagname']."=".$nodegroup['value'];
+      $hash[$key]=$nodegroup;
+    }
+  return $hash;
+}
+  
 //////////////////////////////////////////////////////////// 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'] . ")"; }
@@ -340,7 +356,9 @@ function plc_vertical_table ($messages, $class="") {
 }
 
 //////////////////////////////////////////////////////////// various mappers
+// could not figure how to use anonymous lambdas..
 function get_site_id ($site) { return $site['site_id'];}
+function get_tagname ($tag) { return $tag['tagname'];}
 
 ////////////////////////////////////////////////////////////
 function plc_section ($text,$line=true) {
index ef31cd5..566bf8e 100644 (file)
@@ -27,11 +27,12 @@ function plc_table_cell($cell) {
 //  - search_area : boolean (default true)
 //  - pagesize_area : boolean (default true)
 //  - notes_area : boolean (default true)
+//  - search_width : size in chars of the search text dialog
 //  - notes : an array of additional notes
 //  - pagesize: the initial pagination size
 //  - pagesize_def: the page size when one clicks the pagesize reset button
 //  - max_pages: the max number of pages to display in the paginator
-//  - footers: a list of table rows (<tr> will be added) for building the table's tfoot area
+//  - footers: an array of table rows (<tr> will be added) for building the table's tfoot area
 function plc_table_start ($table_id, $headers, $column_sort, $options=NULL) {
   if ( ! $options ) $options = array();
   global $plc_table_hash;
@@ -41,6 +42,7 @@ function plc_table_start ($table_id, $headers, $column_sort, $options=NULL) {
   $max_pages = array_key_exists('max_pages',$options) ? $options['max_pages'] : 10;
   $pagesize = array_key_exists('pagesize',$options) ? $options['pagesize'] : 25;
   $pagesize_def = array_key_exists('pagesize_def',$options) ? $options['pagesize_def'] : 999;
+  $search_width = array_key_exists('search_width',$options) ? $options['search_width'] : 40;
 
   $paginator=$table_id."_paginator";
   $classname="paginationcallback-".$paginator;
@@ -58,7 +60,7 @@ class="plc_table sortable-onload-$column_sort rowstyle-alt colstyle-alt no-arrow
 EOF;
 
   if ($pagesize_area) plc_table_pagesize_area ($table_id,$headers,$pagesize, $pagesize_def);
-  if ($search_area) plc_table_search_area ($table_id, $headers);
+  if ($search_area) plc_table_search_area ($table_id, $headers, $search_width);
 
   print "<tr>";
   foreach ($headers as $label => $type) {
@@ -98,7 +100,7 @@ EOF;
 }
 
 ////////////////////
-function plc_table_search_area ($table_id,$headers) {
+function plc_table_search_area ($table_id,$headers,$search_width) {
   $width=count($headers);
   $search_text_id = $table_id . "_search";
   $search_reset_id = $table_id . "_search_reset";
@@ -108,7 +110,7 @@ function plc_table_search_area ($table_id,$headers) {
    <label class='table_search_label'> Search </label> 
    <input class='table_search_input' type='text' id='$search_text_id'
       onkeyup='plc_table_filter("$table_id","$search_text_id","$search_and_id");'
-      size=40 maxlength=256 />
+      size=$search_width maxlength=256 />
    <label>and</label>
    <input id='$search_and_id' class='table_search_and' 
       type='checkbox' checked='checked' 
index 7ecc909..c4bd0c6 100644 (file)
@@ -195,6 +195,35 @@ plc_details_line_list ("All site nodes",$nodes_area);
 
 plc_details_end ();
 
+//////////////////////////////////////////////////////////// Tags
+// get tags
+$tags=$api->GetNodeTags (array('node_id'=>$node_id));
+$tagnames = array_map ("get_tagname",$tags);
+//plc_debug('tagnames',$tagnames);
+$nodegroups_hash=plc_nodegroup_global_hash($api,$tagnames);
+//plc_debug('hash',$nodegroups_hash);
+
+plc_section("Tags");
+$headers=array("Name"=>"string",
+              "Value"=>"string",
+              "Nodegroup"=>"string");
+
+$table_options=array("notes_area"=>false,"pagesize_area"=>false,"search_width"=>10);
+plc_table_start("node-tags",$headers,0,$table_options);
+if ($tags) foreach ($tags as $tag) {
+  // does this match a nodegroup ?
+  $nodegroup_name="n/a";
+  $nodegroup_key=$tag['tagname'] . "=" . $tag['value'];
+  $nodegroup=$nodegroups_hash[$nodegroup_key];
+  if ($nodegroup) $nodegroup_name=l_nodegroup_t($nodegroup['nodegroup_id'],$nodegroup['groupname']);
+  plc_table_row_start();
+  plc_table_cell($tag['tagname']);
+  plc_table_cell($tag['value']);
+  plc_table_cell($nodegroup_name);
+  plc_table_row_end();
+}
+plc_table_end("node-tags");
+
 //////////////////////////////////////////////////////////// slices
 // display slices
 
@@ -206,8 +235,8 @@ if ( ! $slices  ) {
   $headers['Peer']="string";
   $headers['Name']="string";
   $headers['Slivers']="string";
-  $table_options = array('notes_area'=>false);
-  plc_table_start ("slivers",$headers,1,$table_options);
+  $table_options = array('notes_area'=>false,"search_width"=>10);
+  plc_table_start ("node-slices",$headers,1,$table_options);
 
   foreach ($slices as $slice) {
     plc_table_row_start($slice['name']);
@@ -216,7 +245,7 @@ if ( ! $slices  ) {
     plc_table_cell (l_sliver_t ($node_id,$slice['slice_id'],'view'));
     plc_table_row_end();
   }
-  plc_table_end("slivers");
+  plc_table_end("node-slices");
  }
 
 //////////////////////////////////////////////////////////// interfaces
@@ -239,8 +268,8 @@ if ( ! $peer_id ) {
     $headers["bw limit"]="FileSize";
 
     plc_section('Interfaces');
-    $table_options=array('search_area'=>false);
-    plc_table_start("interfaces",$headers,2,$table_options);
+    $table_options=array('search_area'=>false,"pagesize_area"=>false,'notes_area'=>false);
+    plc_table_start("node-interfaces",$headers,2,$table_options);
        
     foreach ( $interfaces as $interface ) {
       $interface_id= $interface['interface_id'];
@@ -279,34 +308,10 @@ if ( ! $peer_id ) {
       $button=plc_form_simple_button(l_interface_add($node_id),"Add interface","GET");
       $footers=array(plc_table_td_text($button,6,"right"));
     }
-    plc_table_end("interfaces",array("footers"=>$footers));
+    plc_table_end("node-interfaces",array("footers"=>$footers));
   }
-      
  }
-
-//////////////////////////////////////////////////////////// nodegroups
-// display node group info
-plc_section("Nodegroups");
-if ( ! $nodegroups ) {
-  echo "<p><span class='plc-warning'>This node is not in any nodegroup.</span></p>\n";
- } 
-$headers=array();
-$headers['Name']="string";
-$headers['Tag']="string";
-$headers['Value']="string";
-  
-$table_options = array('search_area'=>false);
-plc_table_start("nodegroups",$headers,0,$table_options);
-
-if ($nodegroups) foreach( $nodegroups as $nodegroup ) {
-  plc_table_row_start();
-  plc_table_cell(l_nodegroup_t($nodegroup_id,$nodegroup['groupname']));
-  $tag_types=$api->GetTagTypes(array($nodegroup['tag_type_id']));
-  plc_table_cell($tag_types[0]['tagname']);
-  plc_table_cell($nodegroup['value']);
-  plc_table_row_end();
-                }
-plc_table_end("nodegroups");
+      
 ////////////////////////////////////////////////////////////
 plc_peer_block_end();
 
index 41b39c6..3419150 100644 (file)
@@ -152,7 +152,7 @@ if( ! $slices) {
   $headers=array('Slice name'=>'string');
   $table_options=array('notes_area'=>false,
                       'pagesize'=>5);
-  plc_table_start("person_slices",$headers,1,$table_options);
+  plc_table_start("person-slices",$headers,1,$table_options);
 
   foreach( $slices as $slice ) {
     $slice_name= $slice['name'];
@@ -161,7 +161,7 @@ if( ! $slices) {
     plc_table_cell(l_slice_t($slice_id,$slice_name));
     plc_table_row_end();
   }
-  plc_table_end("person_slices");
+  plc_table_end("person-slices");
  }
 
 // we don't set 'action', but use the submit button name instead
@@ -185,7 +185,7 @@ $headers=array("Type"=>"string",
 if ($can_manage_keys) $headers['Remove']="none";
 // table overall options
 $table_options=array("search_area"=>false,"notes_area"=>false);
-plc_table_start("person_keys",$headers,"1",$table_options);
+plc_table_start("person-keys",$headers,"1",$table_options);
     
 if ($keys) foreach ($keys as $key) {
   $key_id=$key['key_id'];
@@ -211,7 +211,7 @@ if ($can_manage_keys) {
     "<td> $upload_key_right_area </td>";
 }
 
-plc_table_end("person_keys",array("footers"=>$footers));
+plc_table_end("person-keys",array("footers"=>$footers));
 
 //////////////////// sites
 plc_section('Sites');
@@ -227,7 +227,7 @@ $headers['Name']="string";
 if ($can_manage_sites) 
   $headers['Remove']="string";
 $table_options = array('notes_area'=>false,'search_area'=>false);
-plc_table_start ("person_sites",$headers,0,$table_options);
+plc_table_start ("person-sites",$headers,0,$table_options);
 foreach( $sites as $site ) {
   $site_name= $site['name'];
   $site_id= $site['site_id'];
@@ -262,7 +262,7 @@ if ($can_manage_sites) {
   $footers []="<td style='text-align:right'> $add_site_left_area </td>".
     "<td colspan=2> $add_site_right_area </td>";
  }
-plc_table_end("person_sites",array("footers"=>$footers));
+plc_table_end("person-sites",array("footers"=>$footers));
 
 //////////////////// roles
 plc_section("Roles");
@@ -274,7 +274,7 @@ $table_options=array("search_area"=>false,"notes_area"=>false);
 $headers=array("Role"=>"none");
 if ($can_manage_roles) $headers ["Remove"]="none";
 
-plc_table_start("person_roles",$headers,0,$table_options);  
+plc_table_start("person-roles",$headers,0,$table_options);  
   
 // construct array of role objs
 $role_objs=array();
@@ -311,7 +311,7 @@ if ($can_manage_roles) {
   $footers []="<td style='text-align:right'> $add_role_left_area </td>".
     "<td colspan=2> $add_role_right_area </td>";
  }
-plc_table_end("person_roles",array("footers"=>$footers));
+plc_table_end("person-roles",array("footers"=>$footers));
 
 //////////////////////////////
 plc_form_end();
index 12f1b08..f695bc7 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-// $Id: nodes.php 11750 2009-01-29 10:11:53Z thierry $
+// $Id$
 
 // Require login
 require_once 'plc_login.php';