}
/* tmp - for visual checking */
-.plc-local {
- border: 1px solid #00f;
+/*.plc-local {
+ border: 1px solid #00f; */
}
.plc-foreign {
background: #e0e0e0;
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) {
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
// 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'];
$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();
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";
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?
}
$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',
$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
$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(),
'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
$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();
$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);
}
$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'];
}
$privileges = plc_is_admin () || ( plc_in_site($site_id) && plc_is_pi());
$tabs=array();
+$tabs []= tab_persons();
// enable / disable
if ($local_peer && $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);
// --- 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();
$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'];
}
$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 ) {
'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"));
'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
// --- decoration
$title="Sites";
$tabs=array();
+$tabs []= tab_mysite();
+$tabs []= tab_sites_local();
// --------------------
$site_filter=array();
"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');
$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);
// --- decoration
$title="Nodegroups";
$tabs=array();
-$tabs['Tags'] = array('url'=>l_tags(),
- 'bubble'=>'Lists all known tag types');
+$tabs []= tab_tags();
+
// --------------------
$node_filter=array();
// --- 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 ) );
// --- 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);