X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fnodes%2Fslivers.php;h=62e46de7247e1f18c6f7613ba56ede1a753355f4;hb=ab7d755720166fb4ce7acaf629463dc7f0a00ffe;hp=738978255539c21f853c5295792b419bbfdce05f;hpb=13f1390a55a79b7e3ef6d0558ea070c88bd06cb4;p=plewww.git diff --git a/planetlab/nodes/slivers.php b/planetlab/nodes/slivers.php index 7389782..62e46de 100644 --- a/planetlab/nodes/slivers.php +++ b/planetlab/nodes/slivers.php @@ -9,135 +9,90 @@ global $plc, $api; // Print header require_once 'plc_drupal.php'; -drupal_set_title('Slivers'); +drupal_set_title('Sliver Tags'); include 'plc_header.php'; // Common functions require_once 'plc_functions.php'; -require_once 'plc_sorts.php'; - -// find person roles -$_person= $plc->person; -$_roles= $_person['role_ids']; - -//print_r( $_person ); - - -// if add is set, diplay add sliver form -if( $_GET['add'] ) { - $node_id= $_GET['add']; - $slice_id= $_GET['slice']; - - // slice info - $slice_info= $api->GetSlices( array( intval( $slice_id ) ), array( "name" ) ); - - // node info - $node_info= $api->GetNodes( array( intval( $node_id ) ), array( "hostname" ) ); - - // get tag types - $type_info= $api->GetTagTypes( NULL, array( "tag_type_id", "tagname" ) ); - - // get the slivers for this node - $sliver_info= $api->GetSliceTags( array( "node_id"=>intval( $node_id ), "slice_id"=>intval( $slice_id ) ), array( "tag_type_id", "name" ) ); - - $types_left= $type_info; - - - // start form - echo "
\n -

Add a Sliver Tag to ". $slice_info[0]['name'] ." on node ". $node_info[0]['hostname'] ."

\n - \n - \n - \n -
Tag:
Value:
\n - -

\n"; - - echo "

Back to Node\n

\n"; - -} +require_once 'table.php'; +require_once 'toggle.php'; +require_once 'form.php'; // if slice and node ids are passed display slivers and tags -if( $_GET['slice'] && $_GET['node'] ) { - $slice_id= $_GET['slice']; - $node_id= $_GET['node']; - - // slice info - $slice_info= $api->GetSlices( array( intval( $slice_id ) ), array( "name" ) ); - - // node info - $node_info= $api->GetNodes( array( intval( $node_id ) ), array( "hostname" ) ); - - // get the slivers for this node - $sliver_info= $api->GetSliceTags( array( "node_id"=>intval( $node_id ), "slice_id"=>intval( $slice_id ) ), array( "slice_tag_id", "name", "value", "min_role_id", "description" ) ); - - // get the attrbibutes for this slice - $tag_info= $api->GetSliceTags( array( intval( $slice_id ) ), array( "slice_tag_id", "name", "value", "min_role_id", "description" ) ); - - - // start form - echo "
\n

Sliver Details for slice ". $slice_info[0]['name'] ." on node ". $node_info[0]['hostname'] ."

\n"; - - // sliver tags of slice - if( empty( $sliver_info ) ) - // if no sliver exists tell user - echo "No sliver tag for this node/slice sliver combination.\n"; - else { - echo "

