-/* $Id: plc_tables.css 11750 2009-01-29 10:11:53Z thierry $ */
+/* $Id$ */
table.plc_details {
width:auto;
padding: 0;
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); }
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'] . ")"; }
}
//////////////////////////////////////////////////////////// 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) {
// - 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;
$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;
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) {
}
////////////////////
-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";
<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'
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
$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']);
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
$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'];
$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();
$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'];
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
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'];
"<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');
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'];
$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");
$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();
$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();
<?php
-// $Id: nodes.php 11750 2009-01-29 10:11:53Z thierry $
+// $Id$
// Require login
require_once 'plc_login.php';