From 8dfeb8aa13ccfe89e04ca7e290f0dfbd10e1b5ab Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> Date: Fri, 13 Feb 2009 13:56:08 +0000 Subject: [PATCH] cleaned up tabs --- planetlab/css/plc_style.css | 4 +-- planetlab/includes/plc_functions.php | 49 ++++++++++++++++++++++++---- planetlab/includes/plc_minitabs.php | 19 +++++++++-- planetlab/minitabs/minitabs.js | 16 +++++++-- planetlab/nodes/interface.php | 4 +-- planetlab/nodes/node.php | 17 ++++++---- planetlab/nodes/nodes.php | 14 ++++---- planetlab/persons/person.php | 5 +-- planetlab/persons/persons.php | 15 ++++----- planetlab/sites/site.php | 10 +++--- planetlab/sites/sites.php | 4 +-- planetlab/tags/nodegroup.php | 11 +++---- planetlab/tags/nodegroups.php | 4 +-- planetlab/tags/tag.php | 2 +- planetlab/tags/tags.php | 9 +++-- 15 files changed, 118 insertions(+), 65 deletions(-) diff --git a/planetlab/css/plc_style.css b/planetlab/css/plc_style.css index 9152078..26c2b67 100644 --- a/planetlab/css/plc_style.css +++ b/planetlab/css/plc_style.css @@ -29,8 +29,8 @@ h2.plc { } /* tmp - for visual checking */ -.plc-local { - border: 1px solid #00f; +/*.plc-local { + border: 1px solid #00f; */ } .plc-foreign { background: #e0e0e0; diff --git a/planetlab/includes/plc_functions.php b/planetlab/includes/plc_functions.php index 9a5eff5..ad41d99 100644 --- a/planetlab/includes/plc_functions.php +++ b/planetlab/includes/plc_functions.php @@ -118,8 +118,48 @@ function l_person_register() { return "/db/persons/register.php"; } function l_site_register() { return "/db/sites/register.php"; } function l_sites_pending() { return "/db/sites/join_request.php"; } -function tabs_events() { return array('image'=>'/planetlab/icons/event.png','height'=>18);} -function tabs_comon() { return array('image'=>'/planetlab/icons/comon.png','height'=>18);} + +//////////////////////////////////////////////////////////// nav tabs +function tab_nodes () { return array ('label'=>'All nodes','url'=>l_nodes(), + 'bubble'=>'Display nodes from all peers'); } +function tab_nodes_local () { return array ('label'=>'Local nodes', 'url'=>l_nodes_peer('local'), + 'bubble'=>'Display local nodes only'); } +function tab_nodes_site($site_id){ return array ('label'=>'Site nodes', 'url'=>l_nodes_site($site_id), + 'bubble'=>'Display nodes on that site'); } +function tab_nodes_mysite () { return array ('label'=>'My nodes', 'url'=>l_nodes_site(plc_my_site_id()), + 'bubble'=>'Display nodes on that site'); } +function tab_node($node) { return array ('label'=>'Node '.$node['hostname'], 'url'=>l_node($node_id), + 'bubble'=>'Details for ' . $node['hostname']); } +////////// +function tab_site($site) { return array ('label'=>'Site '.$site['login_base'], 'url'=>l_site($site_id), + 'bubble'=>'Details for ' . $site['name']); } +function tab_mysite() { return array ('label'=>'My site', 'url'=>l_site(plc_my_site_id()), + 'bubble'=>'Details for site ' . plc_my_site_id()); } +function tab_sites () { return array ('label'=>'All sites' , 'url'=>l_sites(), 'bubble'=> 'Display all sites'); } +function tab_sites_local () { return array ('label'=>'Local sites' , 'url'=>l_sites_peer('local'), 'bubble'=> 'Display local sites'); } +////////// +function tab_slices() { return array ('label'=>'All slices', 'url'=>l_slices(), + 'bubble' => 'Display all slices'); } +function tab_slice($slice) { return array ('label'=>'Slice '.$slice['name'], 'url'=>l_slice($slice_id), + 'bubble' => 'Details for ' . $slice['name']); } +////////// +function tab_persons() { return array ('label'=>'All accounts', 'url'=>l_persons(), + 'bubble'=>'Display users from all peers'); } +function tab_persons_local() { return array ('label'=>'Local accounts', 'url'=>l_persons_peer('local'), + 'bubble'=>'Display local users'); } +function tab_persons_mysite() { return array ('label'=>'My accounts' , 'url'=>l_persons_site(plc_my_site_id()), + 'bubble'=>'Display accounts on site ' . plc_my_site_id()); } +////////// +function tab_tags() { return array ('label'=>'Tag Types', 'url'=>l_tags(), + 'bubble' => 'Display and create tag types'); } +function tab_nodegroups() { return array ('label'=>'Nodegroups', 'url'=>l_nodegroups(), + 'bubble' => 'Display and create nodegroups'); } + +// only partial tab +function tablook_event() { return array('image'=>'/planetlab/icons/event.png','height'=>18);} +function tablook_comon() { return array('image'=>'/planetlab/icons/comon.png','height'=>18);} + +//////////////////// // returns array ['url' => path, 'values' => hash (key=>value)* ] function split_url ($full_url) { @@ -247,11 +287,6 @@ function plc_nodegroup_global_hash ($api,$tagnames=NULL) { function t_site($site) { return " on site " . $site['name'] . " (" . $site['login_base'] .")"; } function t_slice ($slice) { return " running slice " . $slice['name'] . " (" . $slice['slice_id'] . ")"; } -//////////////////////////////////////////////////////////// nav tabs -function tabs_node($node) { return array('Node ' . $node['hostname']=>l_node($node_id)); } -function tabs_site($site) { return array('Site ' . $site['name']=>l_site($site_id)); } -function tabs_slice($slice) { return array('Slice ' . $slice['name']=>l_slice($slice_id)); } - //////////////////////////////////////////////////////////// html fragments function plc_vertical_table ($messages, $class="") { // pretty print the cell diff --git a/planetlab/includes/plc_minitabs.php b/planetlab/includes/plc_minitabs.php index cac7aad..5bce03b 100644 --- a/planetlab/includes/plc_minitabs.php +++ b/planetlab/includes/plc_minitabs.php @@ -13,25 +13,37 @@ drupal_set_html_head(' // todo can be either // (*) a string : it is then taken to be a URL to move to // (*) or an associative array with the following keys +// (*) 'label' : if set, this overrides the string key just above +// this is used for functions that return a tab, more convenient to write&use // (*) 'method': 'POST' or 'GET' -- default is 'GET' // (*) 'url': where to go // (*) 'values': an associative array of (key,value) pairs to send to the URL; values are strings // (*) 'confirm': a question to display before actually triggering // (*) 'bubble': a longer message displayed when the mouse stays quite for a while on the label -// (*) 'image' : the url of an image used instead of the full title +// (*) 'image' : the url of an image used instead of the label // (*) 'height' : used for the image +// examples +// function my_tab () { return array('label'=>'The Text','url'=>'http://google.com'); } +// $tabs=array(); +// $tabs[] = my_tab(); +// $tabs['Simple Tab']="http://planet-lab.org"; +// $tabs['Complex Tab']=array('url'=>'http://planet-lab.org/', +// 'bubble'=>'This text gets displayed when the mouse remains over for a while'); +// plc_tabs($tabs); + ////////// Notes: limited support for images // (*) for some reason, confirmation does not work with image tabs // (the form gets submitted whatever the confirmation....) // (*) you need to tune the image size, which is wrong, as the image should rather be bottom-aligned - function plc_tabs ($array) { print '<div id="minitabs-container">'; print '<ul id="minitabs-list">'; print "\n"; foreach ($array as $label=>$todo) { + // the 'label' key, if set in the hash, supersedes $key + if ($todo['label']) $label=$todo['label']; $tracer="class=minitabs"; if ($todo['id']) $tracer .= " id=".$todo['id']; @@ -47,7 +59,8 @@ function plc_tabs ($array) { $url_values=$split['values']; // create form - printf ('<form name="%s" action="%s" method="%s">',$label,$url,$todo['method']); + $method=$todo['method']; + print "<form name='$label' action='$url' method='$method'>"; // set values $values=$todo['values']; if ( ! $values) $values = array(); diff --git a/planetlab/minitabs/minitabs.js b/planetlab/minitabs/minitabs.js index c31c175..dcbe6ce 100644 --- a/planetlab/minitabs/minitabs.js +++ b/planetlab/minitabs/minitabs.js @@ -87,8 +87,9 @@ var miniTab = { miniTab.slideObj = miniTab.ul.parentNode.appendChild(document.createElement("div")); miniTab.slideObj.appendChild(document.createTextNode(String.fromCharCode(160))); miniTab.slideObj.id = "minitabs-sliding"; - miniTab.slideObj.style.top = (miniTab.ul.offsetTop + miniTab.liArr[miniTab.activeTab].offsetTop + - miniTab.inputArr[miniTab.activeTab].offsetTop) + "px"; + + miniTab.setTop(); + miniTab.slideObj.style.left = (miniTab.ul.offsetLeft + miniTab.liArr[miniTab.activeTab].offsetLeft + miniTab.inputArr[miniTab.activeTab].offsetLeft) + "px"; miniTab.slideObj.style.width = miniTab.inputArr[miniTab.activeTab].offsetWidth + "px"; @@ -134,9 +135,18 @@ var miniTab = { miniTab.bW = miniTab.slideObj.offsetWidth; miniTab.cW = miniTab.destW - miniTab.bW; - miniTab.slideObj.style.top = (miniTab.ul.offsetTop + miniTab.liArr[miniTab.activeTab].offsetTop + miniTab.inputArr[miniTab.activeTab].offsetTop) + "px"; + miniTab.setTop(); }, + setTop: function () { + var delta=0; + /* up 5px for firefox */ + if (navigator.userAgent.match(/Firefox/)) delta=-5; + miniTab.slideObj.style.top = (miniTab.ul.offsetTop + miniTab.liArr[miniTab.activeTab].offsetTop + + miniTab.inputArr[miniTab.activeTab].offsetTop + delta ) + "px"; + + }, + slideIt:function() { // Has the browser text size changed? diff --git a/planetlab/nodes/interface.php b/planetlab/nodes/interface.php index 0554939..a1f9011 100644 --- a/planetlab/nodes/interface.php +++ b/planetlab/nodes/interface.php @@ -43,8 +43,8 @@ if ( ! $node_id) { } $tabs=array(); -$tabs['Back to node']=array('url'=>l_node($node_id), - 'bubble'=>'Cancel pending changes'); +$tabs[] = array('label'=>'Back to node', 'url'=>l_node($node_id), + 'bubble'=>'Cancel pending changes'); plc_tabs($tabs); $fields=array( 'method', 'type', 'ip', 'gateway', 'network', 'broadcast', 'netmask', diff --git a/planetlab/nodes/node.php b/planetlab/nodes/node.php index 98de24b..d58317a 100644 --- a/planetlab/nodes/node.php +++ b/planetlab/nodes/node.php @@ -93,8 +93,9 @@ if( !empty( $conf_file_ids ) ) $conf_files= $api->GetConfFiles( $conf_file_ids ); // (*) idem for PCUs // gets pcu and port info key to both is $pcu_id -if( !empty( $pcu_ids ) ) - $PCUs= $api->GetPCUs( $pcu_ids ); +// turning this off: GetPCUs is not allowed to users, and we don't show PCUs yet anyway +//if( !empty( $pcu_ids ) ) +// $PCUs= $api->GetPCUs( $pcu_ids ); //////////////////// display node info @@ -107,6 +108,10 @@ $privileges = (plc_is_admin () && $local_peer) || ( plc_in_site($site_id) && ( p $tabs=array(); // available actions +$tabs [] = tab_nodes_site($site_id); +$tabs [] = tab_site($site_id); +$tabs [] = tab_nodes(); + if ( $local_peer && $privileges ) { $tabs['Delete'] = array ('url'=>l_actions(), @@ -116,17 +121,15 @@ if ( $local_peer && $privileges ) { 'confirm'=>'Are you sure to delete ' . $hostname. ' ?'); // xxx subject to roles $tabs["Add Interface"]=array('url'=>l_interface_add($node_id), - 'bubble'=>"Declare new network interface on $hostname"); - $tabs["Events"]=array_merge(tabs_events(), + 'bubble'=>"Define new network interface on $hostname"); + $tabs["Events"]=array_merge(tablook_event(), array('url'=>l_event("Node","node",$node_id), 'bubble'=>"Events for node $hostname")); - $tabs["Comon"]=array_merge(tabs_comon(), + $tabs["Comon"]=array_merge(tablook_comon(), array('url'=>l_comon("node_id",$node_id), 'bubble'=>"Comon page about node $hostname")); } -$tabs["All nodes"]=l_nodes(); - plc_tabs($tabs); // show gray background on foreign objects : start a <div> with proper class diff --git a/planetlab/nodes/nodes.php b/planetlab/nodes/nodes.php index b1daeff..8541c13 100644 --- a/planetlab/nodes/nodes.php +++ b/planetlab/nodes/nodes.php @@ -30,11 +30,9 @@ $slice_id=intval($_GET['slice_id']); $title="Nodes"; $tabs=array(); $mysite_id=plc_my_site_id(); -$tabs['My nodes'] = array('url'=>l_nodes(), - 'values'=>array('site_id'=>plc_my_site_id()), - 'bubble'=>'Lists nodes on site ' . $mysite_id); -$tabs['Local nodes'] = array ('url'=>l_nodes_peer('local'), - 'bubble' => 'Nodes local to this peer'); +$tabs []= tab_nodes_mysite(); +$tabs []= tab_nodes_local(); + // -------------------- $node_filter=array(); @@ -71,12 +69,12 @@ $node_filter=array_merge($node_filter,$peerscope->filter()); $title .= ' - ' . $peerscope->label(); if ($site_id) { - $sites=$api->GetSites(array($site_id),array("name","login_base")); + $sites=$api->GetSites(array($site_id)); $site=$sites[0]; $name=$site['name']; $login_base=$site['login_base']; $title .= t_site($site); - $tabs = array_merge($tabs,tabs_site($site)); + $tabs []= tab_site($site); $node_filter['site_id']=array($site_id); } @@ -84,7 +82,7 @@ if ($slice_id) { $slices=$api->GetSlices(array($slice_id),array('node_ids','name')); $slice=$slices[0]; $title .= t_slice($slice); - $tabs = array_merge($tabs,tabs_slice($slice)); + $tabs []= tab_slice($slice); $node_filter['node_id'] = $slice['node_ids']; } diff --git a/planetlab/persons/person.php b/planetlab/persons/person.php index 126dee9..b98f529 100644 --- a/planetlab/persons/person.php +++ b/planetlab/persons/person.php @@ -72,6 +72,7 @@ $is_my_account = plc_my_person_id() == $person_id; $privileges = plc_is_admin () || ( plc_in_site($site_id) && plc_is_pi()); $tabs=array(); +$tabs []= tab_persons(); // enable / disable if ($local_peer && $privileges) @@ -114,10 +115,6 @@ if ( $privileges) 'bubble'=>"Events about $first_name $last_name", 'image'=>'/planetlab/icons/event.png','height'=>18); -// Back button -$tabs['All Users'] = array ('url'=>l_persons(), - 'bubble'=>'Back to the Users page'); - plc_tabs($tabs); $peers->block_start ($peer_id); diff --git a/planetlab/persons/persons.php b/planetlab/persons/persons.php index c95cc68..f5f5323 100644 --- a/planetlab/persons/persons.php +++ b/planetlab/persons/persons.php @@ -32,12 +32,10 @@ $slice_id=intval($_GET['slice_id']); // --- decoration $title="Accounts"; $tabs=array(); -$tabs['My accounts'] = array('url'=>l_persons(), - 'values'=>array('site_id'=>plc_my_site_id()), - 'bubble'=>'Lists accounts on site ' . plc_my_site_id()); +$tabs []= tab_persons_mysite(); + if (plc_is_admin()) - $tabs['Local accounts'] = array('url'=>l_persons(), - 'values'=>array('peerscope'=>'local')); + $tabs []= tab_persons_local(); // -------------------- $person_filter=array(); @@ -93,17 +91,16 @@ if ($site_id) { $name=$site['name']; $login_base=$site['login_base']; $title .= t_site($site); - $tabs = array_merge($tabs,tabs_site($site)); $person_filter['person_id']=$site['person_ids']; - if ($site_id == plc_my_site_id()) - unset($tabs['My accounts']); + if ($site_id != plc_my_site_id()) + $tabs []= tab_site($site); } if ($slice_id) { $slices=$api->GetSlices(array($slice_id),array('person_ids','name')); $slice=$slices[0]; $title .= t_slice($slice); - $tabs = array_merge($tabs,tabs_slice($slice)); + $tabs []= tab_slice($slice); $person_filter['person_id'] = $slice['person_ids']; } diff --git a/planetlab/sites/site.php b/planetlab/sites/site.php index 82c3409..2efd127 100644 --- a/planetlab/sites/site.php +++ b/planetlab/sites/site.php @@ -99,6 +99,10 @@ $local_peer = ! $peer_id; $privileges = plc_is_admin () || ( plc_in_site($site_id) && plc_is_pi()); $tabs=array(); + +$tabs []= tab_sites(); +$tabs []= tab_sites_local(); + // available actions if ( $local_peer && $privileges ) { @@ -115,10 +119,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,8 +131,6 @@ if ( $local_peer && $privileges ) { 'bubble'=>'Review pending join requests'); } -$tabs["All sites"]=l_sites(); - plc_tabs($tabs); // show gray background on foreign objects : start a <div> with proper class diff --git a/planetlab/sites/sites.php b/planetlab/sites/sites.php index 7ee7086..227bec1 100644 --- a/planetlab/sites/sites.php +++ b/planetlab/sites/sites.php @@ -27,6 +27,8 @@ $pattern=$_GET['pattern']; // --- decoration $title="Sites"; $tabs=array(); +$tabs []= tab_mysite(); +$tabs []= tab_sites_local(); // -------------------- $site_filter=array(); @@ -95,8 +97,6 @@ if (! plc_is_admin()) { "enabled", "person_ids", "max_slices", "slice_ids", "node_ids"); } -$tabs['My site'] = array('url'=>l_site(plc_my_site_id())); -$tabs['Local sites'] = array('url'=>l_sites_peer('local')); if (plc_is_admin()) $tabs['Pending'] = array ('url'=>l_sites_pending(), 'bubble'=>'Review pending join requests'); diff --git a/planetlab/tags/nodegroup.php b/planetlab/tags/nodegroup.php index b4d20eb..ac7ec61 100644 --- a/planetlab/tags/nodegroup.php +++ b/planetlab/tags/nodegroup.php @@ -42,12 +42,11 @@ $node_columns = array("hostname","node_id"); $nodes = $api->GetNodes( $node_ids, $node_columns); -$tabs ["All nodegroups"] = array ('url'=>l_nodegroups(), - 'bubble'=>'All nodegroups'); -$tabs ["All tags"] = array ('url'=>l_tags(), - 'bubble'=>'All tags'); -$tabs ["Local nodes"] = array ('url'=>l_nodes_peer('local'), - 'bubble'=>'All local nodes'); +$tabs = array(); + +$tabs []= tab_tags(); +$tabs []= tab_nodegroups(); +$tabs []= tab_nodes_local(); drupal_set_title("Details for node group " . $nodegroup['groupname']); plc_tabs($tabs); diff --git a/planetlab/tags/nodegroups.php b/planetlab/tags/nodegroups.php index 2e1bd0c..2242544 100644 --- a/planetlab/tags/nodegroups.php +++ b/planetlab/tags/nodegroups.php @@ -25,8 +25,8 @@ $pattern=$_GET['pattern']; // --- decoration $title="Nodegroups"; $tabs=array(); -$tabs['Tags'] = array('url'=>l_tags(), - 'bubble'=>'Lists all known tag types'); +$tabs []= tab_tags(); + // -------------------- $node_filter=array(); diff --git a/planetlab/tags/tag.php b/planetlab/tags/tag.php index 7d20f19..771117e 100644 --- a/planetlab/tags/tag.php +++ b/planetlab/tags/tag.php @@ -31,7 +31,7 @@ if ( ! $tag_type_id ) { // --- decoration $title="Tag Type"; $tabs=array(); -$tabs['All Types']=array('url'=>l_tags(),'bubble'=>"All Tag Types"); +$tabs []= tab_tags(); // -------------------- $tag_types= $api->GetTagTypes( array( $tag_type_id ) ); diff --git a/planetlab/tags/tags.php b/planetlab/tags/tags.php index 282c9c5..3583abd 100644 --- a/planetlab/tags/tags.php +++ b/planetlab/tags/tags.php @@ -26,11 +26,10 @@ $pattern=$_GET['pattern']; // --- decoration $title="Tag Types"; $tabs=array(); -$tabs['Tag Types']=array('url'=>l_tags(),'bubble'=>"Create a new tag type"); -$tabs['All Nodes']=array('url'=>l_nodes(),'bubble'=>"Nodes from all peers"); -$tabs['Local Nodes']=array('url'=>l_nodes(),'values'=>array('peerscope'=>'local'),'bubble'=>"All local nodes"); -//$tabs['Interfaces']=l_interfaces(); -$tabs['All Slices']=array('url'=>l_slices(),'bubble'=>"Slices from all peers"); +$tabs []= tab_tags(); +$tabs []= tab_nodes(); +$tabs []= tab_nodes_local(); +$tabs []= tab_slices(); // -------------------- drupal_set_title($title); -- 2.47.0