\n\n"; - if ( in_array( 10, $_roles ) || ( in_array( 20, $_roles ) && in_array( $node_info, $_person['site_ids'] ) ) ) echo ""; - echo "\n"; - - foreach( $sliver_info AS $sliver ) { - echo ""; - if ( in_array( 10, $_roles ) || ( in_array( 20, $_roles ) && in_array( $node_info, $_person['site_ids'] ) ) ) echo ""; - echo "\n"; - - +if( $_GET['slice_id'] && $_GET['node_id'] ) { + $slice_id = $_GET['slice_id']; + $node_id = $_GET['node_id']; + + + // slice info + $slice = $api->GetSlices( array( intval( $slice_id ) ), array( "name" ) ); + $slice = $slice[0]; + + // node info + $node = $api->GetNodes( array( intval( $node_id ) ), array( "hostname" ) ); + $node = $node[0]; + + drupal_set_title("Sliver tags on node " . $node['hostname'] . " and slice " . $slice['name']); + + $peer_id= $slice['peer_id']; + $local_peer = ! $peer_id; + $privileges = ( $local_peer && (plc_is_admin() || plc_is_pi() || $am_in_slice)); + + // get the slivers for this node + $tags = $api->GetSliceTags( array( "node_id"=>intval( $node_id ), "slice_id"=>intval( $slice_id ) ), + array( "slice_tag_id", "tagname", "value", "min_role_id", "description" ) ); + + $toggle = new PlekitToggle ('sliver-tags',count_english_warning($tags,'tag'), + array('bubble'=>'Inspect and set tags on the sliver', + 'visible'=>true)); + $toggle->start(); + + $headers=array( + "Name"=>"string", + "Value"=>"string", + "Description"=>"string"); + if ($privileges) $headers[plc_delete_icon()]="none"; + + $table_options = array("notes_area"=>false,"pagesize_area"=>false,"search_width"=>10); + $table = new PlekitTable("sliver_tags",$headers,'0',$table_options); + $form = new PlekitForm(l_actions(),array('slice_id'=>$slice_id, 'node_id'=>$node_id, 'sliver_action'=>true)); + $form->start(); + $table->start(); + + foreach ($tags as $tag) { + $table->row_start(); + $table->cell($tag['tagname']); + $table->cell($tag['value']); + $table->cell($tag['description']); + $table->row_end(); } - echo "
Slivers
NameValueMin RollDescription
". $sliver['name'] ."". $sliver['value'] ."". $sliver['min_role_id'] ."". $sliver['description'] ."EditRemove
\n"; - - } - - if ( in_array( 10, $_roles ) || ( in_array( 20, $_roles ) && in_array( $node_info, $_person['site_ids'] ) ) ) echo "

Add Sliver Tag\n"; - - echo "


"; - - // regular tags of slice - if( empty( $tag_info ) ) - // if no tags exist tell user - echo "No Tags for this slice.\n"; - else { - echo "

\n\n"; - if ( in_array( 10, $_roles ) || ( in_array( 20, $_roles ) && in_array( $node_info, $_person['site_ids'] ) ) ) echo ""; - echo "\n"; - - foreach( $tag_info AS $tag ) { - echo ""; - if ( in_array( 10, $_roles ) || ( in_array( 20, $_roles ) && in_array( $node_info, $_person['site_ids'] ) ) ) echo ""; - echo "\n"; - - + if ($privileges) { + $table->tfoot_start(); + $table->row_start(); + $table->cell($form->submit_html ("delete-slice-tags","Remove selected"), + array('hfill'=>true,'align'=>'right')); + $table->row_end(); + + $table->row_start(); + function tag_selector ($tag) { + return array("display"=>$tag['tagname'],"value"=>$tag['tag_type_id']); + } + $all_tags= $api->GetTagTypes( array ("category"=>"slice*"), array("tagname","tag_type_id")); + $selector_tag=array_map("tag_selector",$all_tags); + + $table->cell($form->select_html("tag_type_id",$selector_tag,array('label'=>"Choose Tag"))); + $table->cell($form->text_html("value","",array('width'=>8))); + $table->cell($form->submit_html("add-slice-tag","Set Tag"),array('columns'=>2,'align'=>'left')); + $table->row_end(); } - echo "
Tags
NameValueMin RollDescription
". $tag['name'] ."". $tag['value'] ."". $tag['min_role_id'] ."". $tag['description'] ."Edit
\n"; - - } - - - echo "

Back to Node\n

\n"; - + $form->end(); + $table->end(); + $toggle->end(); } - // Print footer include 'plc_footer.php';