The first "production" version of the column selection interface
authorPanos <antoniad@akastos.rsr.lip6.fr>
Wed, 13 Oct 2010 16:31:40 +0000 (18:31 +0200)
committerPanos <antoniad@akastos.rsr.lip6.fr>
Wed, 13 Oct 2010 16:31:40 +0000 (18:31 +0200)
planetlab/css/my_slice.css
planetlab/includes/plc_visibletags2.php
planetlab/slices/slice2.php
plekit/icons/ajax-loader.gif [new file with mode: 0644]
plekit/php/columns.php
plekit/php/logSorting.php [new file with mode: 0644]
plekit/php/table2.php
plekit/php/updateConfiguration.php [moved from plekit/php/updateConf.php with 69% similarity]
plekit/table/columns.js

index d33730f..0a20eb2 100644 (file)
@@ -40,14 +40,17 @@ table#leases_data {
 #leases_buttons { padding: 0px 10px 10px 10px; }
 #leases_clear { position: relative; left: 30%;}
 #leases_submit { position: relative; left: 60%; }
-       
+        
 
-/*panos: some additional styles for the column configuration */
+/* column configuation style */
 
 div#toggle-container-my-slice-nodes-configuration {
     background: #f8f8f8;
 }
 
+OPTION.out{background-color:white; color:black}
+OPTION.in{background-color:#CAE8EA; color:#4f6b72}
+
 div.out{background-color:white; color:black}
 div.in{background-color:#CAE8EA; color:#4f6b72}
 div.selected{background-color:gray; color:black}
@@ -59,16 +62,17 @@ div.invisible{display:none}
 }
 
 .myslice .title {
-       font: 11px;
-       font-weight: bold;
+        font: 11px;
+        font-weight: bold;
 }
 
 .myslice .desc {
-       font: 11px;
-       font-style: italic;
+        font: 11px;
+        font-style: italic;
 }
 
 .myslice .subtitle{
         color: #bb9c61;
 }
 
+
index 10341c3..319ac7f 100644 (file)
@@ -49,7 +49,8 @@ class VisibleTags {
 
     # cache for next time
     $this->columns=$columns;
-//    plc_debug('columns',$columns);
+
+    //plc_debug('columns',$columns);
     return $columns;
   }
 
@@ -63,8 +64,14 @@ class VisibleTags {
     $headers=array();
     $columns=$this->columns();
     foreach ($columns as $column)
+       {
            //panos: needed a few more fields in the header array
-       $headers[$column['header']]=array('header'=>$column['header'],'type'=>$column['type'],'tagname'=>$column['tagname'],'title'=>$column['description']);
+       $headerId = $column['header'];
+       if ($column['headerId'] != "")
+               $headerId = $column['headerId'];
+
+       $headers[$headerId]=array('header'=>$column['header'],'headerId'=>$headerId, 'type'=>$column['type'],'tagname'=>$column['tagname'],'title'=>$column['description']);
+       }
     /*
       if ($column['header'] == $column['tagname']) 
        $headers[$column['header']]=$column['type'];
index 385c8b5..a793905 100644 (file)
@@ -23,24 +23,33 @@ require_once 'table2.php';
 require_once 'details.php';
 require_once 'toggle.php';
 require_once 'form.php';
+require_once 'raphael.php';
 require_once 'columns.php';
 
 // keep css separate for now
 drupal_set_html_head('
 <link href="/planetlab/css/my_slice.css" rel="stylesheet" type="text/css" />
+<script src="/planetlab/slices/leases.js" type="text/javascript" charset="utf-8"></script>
 ');
 
 // -------------------- admins potentially need to get full list of users
 ini_set('memory_limit','32M');
 
+$profiling=false;
+if ($_GET['profiling']) $profiling=true;
+
+if ($profiling)  plc_debug_prof_start();
+
 // -------------------- 
 // recognized URL arguments
 $slice_id=intval($_GET['id']);
 if ( ! $slice_id ) { plc_error('Malformed URL - id not set'); return; }
 
 ////////////////////
-// Get all columns as we focus on only one entry
-$slices= $api->GetSlices( array($slice_id));
+// have to name columns b/c we need the non-native 'omf_control' column
+$slice_columns=array('slice_id','name','peer_id','site_id','person_ids','node_ids','expires',
+                    'url','description','instantiation','omf_control');
+$slices= $api->GetSlices( array($slice_id), $slice_columns);
 
 if (empty($slices)) {
   drupal_set_message ("Slice " . $slice_id . " not found");
@@ -49,6 +58,7 @@ if (empty($slices)) {
 
 $slice=$slices[0];
 
+if ($profiling) plc_debug_prof('2: slice',count($slices));
 // pull all node info to vars
 $name= $slice['name'];
 $expires = date( "d/m/Y", $slice['expires'] );
@@ -61,12 +71,15 @@ $peer_id= $slice['peer_id'];
 $peers=new Peers ($api);
 $local_peer = ! $peer_id;
 
+if ($profiling) plc_debug_prof('3: peers',count($peers));
+
 // gets site info
 $sites= $api->GetSites( array( $site_id ) );
 $site=$sites[0];
 $site_name= $site['name'];
 $max_slices = $site['max_slices'];
 
+if ($profiling) plc_debug_prof('4: sites',count($sites));
 //////////////////////////////////////// building blocks for the renew area
 // Constants
 global $DAY;           $DAY = 24*60*60;
@@ -146,10 +159,15 @@ EOF;
      } else {
       print <<< EOF
 <div class='my-slice-renewal'>
-<p>You must provide a short description as well as a link to a project website before renewing it.
-Do <span class='bold'>not</span> provide bogus information; if a complaint is lodged against your slice 
-and PlanetLab Operations is unable to determine what the normal behavior of your slice is, 
-your slice may be deleted to resolve the complaint.</p>
+<p>You <span class='bold'>must</span> provide a short description, 
+as well as a link to a project website, before renewing it.
+
+<br/> Please make sure to provide reasonable details on <span class='bold'>
+the kind of traffic</span>, and <span class='bold'>copyrights</span> if relevant. 
+Do <span class='bold'>not</span> provide bogus information; if a complaint is lodged against 
+your slice  and your PlanetLab Operations Center is unable to determine what the normal behavior 
+of your slice is, your slice may be deleted to resolve the complaint.</p>
+
 <p><span class='bold'>NOTE:</span> 
 Slices cannot be renewed beyond another $max_renewal_weeks week(s) ($max_renewal_date).
 </p>
@@ -185,7 +203,7 @@ $tags_privileges = $privileges || plc_is_admin();
 
 $tabs=array();
 $tabs [] = tab_nodes_slice($slice_id);
-$tabs [] = tab_site($site_id);
+$tabs [] = tab_site($site);
 
 // are these the right privileges for deletion ?
 if ($privileges) {
@@ -252,6 +270,7 @@ $details->th_td('URL',$slice['url'],'url',array('width'=>50));
 $details->tr_submit("submit","Update Slice");
 $details->th_td('Expires',$expires);
 $details->th_td('Instantiation',$slice['instantiation']);
+$details->th_td("OMF-friendly", ($slice['omf_control'] ? 'Yes' : 'No') . " [to change: see 'omf_control' in the tags section below]");
 $details->th_td('Site',l_site_obj($site));
 // xxx show the PIs here
 //$details->th_td('PIs',...);
@@ -275,8 +294,9 @@ $potential_persons=
                   $person_columns);
 $count=count($persons);
 
+if ($profiling) plc_debug_prof('4: persons',count($persons));
 $toggle=
-  new PlekitToggle ('my-slice-persons',"$count users",
+  new PlekitToggle ('my-slice-persons',"$count Users",
                    array('bubble'=>
                          'Manage accounts attached to this slice',
                          'visible'=>get_arg('show_persons',false)));
@@ -298,7 +318,7 @@ $headers['first']='string';
 $headers['last']='string';
 $headers['R']='string';
 if ($privileges) $headers[plc_delete_icon()]="none";
-$table=new PlekitTable2('persons',$headers,'0', NULL,
+$table=new PlekitTable('persons',$headers,'0',
                       array('notes_area'=>false));
 $form=new PlekitForm(l_actions(),array('slice_id'=>$slice['slice_id']));
 $form->start();
@@ -349,7 +369,7 @@ if ($privileges) {
     // show search for admins only as other people won't get that many names to add
     if ( ! plc_is_admin() ) $options['search_area']=false;
     
-    $table=new PlekitTable2('add_persons',$headers,'0',NULL,$options);
+    $table=new PlekitTable('add_persons',$headers,'0',$options);
     $form=new PlekitForm(l_actions(),array('slice_id'=>$slice['slice_id']));
     $form->start();
     $table->start();
@@ -386,15 +406,20 @@ $toggle->end();
 //     (.) type is passed to the javascript table, for sorting (default is 'string')
 
 // minimal list as a start
-//$node_fixed_columns = array('hostname','node_id','slice_ids_whitelist','boot_state','last_contact');
+$node_fixed_columns = array('hostname','node_id','peer_id','slice_ids_whitelist',
+                           'run_level','boot_state','last_contact','node_type');
 // create a VisibleTags object : basically the list of tag columns to show
-//$visibletags = new VisibleTags ($api, 'node');
-//$visiblecolumns = $visibletags->column_names();
-//$node_columns=array_merge($node_fixed_columns,$visiblecolumns);
+$visibletags = new VisibleTags ($api, 'node');
+$visiblecolumns = $visibletags->column_names();
+$node_columns=array_merge($node_fixed_columns,$visiblecolumns);
 
+// optimizing calls to GetNodes
+//$all_nodes=$api->GetNodes(NULL,$node_columns);
+//$slice_nodes=$api->GetNodes(array('node_id'=>$slice['node_ids']),$node_columns);
+//$potential_nodes=$api->GetNodes(array('~node_id'=>$slice['node_ids']),$node_columns);
 
 
-/* TEST PlekitColumns */
+//NEW CODE FOR ENABLING COLUMN CONFIGURATION
 
 //prepare fix and configurable columns
 
@@ -402,133 +427,321 @@ $fix_columns = array();
 $fix_columns[]=array('tagname'=>'hostname', 'header'=>'hostname', 'type'=>'string', 'title'=>'The name of the node');
 $fix_columns[]=array('tagname'=>'peer_id', 'header'=>'AU', 'type'=>'string', 'title'=>'Authority');
 $fix_columns[]=array('tagname'=>'run_level', 'header'=>'ST', 'type'=>'string', 'title'=>'Status');
+$fix_columns[]=array('tagname'=>'node_type', 'header'=>'RES', 'type'=>'string', 'title'=>'Reservable');
 
+// columns that correspond to the visible tags for nodes (*node/ui*)
 $visibletags = new VisibleTags ($api, 'node');
 $visibletags->columns();
 $tag_columns = $visibletags->headers();
 
-$extra_columns = array();
-$extra_columns[]=array('tagname'=>'site_id', 'header'=>'SN', 'type'=>'string', 'title'=>'Site name', 'description'=>'Site name');
+// extra columns that are not tags (for the moment not sorted correctly)
 
-//$configurable_columns = array_merge($tag_columns, $extra_columns);
-//usort ($configurable_columns, create_function('$col1,$col2','return strcmp($col1["header"],$col2["header"]);'));
+$extra_columns = array();
+//$extra_columns[]=array('tagname'=>'site_id', 'header'=>'SN', 'type'=>'string', 'title'=>'Site name', 'description'=>'Site name');
 
+//get user's column configuration
 
 $first_time_configuration = 'false';
-$default_configuration = "hostname:f|ST:f|AU:f|Rw|AST";
+$default_configuration = "hostname:f|ST:f|AU:f|RES:f";
 $column_configuration = "";
-
-$DescTags=$api->GetSliceTags (array('slice_id'=>$slice['slice_id']));
-for ($i=0; $i<count($DescTags); $i++ ) {
-        if ($DescTags [$i]['tagname']=='Configuration'){
-               $column_configuration = $DescTags [$i]['value'];
-                break;
-        }
+$slice_column_configuration = "";
+
+$show_configuration = "reservable:yes";
+$slice_show_configuration = "";
+$show_reservable_message = "";
+
+$PersonTags=$api->GetPersonTags (array('person_id'=>$plc->person['person_id']));
+//print_r($PersonTags);
+foreach ($PersonTags as $ptag) {
+       if ($ptag['tagname'] == 'columnconf')
+       {
+                $column_configuration = $ptag['value'];
+               $conf_tag_id = $ptag['person_tag_id'];
+       }
+       if ($ptag['tagname'] == 'showconf')
+       {
+                $show_configuration = $ptag['value'];
+               $show_tag_id = $ptag['person_tag_id'];
+       }
 }
 
+//print("<br>person column configuration = ".$column_configuration);
+
+$sliceconf_exists = false;
 if ($column_configuration == "")
 {
-       $first_time_configuration = 'true';
-       $column_configuration = $default_configuration;
+       $column_configuration = $slice_id.";";
+       $sliceconf_exists = true;
+}
+else {
+       $slice_conf = explode(";",$column_configuration);
+       for ($i=0; $i<count($slice_conf); $i++ ) {
+               if ($slice_conf[$i] == $slice_id)
+               {
+                       $i++;
+                       $slice_column_configuration = $slice_conf[$i];
+                       $sliceconf_exists = true;
+                       break;
+               }
+               else
+               {
+                       $i++;
+                       $slice_column_configuration = $slice_conf[$i];
+               }
+       }        
 }
 
-//print("<p>GOT CONFIGURATION: ".$column_configuration);
+if ($sliceconf_exists == false)
+       $column_configuration = $column_configuration.";".$slice_id.";";
+
+//print("<br>slice configuration = ".$slice_column_configuration);
 
-//$test_configuration = "hostname:f|AU:f|ST:f|Rw|AST";
-//print("<p>Parsing configuration ".$test_configuration);
+//instantiate the column configuration class, which prepares the headers array
 
+if ($slice_column_configuration == "")
+       $full_configuration = $default_configuration;
+else
+       $full_configuration = $default_configuration."|".$slice_column_configuration;
 
-$ConfigureColumns =new PlekitColumns($column_configuration, $fix_columns, $tag_columns, $extra_columns);
+$ConfigureColumns =new PlekitColumns($full_configuration, $fix_columns, $tag_columns, $extra_columns);
 
-$node_requested_data = $ConfigureColumns->node_tags();
-$nodes=$api->GetNodes(array('node_id'=>$slice['node_ids']),$node_requested_data);
-$potential_nodes=$api->GetNodes(array('~node_id'=>$slice['node_ids']),$node_requested_data);
+$node_columns = $ConfigureColumns->node_tags();
+//print_r($node_columns);
+$all_nodes=$api->GetNodes(NULL,$node_columns);
 
-//$nodes = array();
-//$potential_nodes = array();
+//print("<br>person show configuration = ".$show_configuration);
 
-//print("<p>RESULTS for ".print_r(array('~node_id'=>$slice['node_ids'])));
-//print_r($nodes);
+$show_conf = explode(";",$show_configuration);
+for ($i=0; $i<count($show_conf); $i++ ) {
+                $i++;
+                $slice_show_configuration = $show_conf[$i];
+}        
+$reservable_value = explode(":", $slice_show_configuration);
+       if ($reservable_value[0]=="reservable" && $reservable_value[1] == "no")
+               $show_reservable_message = "display:none";
 
-$count=count($nodes);
+//print("<br>slice show configuration = ".$slice_show_configuration);
 
-$toggle=new PlekitToggle ('my-slice-nodes',"$count nodes",
+$slice_nodes=array();
+$potential_nodes=array();
+$reservable_nodes=array();
+foreach ($all_nodes as $node) {
+  if (in_array($node['node_id'],$slice['node_ids'])) {
+    $slice_nodes[]=$node;
+    if ($node['node_type']=='reservable') $reservable_nodes[]=$node;
+  } else {
+    $potential_nodes[]=$node;
+  }
+}
+if ($profiling) plc_debug_prof('5: nodes',count($slice_nodes));
+////////////////////
+// outline the number of reservable nodes
+$nodes_message=count_english($slice_nodes,"node");
+if (count($reservable_nodes)) $nodes_message .= " (" . count($reservable_nodes) . " reservable)";
+$toggle=new PlekitToggle ('my-slice-nodes',$nodes_message,
                          array('bubble'=>
                                'Manage nodes attached to this slice',
                                'visible'=>get_arg('show_nodes',false)));
 $toggle->start();
 
+////////// show a notice to people having attached a reservable node
+if (count($reservable_nodes) && $privileges) {
+  $mark=reservable_mark();
+  print <<<EOF
+<div id='note_reservable_div' style="align:center; border : solid 2px red; padding:4px; width:800px; $show_reservable_message">
+<table align=center><tr><td valign=top>
+You have attached one or more <span class='bold'>reservable nodes</span> to your slice. 
+Reservable nodes show up with the '$mark' mark. 
+Your slivers will be available <span class='bold'>only during timeslots
+where you have obtained leases</span>. 
+You can manage your leases in the tab below.
+<br>
+Please note that as of August 2010 this feature is experimental. 
+Feedback is appreciated at <a href="mailto:devel@planet-lab.org">devel@planet-lab.org</a>
+</td><td valign=top><span onClick=closeShowReservable()><img class='reset' src="/planetlab/icons/clear.png" alt="hide message"></span>
+</td></tr></table>
+</div>
+EOF;
+}  
+
+//////////////////// reservable nodes area
+$count=count($reservable_nodes);
+if ($count && $privileges) {
+  // having reservable nodes in white lists looks a bit off scope for now...
+  $toggle_nodes=new PlekitToggle('my-slice-nodes-reserve',
+                                "Leases - " . count($reservable_nodes) . " reservable node(s)",
+                                array('visible'=>get_arg('show_nodes_resa',false)));
+  $toggle_nodes->start();
+  $grain=$api->GetLeaseGranularity();
+  if ($profiling) plc_debug_prof('6 granul',$grain);
+  // where to start from, expressed as an offset in hours from now
+  $resa_offset=$_GET['resa_offset'];
+  if ( ! $resa_offset ) $resa_offset=0;
+  $rough_start=time()+$resa_offset*3600;
+  // xxx should be configurable
+  $resa_slots=$_GET['resa_slots'];
+  if ( ! $resa_slots ) $resa_slots = 36;
+  // for now, show the next 72 hours, or 72 grains, which ever is smaller
+  $duration=$resa_slots*$grain;
+  $steps=$duration/$grain;
+  $start=intval($rough_start/$grain)*$grain;
+  $end=$rough_start+$duration;
+  $lease_columns=array('lease_id','name','t_from','t_until','hostname','name');
+  $leases=$api->GetLeases(array(']t_until'=>$rough_start,'[t_from'=>$end,'-SORT'=>'t_from'),$lease_columns);
+  if ($profiling) plc_debug_prof('7 leases',count($leases));
+  // hash nodes -> leases
+  $host_hash=array();
+  foreach ($leases as $lease) {
+    $hostname=$lease['hostname'];
+    if ( ! $host_hash[$hostname] ) {
+       $host_hash[$hostname]=array();
+    }
+    // resync within the table
+    $lease['nfrom']=($lease['t_from']-$start)/$grain;
+    $lease['nuntil']=($lease['t_until']-$start)/$grain;
+    $host_hash[$hostname] []= $lease;
+  }
+  # leases_data is the name used by leases.js to locate this table
+  echo "<table id='leases_data'>";
+  # pass (slice_id,slicename) as the [0,0] coordinate as thead>tr>td
+  echo "<thead><tr><td>" . $slice['slice_id'] . '&' . $slice['name'] . "</td>";
+  # the timeslot headers read (timestamp,label)
+  $day_names=array('Su','M','Tu','W','Th','F','Sa');
+  for ($i=0; $i<$steps; $i++) {
+    $timestamp=($start+$i*$grain);
+    $day=$day_names[intval(strftime("%w",$timestamp))];
+    $label=$day . strftime(" %H:%M",$timestamp);
+    // expose in each header cell the full timestamp, and how to display it - use & as a separator*/
+    echo "<th>" . implode("&",array($timestamp,$label)) . "</th>";
+  }
+  echo "</tr></thead><tbody>";
+  // todo - sort on hostnames
+  function sort_hostname ($a,$b) { return ($a['hostname']<$b['hostname'])?-1:1;}
+  usort($reservable_nodes,sort_hostname);
+  foreach ($reservable_nodes as $node) {
+    echo "<tr><th scope='row'>". $node['hostname'] . "</th>";
+    $hostname=$node['hostname'];
+    $leases=$host_hash[$hostname];
+    $counter=0;
+    while ($counter<$steps) {
+      if ($leases && ($leases[0]['nfrom']<=$counter)) {
+       $lease=array_shift($leases);
+       /* nicer display, merge two consecutive leases for the same slice 
+          avoid doing that for now, as it might makes things confusing */
+       /* while ($leases && ($leases[0]['name']==$lease['name']) && ($leases[0]['nfrom']==$lease['nuntil'])) {
+         $lease['nuntil']=$leases[0]['nuntil'];
+         array_shift($leases);
+         }*/
+       $duration=$lease['nuntil']-$counter;
+       echo "<td colspan='$duration'>" . $lease['lease_id'] . '&' . $lease['name'] . "</td>";
+       $counter=$lease['nuntil']; 
+      } else {
+       echo "<td></td>";
+       $counter+=1;
+      }
+    }
+    echo "</tr>";
+  }
+  echo "</tbody></table>\n";
 
-$toggle_nodes=new PlekitToggle('my-slice-nodes-configuration',
-                              "Node table column configuration",
-                              array('visible'=>'1'));
+  // the general layout for the scheduler
+  echo <<< EOF
+<div id='leases_area'></div>
 
-$toggle_nodes->start();
+<div id='leases_buttons'>
+  <button id='leases_clear' type='submit'>Clear</button>
+  <button id='leases_submit' type='submit'>Submit</button>
+</div>
+EOF;
 
+  $toggle_nodes->end();
+ }
 
-//usort ($table_headers, create_function('$col1,$col2','return strcmp($col1["header"],$col2["header"]);'));
 
-//print("<p>HEADERS TO SHOW<p>");
-//print_r($headersToShow);
+//////////////////// node configuration panel
 
+$toggle_nodes=new PlekitToggle('my-slice-nodes-configuration',
+                               "Node table layout",
+                               array('visible'=>'1'));
+$toggle_nodes->start();
+
+//usort ($table_headers, create_function('$col1,$col2','return strcmp($col1["header"],$col2["header"]);'));
 //print("<p>TABLE HEADERS<p>");
 //print_r($table_headers);
 
 print("<div id='debug'></div>");
 print("<input type='hidden' id='slice_id' value='".$slice['slice_id']."' />");
-print("<input type='hidden' size='80' id='column_configuration' value='".$column_configuration."' />");
-print("<input type='hidden' id='previousConf' value='".$column_configuration."'></input>");
+print("<input type='hidden' id='person_id' value='".$plc->person['person_id']."' />");
+print("<input type='hidden' id='conf_tag_id' value='".$conf_tag_id."' />");
+print("<input type='hidden' id='show_tag_id' value='".$show_tag_id."' />");
+print("<input type='hidden' id='column_configuration' value='".$slice_column_configuration."' />");
+print("<br><input type='hidden' size=80 id='full_column_configuration' value='".$column_configuration."' />");
+print("<input type='hidden' id='previousConf' value='".$slice_column_configuration."'></input>");
 print("<input type='hidden' id='defaultConf' value='".$default_configuration."'></input>");
-//print("<input type='button' id='testFunctions' onclick=\"highlightOption('AU')\" value='test'></input>");
-
-$ConfigureColumns->javascript_vars();
 
 $ConfigureColumns->configuration_panel_html(true);
 
-print("<div align='center' id='loadingDiv'></div>");
+$ConfigureColumns->javascript_init();
 
 $toggle_nodes->end();
 
 
-////////// nodes currently in
-
-$count=count($nodes);
 
+//////////////////// nodes currently in
 $toggle_nodes=new PlekitToggle('my-slice-nodes-current',
-                              "$count nodes currently in $name",
+                              count_english($slice_nodes,"node") . " currently in $name",
                               array('visible'=>get_arg('show_nodes_current',!$privileges)));
-
 $toggle_nodes->start();
 
+$headers=array();
+$notes=array();
+//$notes=array_merge($notes,$visibletags->notes());
+$notes [] = "For information about the different columns please see the <b>node table layout</b> tab above";
+
+/*
+$headers['peer']='string';
+$headers['hostname']='string';
+$short="-S-"; $long=Node::status_footnote(); $type='string'; 
+       $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
+$short=reservable_mark(); $long=reservable_legend(); $type='string';
+       $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
+// the extra tags, configured for the UI
+$headers=array_merge($headers,$visibletags->headers());
+
+if ($privileges) $headers[plc_delete_icon()]="none";
+*/
+
 $edit_header = array();
 if ($privileges) $edit_header[plc_delete_icon()]="none";
+$headers = array_merge($ConfigureColumns->get_headers(),$edit_header);
 
-$table_options = array('search_width'=>15,
-                       'pagesize'=>20);
-//$table=new PlekitTable2('nodes',$headers,'1',$table_options);
-//$table=new PlekitTable2('nodes_pairwise',array_merge($ConfigureColumns->plekit_columns_get_headers(),$edit_header),NULL,$headersToShow, $table_option);
-//$headersToShow = $ConfigureColumns->plekit_columns_visible();
+//print("<p>HEADERS<p>");
+//print_r($headers);
 
-$table=new PlekitTable2('nodes',array_merge($ConfigureColumns->get_headers(),$edit_header),NULL,NULL, $table_option); 
+$table_options = array('notes'=>$notes,
+                       'search_width'=>15,
+                       'pagesize'=>20,
+                       'configurable'=>true);
+
+$table=new PlekitTable('nodes',$headers,NULL,$table_options);
 
 $form=new PlekitForm(l_actions(),array('slice_id'=>$slice['slice_id']));
 $form->start();
 $table->start();
-if ($nodes) foreach ($nodes as $node) {
+if ($slice_nodes) foreach ($slice_nodes as $node) {
   $table->row_start();
 
-  $table->cell($node['node_id'], array('display'=>'none'));
-  $table->cell(l_node_obj($node));
+$table->cell($node['node_id'], array('display'=>'none'));
 
+  $table->cell(l_node_obj($node));
   $peers->cell($table,$node['peer_id']);
   $run_level=$node['run_level'];
   list($label,$class) = Node::status_label_class_($node);
-  $table->cell ($label,array('name'=>'ST', 'class'=>$class, 'display'=>'table-cell'));
-
-$ConfigureColumns->cells($table, $node);
-
+  $table->cell ($label,array('class'=>$class));
+  $table->cell( ($node['node_type']=='reservable')?reservable_mark():"" );
 
+ //foreach ($visiblecolumns as $tagname) $table->cell($node[$tagname]);
+ $ConfigureColumns->cells($table, $node);
 
   if ($privileges) $table->cell ($form->checkbox_html('node_ids[]',$node['node_id']));
   $table->row_end();
@@ -547,7 +760,7 @@ if ($privileges) {
 $table->end();
 $toggle_nodes->end();
 
-////////// nodes to add
+//////////////////// nodes to add
 if ($privileges) {
   $new_potential_nodes = array();
   if ($potential_nodes) foreach ($potential_nodes as $node) {
@@ -560,37 +773,52 @@ if ($privileges) {
 
   $count=count($potential_nodes);
   $toggle_nodes=new PlekitToggle('my-slice-nodes-add',
-                                "$count more nodes available",
+                                count_english($potential_nodes,"more node") . " available",
                                 array('visible'=>get_arg('show_nodes_add',false)));
   $toggle_nodes->start();
 
-  if ( $potential_nodes ) {
-    // xxx improve style
-    echo "<p class='not-relevant'>No node to add</p>";
-  } else {
+  if ( $potential_nodes ) {
+    $headers=array();
+    $notes=array();
+
 
-    $edit_header = array();
-    if ($privileges) $edit_header['+']="none";
+/*
+    $headers['peer']='string';
+    $headers['hostname']='string';
+    $short="-S-"; $long=Node::status_footnote(); $type='string'; 
+       $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
+       $short=reservable_mark(); $long=reservable_legend(); $type='string';
+       $headers[$short]=array('type'=>$type,'title'=>$long); $notes []= "$short = $long";
+    // the extra tags, configured for the UI
+    $headers=array_merge($headers,$visibletags->headers());
+    $headers['+']="none";
+*/
+
+    $add_header = array();
+    $add_header['+']="none";
+    $headers = array_merge($ConfigureColumns->get_headers(),$add_header);
+
+    //$notes=array_merge($notes,$visibletags->notes());
+    $notes [] = "For information about the different columns please see the <b>node table layout</b> tab above";
     
-    //$table=new PlekitTable2('add_nodes',$headers,'1', $table_options);
-    $table=new PlekitTable2('add_nodes',array_merge($ConfigureColumns->get_headers(), $edit_header),NULL,$headersToShow, $table_options);
+    $table=new PlekitTable('add_nodes',$headers,NULL, $table_options);
     $form=new PlekitForm(l_actions(),
                         array('slice_id'=>$slice['slice_id']));
     $form->start();
     $table->start();
-
     if ($potential_nodes) foreach ($potential_nodes as $node) {
        $table->row_start();
 
-  $table->cell($node['node_id'], array('display'=>'none'));
-  $table->cell(l_node_obj($node));
+$table->cell($node['node_id'], array('display'=>'none'));
 
-  $peers->cell($table,$node['peer_id']);
-  $run_level=$node['run_level'];
-  list($label,$class) = Node::status_label_class_($node);
-  $table->cell ($label,array('name'=>'ST', 'class'=>$class, 'display'=>'table-cell'));
+       $table->cell(l_node_obj($node));
+       $peers->cell($table,$node['peer_id']);
+       list($label,$class) = Node::status_label_class_($node);
+       $table->cell ($label,array('class'=>$class));
+       $table->cell( ($node['node_type']=='reservable')?reservable_mark():"" );
 
-$ConfigureColumns->cells($table, $node);
+       //foreach ($visiblecolumns as $tagname) $table->cell($node[$tagname]);
+       $ConfigureColumns->cells($table, $node);
 
        $table->cell ($form->checkbox_html('node_ids[]',$node['node_id']));
        $table->row_end();
@@ -606,11 +834,15 @@ $ConfigureColumns->cells($table, $node);
   }
   $toggle_nodes->end();
 }
+
 $toggle->end();
 
+// very wide values get abbreviated
+$tag_value_threshold=24;
 //////////////////////////////////////////////////////////// Tags
 //if ( $local_peer ) {
   $tags=$api->GetSliceTags (array('slice_id'=>$slice_id));
+  if ($profiling) plc_debug_prof('8 slice tags',count($tags));
   function get_tagname ($tag) { return $tag['tagname'];}
   $tagnames = array_map ("get_tagname",$tags);
   
@@ -627,7 +859,7 @@ $toggle->end();
   if ($tags_privileges) $headers[plc_delete_icon()]="none";
   
   $table_options=array("notes_area"=>false,"pagesize_area"=>false,"search_width"=>10);
-  $table=new PlekitTable2("slice_tags",$headers,'0',NULL,$table_options);
+  $table=new PlekitTable("slice_tags",$headers,'0',$table_options);
   $form=new PlekitForm(l_actions(),
                        array('slice_id'=>$slice['slice_id']));
   $form->start();
@@ -636,23 +868,26 @@ $toggle->end();
     foreach ($tags as $tag) {
       $node_name = "ALL";
       if ($tag['node_id']) {
-        $nodes = $api->GetNodes(array('node_id'=>$tag['node_id']));
-        if($nodes) {
-          $node = $nodes[0];
+        $tag_nodes = $api->GetNodes(array('node_id'=>$tag['node_id']));
+       if ($profiling) plc_debug_prof('9 node for slice tag',count($tag_nodes));
+        if($tag_nodes) {
+          $node = $tag_nodes[0];
           $node_name = $node['hostname'];
         }
       }
       $nodegroup_name="n/a";
       if ($tag['nodegroup_id']) { 
-        $nodegroup=$api->GetNodeGroups(array('nodegroup_id'=>$tag['nodegroup_id']));
+        $nodegroups=$api->GetNodeGroups(array('nodegroup_id'=>$tag['nodegroup_id']));
+       if ($profiling) plc_debug_prof('10 nodegroup for slice tag',$nodegroup);
         if ($nodegroup) {
-          $nodegroup = $nodegroup[0];
+          $nodegroup = $nodegroups[0];
           $nodegroup_name = $nodegroup['groupname'];
         }
       }
       $table->row_start();
       $table->cell(l_tag_obj($tag));
-      $table->cell($tag['value']);
+      // very wide values get abbreviated
+      $table->cell(truncate_and_popup($tag['value'],$tag_value_threshold));
       $table->cell($node_name);
       $table->cell($nodegroup_name);
       if ($tags_privileges) $table->cell ($form->checkbox_html('slice_tag_ids[]',$tag['slice_tag_id']));
@@ -671,18 +906,19 @@ $toggle->end();
       return array("display"=>$tag['tagname'],"value"=>$tag['tag_type_id']);
     }
     $all_tags= $api->GetTagTypes( array ("category"=>"slice*","-SORT"=>"+tagname"), array("tagname","tag_type_id"));
+    if ($profiling) plc_debug_prof('11 tagtypes',count($all_tags));
     $selector_tag=array_map("tag_selector",$all_tags);
     
     function node_selector($node) { 
       return array("display"=>$node["hostname"],"value"=>$node['node_id']);
     }
-    $all_nodes = $api->GetNodes( array ("node_id" => $slice['node_ids']), array("hostname","node_id"));
-    $selector_node=array_map("node_selector",$all_nodes);
+    $selector_node=array_map("node_selector",$slice_nodes);
     
     function nodegroup_selector($ng) {
       return array("display"=>$ng["groupname"],"value"=>$ng['nodegroup_id']);
     }
     $all_nodegroups = $api->GetNodeGroups( array("groupname"=>"*"), array("groupname","nodegroup_id"));
+    if ($profiling) plc_debug_prof('13 nodegroups',count($all_nodegroups));
     $selector_nodegroup=array_map("nodegroup_selector",$all_nodegroups);
     
     $table->cell($form->select_html("tag_type_id",$selector_tag,array('label'=>"Choose Tag")));
@@ -706,257 +942,9 @@ if ($local_peer ) {
 
 $peers->block_end($peer_id);
 
+if ($profiling) plc_debug_prof_end();
+
 // Print footer
 include 'plc_footer.php';
 
 ?>
-
-
-<script type="text/javascript">
-
-var sourceComon = '<a target="source_window" href="http://comon.cs.princeton.edu/">CoMoN</a>';
-var sourceTophat = '<b><a target="source_window" href="http://www.top-hat.info/">TopHat</a></b>';
-var sourceTophatAPI = '<b><a target="source_window" href="http://www.top-hat.info/API/">TopHat API</a></b>';
-var sourceMySlice = '<b><a target="source_window" href="http://myslice.info/">MySlice</a></b>';
-var sourceCymru = '<b><a target="source_window" href="http://www.team-cymru.org/">Team Cymru</a></b>';
-var sourceMyPLC = '<b><a target="source_window" href="http://www.planet-lab.eu/PLCAPI/">MyPLC API</a></b>';
-var sourceManiacs = '<b><a target="source_window" href="http://www.ece.gatech.edu/research/labs/MANIACS/as_taxonomy/">MANIACS</a></b>';
-var sourceMonitor = '<b><a target="source_window" href="http://monitor.planet-lab.org/">Monitor</a></b>';
-var selectReferenceNode ='Select reference node: <select id="reference_node" onChange="updateDefaultConf(this.value)"><option value=planetlab-europe-07.ipv6.lip6.fr>planetlab-europe-07.ipv6.lip6.fr</option></select>';
-var addButton = '<input id="addButton" type="button" value="Add" onclick=addColumnAjax(document.getElementById("list1").value)></input>';
-var deleteButton = '<input id="deleteButton" type="button" value="Delete" onclick=deleteColumn(window.document.getElementById("list1").value)></input>';
-
-var titleAU = 'Authority';
-var detailAU = '<i>The authority of the global PlanetLab federation that the site of the node belongs to.</i>';
-var valuesAU = 'Values: <b>PLC</b> (PlanetLab Central), <b>PLE</b> (PlanetLab Europe)';
-var sourceAU = '<b>Source:</b> '+sourceMyPLC;
-var descAU = '<span class="myslice title">'+titleAU+'</span><p>'+detailAU+'<p>'+valuesAU+'<p>'+sourceAU;
-
-var descHOSTNAME = "test";
-
-
-var titleAS = 'Autonomous system ID';
-var sourceAS = 'Source: '+sourceCymru+' (via '+sourceTophat+')';
-var valuesAS = 'Unit: <b>Integer between 0 and 65535</b>';
-var descAS = '<span class="myslice title">'+titleAS+'</span><p>'+valuesAS+'<p>' + sourceAS;
-
-var titleAST = 'Autonomous system type';
-var sourceAST = 'Source: '+sourceManiacs;
-var valuesAST = 'Values: <b>t1</b> (tier-1), <b>t2</b> (tier-2), <b>edu</b> (university), <b>comp</b> (company), <b>nic</b> (network information center), <b>ix</b> (IXP), <b>n/a</b>';
-var descAST = '<span class="myslice title">'+titleAST+'</span><p>'+valuesAST+'<p>'+sourceAST;
-
-var titleASN = 'Autonomous system name';
-var sourceASN = 'Source: '+sourceTophat;
-var descASN = '<span class="myslice title">'+titleASN+'</span><p>'+sourceASN;
-
-var selectPeriodBU = 'Select period: <select id="selectperiodBU" onChange=updatePeriod("BU")><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
-var titleBU = 'Bandwidth utilization ';
-var sourceBU = 'Source: '+sourceComon+' (via '+sourceMySlice+')';
-var valuesBU ='Unit: <b>Kbps</b>';
-var detailBU = '<i>The average Transmited bandwidh (Tx) over the selected period. The period is the most recent for which data is available, with CoMoN data being collected by MySlice daily.</i>'
-var descBU = '<span class="myslice title">'+titleBU+'</span><p>'+detailBU+'<p>'+selectPeriodBU+'<p>'+valuesBU+'<p>'+sourceBU; 
-
-var titleBW= 'Bandwidth limit';
-var sourceBW = 'Source: '+sourceComon;
-var valuesBW = 'Unit: <b>Kbps</b>';
-var detailBW = '<i>The bandwidth limit is a cap on the total outbound bandwidth usage of a node. It is set by the site administrator (PI). For more details see <a href="http://www.planet-lab.org/doc/BandwidthLimits">Bandwidth Limits (planet-lab.org)</a></i>';
-var descBW = '<span class="myslice title">'+titleBW+'</span><p>'+detailBW+'<p>'+valuesBW+'<p>'+sourceBW;
-
-var titleCC = 'Number of CPU cores';
-var sourceCC = 'Source: '+sourceComon;
-var valuesCC = 'Current PlanetLab hardware requirements: 4 cores min. <br><i>(Older nodes may have fewer cores)</i>';
-var descCC = '<span class="myslice title">'+titleCC+'</span><p>'+valuesCC+'<p>'+sourceCC;
-
-var titleCN = 'Number of CPUs';
-var sourceCN = 'Source: '+sourceComon;
-var valuesCN = 'Current PlanetLab hardware requirements: <b>1 (if quad core) or 2 (if dual core)</b>';
-var descCN = '<span class="myslice title">'+titleCN+'</span><p>'+valuesCN+'<p>'+sourceCN;
-
-var titleCR = 'CPU clock rate';
-var sourceCR = 'Source: '+sourceComon;
-var valuesCR = 'Unit: <b>GHz</b><p>Current PlanetLab hardware requirements: <b>2.4 GHz</b>';
-var descCR = '<span class="myslice title">'+titleCR+'</span><p>'+valuesCR+'<p>'+sourceCR;
-
-var selectPeriodCF = 'Select period: <select id="selectperiodCF" onChange=updatePeriod("CF")><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
-var titleCF = 'Free CPU';
-var sourceCF = 'Source: '+sourceComon+' (via '+sourceMySlice+')';
-var valuesCF = 'Unit: <b>%</b>';
-var detailCF = '<i> The average CPU percentage that could be allocated by a test slice (burb) run periodically by CoMoN </i>';
-var descCF = '<span class="myslice title">'+titleCF+'</span><p>'+detailCF+'<p>'+selectPeriodCF+'<p>'+valuesCF+'<p>'+sourceCF; 
-
-var titleDS = 'Disk size';
-var sourceDS = 'Source: '+sourceComon;
-var valuesDS = 'Unit: <b>GB</b><p>Current PlanetLab hardware requirements: <b>500GB</b>';
-var descDS = '<span class="myslice title">'+titleDS+'</span><p>'+valuesDS+'<p>'+sourceDS;
-
-var titleDU = 'Current disk utilization';
-var sourceDU = 'Source: '+sourceComon+' (via '+sourceMySlice+')';
-var valuesDU = 'Unit: <b>GB</b>';
-var detailDU = '<i> The amount of disk space currently consumed (checked daily) </i>';
-var descDU = '<span class="myslice title">'+titleDU+'</span><p>'+detailDU+'<p>'+valuesDU+'<p>'+sourceDU;
-
-var titleHC = 'Hop count from a reference node';
-var sourceHC = 'Source: '+sourceTophat;
-var detailHC = '<i>TopHat conducts traceroutes every five minutes in a full mesh between all PlanetLab nodes. The hop count is the length of the traceroute from the node to the reference node, based upon the most recently reported traceroute</i>.';
-var descHC = '<span class="myslice title">'+titleHC+'</span><p>'+detailHC+'<p>'+selectReferenceNode+'<p>'+sourceHC;
-
-var titleIP = 'IP address';
-var sourceIP = 'Source: '+sourceTophat;
-var descIP = '<span class="myslice title">'+titleIP+'</span><p>'+sourceIP;
-
-var selectPeriodL = 'Select period: <select id="selectperiodL" onChange=updatePeriod("L")><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
-var titleL= 'Load ';
-var sourceL = 'Source: '+sourceComon;
-var valuesL = 'Unit: <b>float</b>';
-var detailL = '<i>The average 5-minute Unix load (as reported by the uptime command) over the selected period</i>';
-var descL = '<span class="myslice title">'+titleL+'</span><p>'+detailL+'<p>'+selectPeriodL+'<p>'+valuesL+'<p>'+sourceL; 
-
-var titleLON= 'Longitude';
-var sourceLON = 'Source: '+sourceTophat;
-var descLON = '<span class="myslice title">'+titleLON+'</span><p>'+sourceLON;
-
-var titleLAT= 'Latitude';
-var sourceLAT = 'Source: '+sourceTophat;
-var descLAT = '<span class="myslice title">'+titleLAT+'</span><p>'+sourceLAT;
-
-var titleLCN= 'Location (Country)';
-var sourceLCN = 'Source: '+sourceTophat;
-var detailLCN = '<i>Based on the latitude, longitude information</i>';
-var descLCN = '<span class="myslice title">'+titleLCN+'</span><p>'+detailLCN+'<p>'+sourceLCN;
-
-var titleLCT= 'Location (Continent)';
-var sourceLCT = 'Source: '+sourceTophat;
-var detailLCT = '<i>Based on the latitude, longitude information</i>';
-var descLCT = '<span class="myslice title">'+titleLCT+'</span><p>'+detailLCT+'<p>'+sourceLCT;
-
-var titleLCY= 'Location (City)';
-var sourceLCY = 'Source: '+sourceTophat;
-var detailLCY = '<i>Based on the latitude, longitude information</i>';
-var descLCY = '<span class="myslice title">'+titleLCY+'</span><p>'+detailLCY+'<p>'+sourceLCY;
-
-var titleLPR= 'Location precision radius';
-var sourceLPR = 'Source: '+sourceTophat;
-var valuesLPR = 'Unit: <b>float</b>';
-var detailLPR = '<i>The radius of the circle corresponding to the error in precision of the geolocalization</i>';
-var descLPR = '<span class="myslice title">'+titleLPR+'</span><p>'+detailLPR+'<p>'+valuesLPR+'<p>'+sourceLPR;
-
-var titleLRN= 'Location (Region)';
-var sourceLRN = 'Source: '+sourceTophat;
-var detailLRN = '<i>Based on the latitude, longitude information</i>';
-var descLRN = '<span class="myslice title">'+titleLRN+'</span><p>'+detailLRN+'<p>'+sourceLRN;
-
-var titleMS= 'Memory size';
-var sourceMS = 'Source: '+sourceComon;
-var valuesMS = 'Unit: <b>GB</b><p>Current PlanetLab hardware requirements: <b>4GB</b>';
-var descMS = '<span class="myslice title">'+titleMS+'</span><p>'+valuesMS+'<p>'+sourceMS;
-
-var selectPeriodMU = 'Select period: <select id="selectperiodMU" onChange=updatePeriod("MU")><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
-var titleMU = 'Memory utilization';
-var sourceMU = 'Source: '+sourceComon;
-var valuesMU = '<p>Unit: <b>%</b>';
-var detailMU = '<i>The average active memory utilization as reported by CoMoN</i>';
-var descMU = '<span class="myslice title">'+titleMU+'</span><p>'+detailMU+'<p>'+selectPeriodMU+'<p>'+valuesMU+'<p>'+sourceMU; 
-
-var titleNEC= 'Network information (ETOMIC)';
-var sourceNEC = 'Source: '+sourceTophat;
-var valuesNEC = 'Values: <b>yes/no</b>';
-var detailNEC = '<i>The existence of a colocated ETOMIC box. When an ETOMIC box is present you have the possibility to conduct high-precision measurements through the '+sourceTophatAPI+'</i>';
-var descNEC = '<span class="myslice title">'+titleNEC+'</span><p>'+detailNEC+'<p>'+valuesNEC+'<p>'+sourceNEC;
-
-var titleNTH= 'Network information (TopHat)';
-var sourceNTH = 'Source: '+sourceTophat;
-var valuesNTH = 'Values: <b>yes/no</b>';
-var detailNTH = '<i>The existence of a colocated TopHat agent. When a TopHat agent is present you have the possibility to conduct high-precision measurements through the '+sourceTophatAPI+'</i>';
-var descNTH = '<span class="myslice title">'+titleNTH+'</span><p>'+detailNTH+'<p>'+valuesNTH+'<p>'+sourceNTH;
-
-var titleNDS= 'Network information (DIMES)';
-var sourceNDS = 'Source: '+sourceTophat;
-var valuesNDS = 'Values: <b>yes/no</b>';
-var detailNDS = '<i>The existence of a colocated DIMES agent. When a DIMES agent is present you have the possibility to conduct high-precision measurements through the '+sourceTophatAPI+'</i>';
-var descNDS = '<span class="myslice title">'+titleNDS+'</span><p>'+detailNDS+'<p>'+valuesNDS+'<p>'+sourceNDS;
-
-var titleNSF= 'Network information (spoof)';
-var sourceNSF = 'Source: '+sourceTophat;
-var valuesNSF = '<p>Values: <b>yes/no</b>';
-var detailNSF = '<i> Whether the node can send packets packets using the IP spoof option</i>';
-var descNSF = '<span class="myslice title">'+titleNSF+'</span><p>'+detailNSF+'<p>'+valuesNSF+'<p>'+sourceNSF;
-
-var titleNSR= 'Network information (source route)';
-var sourceNSR = 'Source: '+sourceTophat;
-var valuesNSR = '<p>Values: <b>yes/no</b>';
-var detailNSR = '<i> Whether the node can send packets packets using the IP source route option</i>';
-var descNSR = '<span class="myslice title">'+titleNSR+'</span><p>'+detailNSR+'<p>'+valuesNSR+'<p>'+sourceNSR;
-
-var titleNTP= 'Network information (timestamp)';
-var sourceNTP = 'Source: '+sourceTophat;
-var valuesNTP = '<p>Values: <b>yes/no</b>';
-var detailNTP = '<i> Whether the node can send packets packets using the IP timestamp option</i>';
-var descNTP = '<span class="myslice title">'+titleNTP+'</span><p>'+detailNTP+'<p>'+valuesNTP+'<p>'+sourceNTP;
-
-var titleNRR= 'Network information (record route)';
-var sourceNRR = 'Source: '+sourceTophat;
-var valuesNRR = '<p>Values: <b>yes/no</b>';
-var detailNRR = '<i> Whether the node can send packets packets using the IP record route option</i>';
-var descNRR = '<span class="myslice title">'+titleNRR+'</span><p>'+detailNRR+'<p>'+valuesNRR+'<p>'+sourceNRR;
-
-var titleOS = 'Operating system';
-var sourceOS = 'Source: '+sourceMyPLC;
-var valuesOS = 'Values: <b>Fedora, Cent/OS, other, n/a</b>';
-var descOS = '<span class="myslice title">'+titleOS+'</span><p>'+valuesOS+'<p>'+sourceOS;
-
-var selectPeriodR = 'Select period: <select id="selectperiodR" onChange=updatePeriod("R")><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
-var titleR = 'Reliability';
-var sourceR = 'Source: '+sourceComon+' (via '+sourceMySlice+')';
-var detailR = '<i>CoMoN queries nodes every 5 minutes, for 255 queries per day. The average reliability is the percentage of queries over the selected period for which CoMoN reports a value. The period is the most recent for which data is available, with CoMoN data being collected by MySlice daily</i>';
-var valuesR = 'Unit: <b>%</b>';
-var descR = '<span class="myslice title">'+titleR+'</span><p>'+detailR+'<p>'+selectPeriodR+'<p>'+valuesR+'<p>'+sourceR; 
-
-var titleRES = 'Reservation capabilities';
-var sourceRES = 'Source: '+sourceMyPLC;
-var valuesRES = 'Values: <b>yes/no</b>';
-var detailRES = '<i> Whether the node can be reserved for a certain duration</i>';
-var descRES = '<span class="myslice title">'+titleRES+'</span><p>'+detailRES+'<p>'+valuesRES+'<p>'+sourceRES;
-
-var selectPeriodS = 'Select period: <select id="selectperiodS" onChange=updatePeriod("S")><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
-var titleS = 'Active slices';
-var sourceS = 'Source: '+sourceComon+' (via '+sourceMySlice+')';
-var valuesS = 'Unit: <b>%</b>';
-var detailS = '<i>Average number of active slices over the selected period for which CoMoN reports a value. The period is the most recent for which data is available, with CoMoN data being collected by MySlice daily</i>';
-var descS = '<span class="myslice title">'+titleS+'</span><p>'+detailS+'<p>'+selectPeriodS+'<p>'+valuesS+'<p>'+sourceS; 
-
-var titleSN = 'Site name';
-var sourceSN = 'Source: '+sourceMyPLC;
-var descSN = '<span class="myslice title">'+titleSN+'</span><p>'+sourceSN;
-
-var selectPeriodSSH = 'Select period: <select id="selectperiodSSH" onChange=updatePeriod("SSH")><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
-var titleSSH = 'Average SSH response delay';
-var valuesSSH = 'Unit: <b>%</b>';
-var detailSSH = '<i>The average response delay of the node to SSH logins over the selected period for which CoMoN reports a value. The period is the most recent for which data is available, with CoMoN data being collected by MySlice daily</i>';
-var sourceSSH ='Source: '+sourceComon+' (via '+sourceMySlice+')';
-var descSSH = '<span class="myslice title">'+titleSSH+'</span><p>'+detailSSH+'<p>'+selectPeriodSSH+'<p>'+valuesSSH+'<p>'+sourceSSH; 
-
-var titleST = 'Status';
-var sourceST = 'Source: '+sourceMonitor;
-var valuesST = 'Values: <b>online</b> (up and running), <b>good</b> (up and running recently), <b>offline</b> (unreachable today), <b>down</b> (unreachable nodes for more than 1 day), <b>failboot</b> (safeboot, MyPLC API term for debug)';
-var descST = '<span class="myslice title">'+titleST+'</span><p>'+valuesST+'<p>'+sourceST;
-
-highlightOption("AU");
-overrideTitles();
-
-
-/*
-document.defaultAction = false;
-document.onkeyup = detectEvent;
-
-function detectEvent(e) {
-       var evt = e || window.event;
-       //debugfilter(evt.type);
-       //debugfilter('keyCode is ' + evt.keyCode);
-       //debugfilter('charCode is ' + evt.charCode);
-       //debugfilter(document.getElementById('testfocus').focused);
-       return document.defaultAction;
-}
-*/
-
-
-</script>
diff --git a/plekit/icons/ajax-loader.gif b/plekit/icons/ajax-loader.gif
new file mode 100644 (file)
index 0000000..c69e937
Binary files /dev/null and b/plekit/icons/ajax-loader.gif differ
index 987d9be..d16b128 100644 (file)
@@ -64,11 +64,19 @@ $this->all_headers[$column['header']]=array('header'=>$column['header'],'type'=>
 }
 
 foreach ($this->tag_columns as $column) {
-$this->all_headers[$column['header']]=array('header'=>$column['header'],'type'=>$column['type'],'tagname'=>$column['tagname'],'title'=>$column['tagname'], 'description'=>$column['title'], 'label'=>$this->removeDuration($column['header']),'visible'=>false);
+
+//print("<br>".$column['header'].":".$column['headerId'].":".$column['tagname']);
+
+if ($column['headerId'] != "")
+       $headerId = $column['headerId'];
+else
+       $headerId = $column['header'];
+
+$this->all_headers[$headerId]=array('header'=>$headerId,'type'=>$column['type'],'tagname'=>$column['tagname'],'title'=>$column['title'], 'description'=>$column['title'], 'label'=>$column['header'],'visible'=>false);
 }
 
 foreach ($this->extra_columns as $column) {
-$this->all_headers[$column['header']]=array('header'=>$column['header'],'type'=>$column['type'],'tagname'=>$column['tagname'],'title'=>$column['tagname'], 'description'=>$column['title'], 'label'=>$this->removeDuration($column['header']),'visible'=>false);
+$this->all_headers[$column['header']]=array('header'=>$column['header'],'type'=>$column['type'],'tagname'=>$column['tagname'],'title'=>$column['title'], 'description'=>$column['title'], 'label'=>$column['header'],'visible'=>false);
 }
 
 return $this->all_headers;
@@ -82,6 +90,20 @@ return $this->all_headers;
 
 }
 
+function get_selected_period($label) {
+
+if ($this->all_headers[$label."w"]['visible'])
+       return "w";
+else if ($this->all_headers[$label."m"]['visible'])
+       return "m";
+else if ($this->all_headers[$label."y"]['visible'])
+       return "y";
+else if ($this->all_headers[$label]['visible'])
+       return "";
+       
+return "";
+}
+
 function node_tags() {
 
        $fetched_tags = array('node_id');       
@@ -101,7 +123,7 @@ function print_headers() {
 
        foreach ($this->all_headers as $h)
        {
-               $headers.="<br>".$h['header'].":".$h['label'].":".$h['tagname'];
+               $headers.="<br>".$h['header'].":".$h['label'].":".$h['tagname'].":".$h['visible'];
        }
        return $headers;
 }
@@ -122,11 +144,11 @@ function headerIsVisible($header_name) {
 
 $headersToShow = $this->visible_headers;
 
+if (in_array($header_name, $headersToShow))
+       return true;
 
-       if ($this->inTypeC($header_name."w") || $this->inTypeC($header_name."m") || $this->inTypeC($header_name."y"))
-               return (in_array($header_name."w", $headersToShow) || in_array($header_name."m", $headersToShow) || in_array($header_name."y", $headersToShow));
-       else
-               return in_array($header_name, $headersToShow);
+if ($this->inTypeC($header_name."w"))
+       return (in_array($header_name."w", $headersToShow) || in_array($header_name."m", $headersToShow) || in_array($header_name."y", $headersToShow));
 }
 
 
@@ -267,11 +289,13 @@ function checkThreshold($value, $threshold, $hh) {
 
 function cells($table, $node) {
 
+$this->fetch_data($node);
 
 foreach ($this->all_headers as $h)
 {
+if (!$h['fixed']) { 
 
-if (!$h['fixed'] && $h['visible'])
+if ($h['visible'] != "")
 {
 if ($this->inTypeC($h['header']))
 {
@@ -304,9 +328,9 @@ else
         $table->cell($value,array('name'=>$h['header'], 'display'=>'table-cell'));
 }
 }
-else
+else 
         $table->cell("??", array('name'=>$h['header'], 'display'=>'none'));
-
+}
 }
 
 }
@@ -319,68 +343,106 @@ HTML
 */
 
 
-function javascript_vars() {
+function javascript_init() {
 
 print("<input type='hidden' id='reference_node' value='".$this->reference_node."' />");
 
-$all_columns_string = "";
-foreach ($this->all_headers as $h)
-        $all_columns_string.= $h['header'].",";
-
 print("<script type='text/javascript'>");
+print("highlightOption('AU');");
+print("overrideTitles();");
+print("</script>");
 
-print("var column_table = new Array();"); 
-print ("var column_index=0;");
-print("var column_table2 = new Array();");
-print("var column_headers = new Array();");
-print("var columns_to_fetch = new Array();");
-//document.onkeyup = scrollList('test');
+}
+
+
+
+function quickselect_html() {
+
+//return '<p>This link uses the onclick event handler.<br><a href="#" onclick="setVisible(\'quicklist\');return false" target="_self">Open popup</a></p>';
+
+
+$quickselection = "<select id='quicklist' multiple size=10 onChange=changeSelectStatus(this.value)><option value''>Add/remove columns</option>";
+$prev_label="";
+$optionclass = "out";
 foreach ($this->all_headers as $h)
 {
-/*
-        print("column_table2[column_index] = new Array();");
-        print("column_table2[column_index]['header'] = ".$h['header'].";");
-        print("column_table2[column_index]['label'] = ".$h['label'].";");
-        if ($h['visible'])
+       if ($h['header'] == "hostname")
+               continue;
+
+       if ($h['fixed'])
+               $disabled = "disabled=true";
+       else
+               $disabled = "";
+
+        if ($this->headerIsVisible($h['label']))
        {
-        print("column_table2[column_index]['visible'] = true;");
-        print("column_table2[column_index]['fetched'] = true;");
+                       $optionclass = "in";
+               //$selected = "selected=selected";
        }
-        else
+       else
        {
-        print("column_table2[column_index]['visible'] = false;");
-        print("column_table2[column_index]]['fetch'] = false;");
+                       $optionclass = "out";
+               //$selected = "";
        }
-        print("column_table2[column_index]['tagname'] = '".$h['tagname']."';");
-        print("column_table2[column_index]['description'] = '".$h['description']."';");
-*/
 
-        print("column_table[\"".$h['header']."\"] = new Array();");
-        if ($h['visible'])
+       if ($prev_label == $h['label'])
+               continue;
+
+       $prev_label = $h['label'];
+
+
+$quickselection.="<option id='option'".$h['label']." class='".$optionclass."' '".$selected."' value='".$h['label']."'>".$h['label'].":&nbsp;".$h['title']."</option>";
+}
+
+
+$quickselection.="</select>";
+$quickselection.="&nbsp;<input type='button' id='fetchbutton' onclick='fetchData()' value='Fetch data' disabled=true />";
+
+return $quickselection;
+
+}
+
+
+function quickselect_popup_html() {
+
+print('<div id="quickdiv">');
+print ("<select size='12' id='quicklist' onChange=changeSelectStatus(this.value)>");
+
+$prev_label="";
+$optionclass = "out";
+foreach ($this->all_headers as $h)
+{
+       if ($h['header'] == "hostname")
+               continue;
+
+       if ($h['fixed'])
+               $disabled = "disabled=true";
+       else
+               $disabled = "";
+
+        if ($this->headerIsVisible($h['label']))
        {
-        print("column_table['".$h['header']."']['visible'] = true;");
-        print("column_table['".$h['header']."']['fetched'] = true;");
+                       $optionclass = "in";
+               //$selected = "selected=selected";
        }
-        else
+       else
        {
-        print("column_table['".$h['header']."']['visible'] = false;");
-        print("column_table['".$h['header']."']['fetch'] = false;");
+                       $optionclass = "out";
+               //$selected = "";
        }
 
-        print("column_table['".$h['header']."']['tagname'] = '".$h['tagname']."';");
-        print("column_table['".$h['header']."']['description'] = '".$h['description']."';");
-}
+       if ($prev_label == $h['label'])
+               continue;
 
-foreach ($this->all_headers as $h)
-        print("column_headers['".$h['label']."'] = '0';");
+       $prev_label = $h['label'];
 
-print("var all_columns_string = '".substr($all_columns_string,0,strlen($all_columns_string)-1)."';");
 
-//if ($first_time == true)
-        //print("resetConfiguration();");
-//print("debugfilter('vars are OK');");
+        print ("<option id='option'".$h['label']." class='".$optionclass."' '".$selected."' value='".$h['label']."'>".$h['label'].":&nbsp;".$h['title']."</option>");
+}
 
-print("</script>");
+
+print("</select></div>");
+print("&nbsp;<input type='button' id='fetchbutton' onclick='fetchData()' value='Fetch data' disabled=true />");
 
 }
 
@@ -393,14 +455,14 @@ else
        $table_width = 350;
 
 print("<table align=center cellpadding=10 width=".$table_width.">");
-print("<tr><th>Add/delete columns</th>");
+print("<tr><th>Add/remove columns</th>");
 
 if ($showDescription)
        print("<th>Column description and configuration</th>");
 
 print("</tr><tr><td valign=top width=300>");
 
-       print('<div id="scrolldiv" onFocusOut="debugfilter(this.id);" style="border : solid 2px grey; padding:4px; width:300px; height:180px; overflow:auto;">');
+       print('<div id="scrolldiv" style="border : solid 2px grey; padding:4px; width:300px; height:180px; overflow:auto;">');
 print ("<table>");
        $prev_label="";
        $optionclass = "out";
@@ -417,19 +479,34 @@ print ("<table>");
                if ($this->headerIsVisible($h['label']))
                {
                        $selected = "checked=true";
+                       $fetch = "true";
                        //print("header ".$h['label']." checked!");
                }
                else
                {
                        $selected = "";
+                       $fetch = "false";
                }
 
+               print("<input type='hidden' id='tagname".$h['header']."' value='".$h['tagname']."'></input>");
+
                if ($prev_label == $h['label'])
                        continue;
 
                $prev_label = $h['label'];
-
-               print ("<tr><td><div id='".$h['label']."' class='".$optionclass."' onkeyup='debugfilter(this.id)' onclick='highlightOption(this.id)'><table width=280 id='table".$h['label']."'><tr><td align=left width=30>".$h['label']."</td><td align=left>&nbsp;<span style='height:10px' id ='htitle".$h['label']."'>".$h['title']."</span>&nbsp;</td><td align=right width=20><input id='check".$h['label']."' type='checkbox' ".$selected." ".$disabled." autocomplete='off' value='".$h['label']."' onclick='changeCheckStatus(this.id)'></input></td></tr></table></div></td></tr>");
+               $period = $this->get_selected_period($h['label']);
+
+//<input type='hidden' id='fdesc".$h['label']."' value='".$h['description']."'></input>
+               print ("<tr><td>
+<input type='hidden' id='fetched".$h['label']."' value=',".$period.",".$fetch."'></input>
+<input type='hidden' id='period".$h['label']."' value='".$period."'></input>
+               <div id='".$h['label']."' name='columnlist' class='".$optionclass."' onclick='highlightOption(this.id)'>
+<table width=280 id='table".$h['label']."'><tr>
+<td bgcolor=#CAE8EA align=center width=30><b><span style='color:#3399CC'>".$h['label']."</span></b></td> 
+<td align=left>&nbsp;<span style='height:10px' id ='htitle".$h['label']."'>".$h['title']."</span>&nbsp;</td>
+<td align=right width=20>&nbsp;<span style='height:10px' id ='loading".$h['label']."'></span>&nbsp;</td>
+<td align=right width=20><input id='check".$h['label']."' name='".$h['tagname']."' type='checkbox' ".$selected." ".$disabled." autocomplete='off' value='".$h['label']."' onclick='changeCheckStatus(this.id)'></input></td>
+</tr></table></div></td></tr>");
        }
 
        print("</table> </div></td>");
@@ -440,12 +517,14 @@ if ($showDescription)
        print("<div class='myslice' id='selectdescr'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div></td>");
 }
 
-print("</tr><tr><td align=center>");
+print("</tr>");
+//print("<tr><td align=center>");
 //print("<input type='button' value='Reset' onclick=resetCols('previousConf') />");
 //print("<input type='button' value='Default' onclick=saveConfiguration('defaultConf') />");
-print("<input type='button' value='Reset table' onclick=\"resetConfiguration('defaultConf')\" />");
-print("&nbsp;<input type='button' value='Save configuration' onclick=saveConfiguration('column_configuration') />");
-print("&nbsp;<input type='button' id='fetchbutton' onclick='fetchData()' value='Fetch data' disabled=true /> </td>");
+//print("<input type='button' value='Reset table' onclick=\"resetConfiguration()\" />");
+//print("</td>");
+//print("&nbsp;<input type='button' value='Save configuration' onclick=saveConfiguration('column_configuration') />");
+//print("&nbsp;<input type='button' id='fetchbutton' onclick='fetchData()' value='Fetch data' disabled=true /> </td>");
 
 if ($showDescription)
        print("<td></td>");
@@ -453,6 +532,8 @@ if ($showDescription)
 print(" </tr> </table>");
 }
 
+
+
 function column_filter () {
 
 echo <<< EOF
diff --git a/plekit/php/logSorting.php b/plekit/php/logSorting.php
new file mode 100644 (file)
index 0000000..27e7ff5
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+
+// Require login
+require_once 'plc_login.php';
+
+// Get session and API handles
+require_once 'plc_session.php';
+global $plc, $api;
+
+//print header
+require_once 'plc_drupal.php';
+
+// Common functions
+require_once 'plc_functions.php';
+
+$value=$_GET["value"];
+$person_id=$_GET["slice_id"];
+
+$myFile = "/var/log/myslice-log";
+$fh = fopen($myFile, 'a') or die("can't open file");
+$stringData = "\n".date('Ymd-H:i')."|".$person_id.":".$value;
+fwrite($fh, $stringData);
+fclose($fh);
+
+?> 
index fdc9a89..d37acb8 100644 (file)
@@ -1,14 +1,9 @@
 <?php
 
-  // $Id: table.php 15752 2009-11-15 22:28:05Z thierry $
+  // $Id$
 
 require_once 'prototype.php';
 
-// Get session and API handles
-require_once 'plc_session.php';
-global $plc, $api;
-
-
 drupal_set_html_head('
 <script type="text/javascript" src="/plekit/tablesort/tablesort.js"></script>
 <script type="text/javascript" src="/plekit/tablesort/customsort.js"></script>
@@ -43,7 +38,7 @@ drupal_set_html_head('
 //  - notes : an array of additional notes
 //  - debug: enables debug callbacks (prints out on console.log)
 
-class PlekitTable2 {
+class PlekitTable {
   // mandatory
   var $table_id;
   var $headers;
@@ -61,13 +56,12 @@ class PlekitTable2 {
   var $max_pages;     // the max number of pages to display in the paginator
   var $notes;         // an array of additional notes
   var $debug;        // set to true for enabling various log messages on console.log
-  var $headersToShow;
-
+  var $configurable;  // boolen (whether the column configuration option is set or not)
 
   // internal
   var $has_tfoot;
 
-  function PlekitTable2 ($table_id,$headers,$sort_column,$headersToShow=NULL,$options=NULL) {
+  function PlekitTable ($table_id,$headers,$sort_column,$options=NULL) {
     $this->table_id = $table_id;
     $this->headers = $headers;
     $this->sort_column = $sort_column;
@@ -84,15 +78,12 @@ class PlekitTable2 {
     $this->max_pages = 10;
     $this->notes = array();
     $this->debug = false;
+    $this->configurable = true;
+
     $this->set_options ($options);
-    //$this->headersToShow=array();
-       $this->headersToShow = $headersToShow;
+
     // internal
     $this->has_tfoot=false;
-
-//print_r ($this->headersToShow);
-
-
   }
 
   function set_options ($options) {
@@ -110,6 +101,7 @@ class PlekitTable2 {
     if (array_key_exists('max_pages',$options)) $this->max_pages=$options['max_pages'];
     if (array_key_exists('notes',$options)) $this->notes=array_merge($this->notes,$options['notes']);
     if (array_key_exists('debug',$options)) $this->debug=$options['debug'];
+    if (array_key_exists('configurable',$options)) $this->configurable=$options['configurable'];
   }
 
   public function columns () {
@@ -150,29 +142,30 @@ class PlekitTable2 {
       print "<caption> $this->caption </caption>";
     print "<tr>";
 
+//a hidden column to store the node_id (used for the dynamic update of column data but not sure if
+//it is necessary)
+if ($this->configurable)
+      print ("<th class=\"plekit_table\" style=\"display:none\">nodeid</th>\n");
 
-
-//panos: hidden column for the node_id
-print ("<th class=\"plekit_table\" name=\"nid\" style=\"display:none\">nid</th>\n");
-////DON'T FORGET!
-
-    foreach ($this->headers as $hkey => $colspec) {
-       //print $label;
+    foreach ($this->headers as $label => $colspec) {
       // which form is being used
       if (is_array($colspec)) {
        $type=$colspec['type'];
-       $title=$colspec['title'];
-//panos some additional attributes
-       $visible=$colspec['visible'];
-       $header = $colspec['header'];
-       $label=$colspec['label'];
+       $title=ucfirst($colspec['title']);
+       if ($this->configurable) {
+               $visible=$colspec['visible'];
+               $header = $colspec['header'];
+               $tlabel=$colspec['label'];
+       }
       } else {
        // simple/legacy form
        $type=$colspec;
        $title=NULL;
-       $visible = true;
-       $label=$hkey;
-       $header=$hkey;
+       if ($this->configurable) {
+               $visible = true;
+               $tlabel=$label;
+               $header=$hkey;
+       }
       }
       switch ($type) {
       case "none" : 
@@ -186,10 +179,13 @@ print ("<th class=\"plekit_table\" name=\"nid\" style=\"display:none\">nid</th>\
       }
       $title_part=$title ? "title=\"$title\"" : "";
 
-
-       if ($visible) print ("<th class=\"$class plekit_table\" $title_part name=\"$header\" style=\"display:table-cell\">".$label."</th>\n");
-       else  print ("<th class=\"$class plekit_table\" $title_part name=\"$header\" style=\"display:none\">".$label."</th>\n");
-
+      if ($this->configurable) {
+       if ($visible) print ("<th class=\"$class plekit_table\" $title_part name=\"$header\" style=\"display:table-cell\">".$tlabel."</th>\n");
+        else  print ("<th class=\"$class plekit_table\" $title_part name=\"$header\" style=\"display:none\">".$tlabel."</th>\n");
+      }
+      else
+       print ("<th class=\"$class plekit_table\" $title_part name=\"$label\" style=\"display:table-cell\">$label</th>\n");
+       //print ("<th class=\"$class plekit_table\" $title_part>$label</th>\n");
     }
 
     print "</tr></thead><tbody>";
@@ -268,25 +264,25 @@ EOF;
 
   ////////////////////////////////////////
   function notes_area_html () {
-//    $search_notes =  
-//      array("Enter &amp; or | in the search area to switch between <span class='bold'>AND</span> and <span class='bold'>OR</span> search modes");
-//    $sort_notes = 
-//      array ("Hold down the shift key to select multiple columns to sort");
+    $search_notes =  
+      array("Enter &amp; or | in the search area to switch between <span class='bold'>AND</span> and <span class='bold'>OR</span> search modes");
+    $sort_notes = 
+      array ("Hold down the shift key to select multiple columns to sort");
 
     if ($this->notes)
       $notes=$this->notes;
     else
       $notes=array();
-//    $notes=array_merge($notes,$sort_notes);
-//    if ($this->search_area)
-//      $notes=array_merge($notes,$search_notes);
+    $notes=array_merge($notes,$sort_notes);
+    if ($this->search_area)
+      $notes=array_merge($notes,$search_notes);
     if (! $notes)
       return "";
     $result = "";
-//    $result .= "<p class='table_note'> <span class='table_note_title'>Notes</span>\n";
-//    foreach ($notes as $note) 
-//      $result .= "<br/><div id='test' style=\"display:none; width:160px; height:80px; background:#ccc;\">$note</div>";
//   $result .= "</p>";
+    $result .= "<p class='table_note'> <span class='table_note_title'>Notes</span>\n";
+    foreach ($notes as $note) 
+      $result .= "<br/>$note\n";
+    $result .= "</p>";
     return $result;
   }
 
@@ -319,9 +315,9 @@ EOF;
     $option=$options['columns'];if ($option) $html .= " colspan='$option'";
     $option=$options['hfill']; if ($option) $html .= " colspan='" . $this->columns() . "'";
     $option=$options['align']; if ($option) $html .= " style='text-align:$option'";
-    $option=$options['color']; if ($option) $html .= " style='color:$option'";
+    $option=$options['color'];  if ($option) $html .= " style='color:$option'";
     $option=$options['display'];  if ($option) $html .= " style='display: $option'";
-    $option=$options['name'];  if ($option) $html .= " name='$option'";
+    $option=$options['name'];   if ($option) $html .= " name='$option'";
     $html .= ">$text</td>";
     return $html;
   }
similarity index 69%
rename from plekit/php/updateConf.php
rename to plekit/php/updateConfiguration.php
index 4722688..39de8ea 100644 (file)
@@ -14,15 +14,15 @@ require_once 'plc_drupal.php';
 require_once 'plc_functions.php';
 
 $value=$_GET["value"];
+$person_id=intval($_GET["person_id"]);
 $slice_id=intval($_GET["slice_id"]);
-$tagN=$_GET["tagName"];
+$tag_id=intval($_GET["tag_id"]);
 
-$fields= array( "$tagN"=>$value);
-$api->UpdateSlice( $slice_id , $fields );
+$api->UpdatePersonTag( $tag_id, $value );
 
 $myFile = "/var/log/myslice-log";
 $fh = fopen($myFile, 'a') or die("can't open file");
-$stringData = "\n".date('Ymd-H:i')."|".$slice_id.":".$value;
+$stringData = "\n".date('Ymd-H:i')."|".$person_id.":".$slice_id.":".$value;
 fwrite($fh, $stringData);
 fclose($fh);
 
index 115fc7c..d956477 100644 (file)
@@ -1,9 +1,259 @@
 
-/* $Id: table.js 13009 2009-04-10 10:49:28Z baris $ */
+/* $Id: column.js Panos $ */
 
 var filtered_color = "grey";
 var normal_color = "black";
 
+//Descriptions overriding the default ones set in Accessors_site.py and configuration 
+
+var sourceComon = '<a target="source_window" href="http://comon.cs.princeton.edu/">CoMon</a>';
+var sourceTophat = '<b><a target="source_window" href="http://www.top-hat.info/">TopHat</a></b>';
+var sourceTophatAPI = '<b><a target="source_window" href="http://www.top-hat.info/API/">TopHat API</a></b>';
+var sourceMySlice = '<b><a target="source_window" href="http://myslice.info/">MySlice</a></b>';
+var sourceCymru = '<b><a target="source_window" href="http://www.team-cymru.org/">Team Cymru</a></b>';
+var sourceMyPLC = '<b><a target="source_window" href="https://www.planet-lab.eu/db/doc/PLCAPI.php">MyPLC API</a></b>';
+var sourceManiacs = '<b><a target="source_window" href="http://www.ece.gatech.edu/research/labs/MANIACS/as_taxonomy/">MANIACS</a></b>';
+var sourceMaxmind = '<b><a target="source_window" href="http://www.maxmind.com/app/geolitecity">MaxMind</a></b>';
+var sourceMonitor = '<b><a target="source_window" href="http://monitor.planet-lab.org/">Monitor</a></b>';
+var selectReferenceNode ='Select reference node: <select id="reference_node" onChange="updateDefaultConf(this.value)"><option value=planetlab-europe-07.ipv6.lip6.fr>planetlab-europe-07.ipv6.lip6.fr</option></select>';
+var addButton = '<input id="addButton" type="button" value="Add" onclick=addColumnAjax(document.getElementById("list1").value)></input>';
+var deleteButton = '<input id="deleteButton" type="button" value="Delete" onclick=deleteColumn(window.document.getElementById("list1").value)></input>';
+
+var descHOSTNAME = "test";
+
+var titleA = 'Architecture name';
+var detailA = '<i>The node architecture.</i>';
+var sourceA = '<b>Source:</b> '+sourceMyPLC;
+var valuesA = 'Values: <b>x86_64</b>, <b>i386</b>';
+var descA = '<span class="myslice title">'+titleA+'</span><p>'+detailA+'<p>'+valuesA+'<p>'+sourceA;
+
+var titlef = 'Operating system';
+var detailf = '<i>Fedora or CentOS distribution to use for node or slivers.</i>';
+var sourcef = '<b>Source:</b> '+sourceMyPLC;
+var descf = '<span class="myslice title">'+titlef+'</span><p>'+detailf+'<p>'+sourcef;
+
+var titleAU = 'Authority';
+var detailAU = '<i>The authority of the global PlanetLab federation that the site of the node belongs to.</i>';
+var valuesAU = 'Values: <b>PLC</b> (PlanetLab Central), <b>PLE</b> (PlanetLab Europe)';
+var sourceAU = '<b>Source:</b> '+sourceMyPLC;
+var descAU = '<span class="myslice title">'+titleAU+'</span><p>'+detailAU+'<p>'+valuesAU+'<p>'+sourceAU;
+
+var titleAS = 'Autonomous system ID';
+var sourceAS = 'Source: '+sourceCymru+' (via '+sourceTophat+')';
+var valuesAS = 'Unit: <b>Integer between 0 and 65535</b>';
+var descAS = '<span class="myslice title">'+titleAS+'</span><p>'+valuesAS+'<p>' + sourceAS;
+
+var titleAST = 'Autonomous system type';
+var sourceAST = 'Source: '+sourceManiacs;
+var valuesAST = 'Values: <b>t1</b> (tier-1), <b>t2</b> (tier-2), <b>edu</b> (university), <b>comp</b> (company), <b>nic</b> (network information centre -- old name for a domain name registry operator), <b>ix</b> (IXP), <b>n/a</b>';
+var descAST = '<span class="myslice title">'+titleAST+'</span><p>'+valuesAST+'<p>'+sourceAST;
+
+var titleASN = 'Autonomous system name';
+var sourceASN = 'Source: '+sourceTophat;
+var descASN = '<span class="myslice title">'+titleASN+'</span><p>'+sourceASN;
+
+var selectPeriodBU = 'Select period: <select id="selectperiodBU" onChange=updatePeriod("BU",this.value)><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
+var titleBU = 'Bandwidth utilization ';
+var sourceBU = 'Source: '+sourceComon+' (via '+sourceMySlice+')';
+var valuesBU ='Unit: <b>Kbps</b>';
+var detailBU = '<i>The average transmited bandwidh over the selected period. The period is the most recent for which data is available, with CoMon data being collected by MySlice daily.</i>'
+var descBU = '<span class="myslice title">'+titleBU+'</span><p>'+detailBU+'<p>'+selectPeriodBU+'<p>'+valuesBU+'<p>'+sourceBU; 
+
+var titleBW= 'Bandwidth limit';
+var sourceBW = 'Source: '+sourceComon;
+var valuesBW = 'Unit: <b>Kbps</b>';
+var detailBW = '<i>The bandwidth limit is a cap on the total outbound bandwidth usage of a node. It is set by the site administrator (PI). For more details see <a targe="source_window" href="http://www.planet-lab.org/doc/BandwidthLimits">Bandwidth Limits (planet-lab.org)</a></i>.';
+var descBW = '<span class="myslice title">'+titleBW+'</span><p>'+detailBW+'<p>'+valuesBW+'<p>'+sourceBW;
+
+var titleCC = 'Number of CPU cores';
+var sourceCC = 'Source: '+sourceComon;
+var valuesCC = 'Current PlanetLab hardware requirements: 4 cores min. <br><i>(Older nodes may have fewer cores)</i>.';
+var descCC = '<span class="myslice title">'+titleCC+'</span><p>'+valuesCC+'<p>'+sourceCC;
+
+var titleCN = 'Number of CPUs';
+var sourceCN = 'Source: '+sourceComon;
+var valuesCN = 'Current PlanetLab hardware requirements: <b>1 (if quad core) or 2 (if dual core)</b>';
+var descCN = '<span class="myslice title">'+titleCN+'</span><p>'+valuesCN+'<p>'+sourceCN;
+
+var titleCR = 'CPU clock rate';
+var sourceCR = 'Source: '+sourceComon;
+var valuesCR = 'Unit: <b>GHz</b><p>Current PlanetLab hardware requirements: <b>2.4 GHz</b>';
+var descCR = '<span class="myslice title">'+titleCR+'</span><p>'+valuesCR+'<p>'+sourceCR;
+
+var selectPeriodCF = 'Select period: <select id="selectperiodCF" onChange=updatePeriod("CF",this.value)><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
+var titleCF = 'Free CPU';
+var sourceCF = 'Source: '+sourceComon+' (via '+sourceMySlice+')';
+var valuesCF = 'Unit: <b>%</b>';
+var detailCF = '<i> The average CPU percentage that gets allocated to a test slice named burb that is periodically run by CoMon.</i>';
+var descCF = '<span class="myslice title">'+titleCF+'</span><p>'+detailCF+'<p>'+selectPeriodCF+'<p>'+valuesCF+'<p>'+sourceCF; 
+
+var titleDS = 'Disk size';
+var sourceDS = 'Source: '+sourceComon;
+var valuesDS = 'Unit: <b>GB</b><p>Current PlanetLab hardware requirements: <b>500 GB</b>';
+var descDS = '<span class="myslice title">'+titleDS+'</span><p>'+valuesDS+'<p>'+sourceDS;
+
+var titleDU = 'Current disk utilization';
+var sourceDU = 'Source: '+sourceComon+' (via '+sourceMySlice+')';
+var valuesDU = 'Unit: <b>GB</b>';
+var detailDU = '<i> The amount of disk space currently consumed (checked daily).</i>';
+var descDU = '<span class="myslice title">'+titleDU+'</span><p>'+detailDU+'<p>'+valuesDU+'<p>'+sourceDU;
+
+var titleHC = 'Hop count (pairwise)';
+var sourceHC = 'Source: '+sourceTophat;
+var detailHC = '<i>TopHat conducts traceroutes every five minutes in a full mesh between all PlanetLab nodes. The hop count is the length of the traceroute from the node to the reference node, based upon the most recently reported traceroute</i>.';
+var descHC = '<span class="myslice title">'+titleHC+'</span><p>'+detailHC+'<p>'+selectReferenceNode+'<p>'+sourceHC;
+
+var titleIP = 'IP address';
+var sourceIP = 'Source: '+sourceTophat;
+var descIP = '<span class="myslice title">'+titleIP+'</span><p>'+sourceIP;
+
+var selectPeriodL = 'Select period: <select id="selectperiodL" onChange=updatePeriod("L",this.value)><option value="">Latest</option><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
+var titleL= 'Load ';
+var sourceL = 'Source: '+sourceComon;
+var valuesL = 'Unit: <b>5-minute load</b>';
+var detailL = '<i>The average 5-minute load (as reported by the Unix uptime command) over the selected period.</i>';
+//var descL = '<span class="myslice title">'+titleL+'</span><p>'+detailL+'<p>'+selectPeriodL+'<p>'+valuesL+'<p>'+sourceL; 
+var descL = '<span class="myslice title">'+titleL+'</span><p>'+detailL+'<p>'+valuesL+'<p>'+sourceL; 
+
+var titleLON= 'Longitude';
+var sourceLON = 'Source: '+sourceTophat;
+var descLON = '<span class="myslice title">'+titleLON+'</span><p>'+sourceLON;
+
+var titleLAT= 'Latitude';
+var sourceLAT = 'Source: '+sourceTophat;
+var descLAT = '<span class="myslice title">'+titleLAT+'</span><p>'+sourceLAT;
+
+var titleLCN= 'Location (Country)';
+var sourceLCN = 'Source: '+sourceMaxmind+' (via '+sourceTophat+')';
+var detailLCN = '<i>Based on the latitude and longitude information.</i>';
+var descLCN = '<span class="myslice title">'+titleLCN+'</span><p>'+detailLCN+'<p>'+sourceLCN;
+
+var titleLCT= 'Location (Continent)';
+var sourceLCT = 'Source: '+sourceMaxmind+' (via '+sourceTophat+')';
+var detailLCT = '<i>Based on the latitude and longitude information.</i>';
+var descLCT = '<span class="myslice title">'+titleLCT+'</span><p>'+detailLCT+'<p>'+sourceLCT;
+
+var titleLCY= 'Location (City)';
+var sourceLCY = 'Source: '+sourceMaxmind+' (via '+sourceTophat+')';
+var detailLCY = '<i>Based on the latitude and longitude information.</i>';
+var descLCY = '<span class="myslice title">'+titleLCY+'</span><p>'+detailLCY+'<p>'+sourceLCY;
+
+var titleLPR= 'Location precision radius';
+var sourceLPR = 'Source: '+sourceTophat;
+var valuesLPR = 'Unit: <b>float</b>';
+var detailLPR = '<i>The radius of the circle corresponding to the error in precision of the geolocalization estimate.</i>';
+var descLPR = '<span class="myslice title">'+titleLPR+'</span><p>'+detailLPR+'<p>'+valuesLPR+'<p>'+sourceLPR;
+
+var titleLRN= 'Location (Region)';
+var sourceLRN = 'Source: '+sourceMaxmind+' (via '+sourceTophat+')';
+var detailLRN = '<i>Based on the latitude and longitude information.</i>';
+var descLRN = '<span class="myslice title">'+titleLRN+'</span><p>'+detailLRN+'<p>'+sourceLRN;
+
+var titleMS= 'Memory size';
+var sourceMS = 'Source: '+sourceComon;
+var valuesMS = 'Unit: <b>GB</b><p>Current PlanetLab hardware requirements: <b>4 GB</b>.';
+var descMS = '<span class="myslice title">'+titleMS+'</span><p>'+valuesMS+'<p>'+sourceMS;
+
+var selectPeriodMU = 'Select period: <select id="selectperiodMU" onChange=updatePeriod("MU",this.value)><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
+var titleMU = 'Memory utilization';
+var sourceMU = 'Source: '+sourceComon;
+var valuesMU = '<p>Unit: <b>%</b>';
+var detailMU = '<i>The average active memory utilization as reported by CoMon.</i>';
+var descMU = '<span class="myslice title">'+titleMU+'</span><p>'+detailMU+'<p>'+selectPeriodMU+'<p>'+valuesMU+'<p>'+sourceMU; 
+
+var titleNEC= 'Network information (ETOMIC)';
+var sourceNEC = 'Source: '+sourceTophat;
+var valuesNEC = 'Values: <b>yes/no</b>';
+var detailNEC = '<i>The existence of a colocated ETOMIC box. When an ETOMIC box is present, you have the possibility to conduct high-precision measurements through the '+sourceTophatAPI+'.</i>';
+var descNEC = '<span class="myslice title">'+titleNEC+'</span><p>'+detailNEC+'<p>'+valuesNEC+'<p>'+sourceNEC;
+
+var titleNSN= 'Network information (SONoMA)';
+var sourceNSN = 'Source: '+sourceTophat;
+var valuesNSN = 'Values: <b>yes/no</b>';
+var detailNSN = '<i>The existence of a SONoMA agent. When an SONoMA is present, you have the possibility to have access to high-precision measurements through the '+sourceTophatAPI+'.</i>';
+var descNSN = '<span class="myslice title">'+titleNSN+'</span><p>'+detailNSN+'<p>'+valuesNSN+'<p>'+sourceNSN;
+
+var titleNTH= 'Network information (TopHat)';
+var sourceNTH = 'Source: '+sourceTophat;
+var valuesNTH = 'Values: <b>yes/no</b>';
+var detailNTH = '<i>The existence of a colocated TDMI (TopHat Dedicated Measurement Infrastructure) agent. When a TDMI agent is present, you have access to a wide variety of network topology measurements through the '+sourceTophatAPI+'.</i>';
+var descNTH = '<span class="myslice title">'+titleNTH+'</span><p>'+detailNTH+'<p>'+valuesNTH+'<p>'+sourceNTH;
+
+var titleNDS= 'Network information (DIMES)';
+var sourceNDS = 'Source: '+sourceTophat;
+var valuesNDS = 'Values: <b>yes/no</b>';
+var detailNDS = '<i>The existence of a colocated DIMES agent. When a DIMES agent is present, you have access to DIMES measurements through the '+sourceTophatAPI+'.</i>';
+var descNDS = '<span class="myslice title">'+titleNDS+'</span><p>'+detailNDS+'<p>'+valuesNDS+'<p>'+sourceNDS;
+
+var titleNSF= 'Network information (spoof)';
+var sourceNSF = 'Source: '+sourceTophat;
+var valuesNSF = '<p>Values: <b>yes/no</b>';
+var detailNSF = '<i> Whether the node can send packets successfully (or not) with a spoofed IP source address.</i>';
+var descNSF = '<span class="myslice title">'+titleNSF+'</span><p>'+detailNSF+'<p>'+valuesNSF+'<p>'+sourceNSF;
+
+var titleNSR= 'Network information (source route)';
+var sourceNSR = 'Source: '+sourceTophat;
+var valuesNSR = '<p>Values: <b>yes/no</b>';
+var detailNSR = '<i> Whether the node can send packets packets using the IP source route option. See <a target="info_window" href="http://www.networksorcery.com/enp/protocol/ip/option003.htm">here</a>for more info.</i>';
+var descNSR = '<span class="myslice title">'+titleNSR+'</span><p>'+detailNSR+'<p>'+valuesNSR+'<p>'+sourceNSR;
+
+var titleNTP= 'Network information (timestamp)';
+var sourceNTP = 'Source: '+sourceTophat;
+var valuesNTP = '<p>Values: <b>yes/no</b>';
+var detailNTP = '<i> Whether the node can send packets packets using the IP timestamp option. See <a target="info_window" href="http://www.networksorcery.com/enp/protocol/ip/option004.htm">here</a>for more info.</i>';
+var descNTP = '<span class="myslice title">'+titleNTP+'</span><p>'+detailNTP+'<p>'+valuesNTP+'<p>'+sourceNTP;
+
+var titleNRR= 'Network information (record route)';
+var sourceNRR = 'Source: '+sourceTophat;
+var valuesNRR = '<p>Values: <b>yes/no</b>';
+var detailNRR = '<i> Whether the node can send packets packets using the IP record route option. See <a target="info_window" href="http://www.networksorcery.com/enp/protocol/ip/option007.htm">here</a>for more info.</i>';
+var descNRR = '<span class="myslice title">'+titleNRR+'</span><p>'+detailNRR+'<p>'+valuesNRR+'<p>'+sourceNRR;
+
+var titleOS = 'Operating system';
+var sourceOS = 'Source: '+sourceMyPLC;
+var valuesOS = 'Values: <b>Fedora, Cent/OS, other, n/a</b>';
+var descOS = '<span class="myslice title">'+titleOS+'</span><p>'+valuesOS+'<p>'+sourceOS;
+
+var selectPeriodR = 'Select period: <select id="selectperiodR" onChange=updatePeriod("R",this.value)><option value="">Latest</option><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
+var titleR = 'Reliability';
+var sourceR = 'Source: '+sourceComon+' (via '+sourceMySlice+')';
+var detailR = '<i>CoMon queries nodes every 5 minutes, for 255 queries per day. The average reliability is the percentage of queries over the selected period for which CoMon reports a value. The period is the most recent for which data is available, with CoMon data being collected by MySlice daily.</i>';
+var valuesR = 'Unit: <b>%</b>';
+var descR = '<span class="myslice title">'+titleR+'</span><p>'+detailR+'<p>'+selectPeriodR+'<p>'+valuesR+'<p>'+sourceR; 
+//var descR = '<span class="myslice title">'+titleR+'</span><p>'+detailR+'<p>'+valuesR+'<p>'+sourceR; 
+
+var titleRES = 'Reservation capabilities';
+var sourceRES = 'Source: '+sourceMyPLC;
+//var valuesRES = 'Values: <b>yes/no</b>';
+var valuesRES = 'Values: <b>-R-</b> (if yes)';
+var detailRES = '<i> Whether the node can be reserved for a certain duration.<br>Your slivers will be available <span class=bold>only during timeslots where you have obtained leases (see tab above)</span></i>.  <p>Please note that as of August 2010 this feature is experimental.  Feedback is appreciated at <a href="mailto:devel@planet-lab.org">devel@planet-lab.org</a>';
+var descRES = '<span class="myslice title">'+titleRES+'</span><p>'+detailRES+'<p>'+valuesRES+'<p>'+sourceRES;
+
+var selectPeriodS = 'Select period: <select id="selectperiodS" onChange=updatePeriod("S",this.value)><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
+var titleS = 'Active slices';
+var sourceS = 'Source: '+sourceComon+' (via '+sourceMySlice+')';
+var valuesS = 'Unit: <b>%</b>';
+var detailS = '<i>Average number of active slices over the selected period for which CoMon reports a value. The period is the most recent for which data is available, with CoMon data being collected by MySlice daily.</i>';
+var descS = '<span class="myslice title">'+titleS+'</span><p>'+detailS+'<p>'+selectPeriodS+'<p>'+valuesS+'<p>'+sourceS; 
+
+var titleSN = 'Site name';
+var sourceSN = 'Source: '+sourceMyPLC;
+var descSN = '<span class="myslice title">'+titleSN+'</span><p>'+sourceSN;
+
+var selectPeriodSSH = 'Select period: <select id="selectperiodSSH" onChange=updatePeriod("SSH",this.value)><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
+var titleSSH = 'Average SSH response delay';
+var valuesSSH = 'Unit: <b>%</b>';
+var detailSSH = '<i>The average response delay of the node to SSH logins over the selected period for which CoMon reports a value. The period is the most recent for which data is available, with CoMon data being collected by MySlice daily.</i>';
+var sourceSSH ='Source: '+sourceComon+' (via '+sourceMySlice+')';
+var descSSH = '<span class="myslice title">'+titleSSH+'</span><p>'+detailSSH+'<p>'+selectPeriodSSH+'<p>'+valuesSSH+'<p>'+sourceSSH; 
+
+var titleST = 'Status';
+var sourceST = 'Source: '+sourceMonitor;
+var valuesST = 'Values: <b>online</b> (up and running), <b>good</b> (up and running recently), <b>offline</b> (unreachable today), <b>down</b> (node unreachable for more than one day), <b>failboot</b> (reachable, but only by administrators for debugging purposes).';
+var descST = '<span class="myslice title">'+titleST+'</span><p>'+valuesST+'<p>'+sourceST;
+
+
+//Categorization of columns in different types, useful for filtering 
 
 function inTypeA(header_name) {
        var typeA = ['ST','SN','RES','OS','NRR','NTP','NSR','NSF','NDS','NTH','NEC','LRN','LCY','LPR','LCN','LAT','LON','IP','ASN','AST'];
@@ -25,172 +275,190 @@ function inTypeD(header_name) {
        return typeD.indexOf(header_name);
 }
 
+
+//Debugging
 function debugfilter(s) {
        document.getElementById('debug').innerHTML+=s;
 }
 
-function scrollList(tableid) {
 
-debugfilter("here");
-
-if (event.keyCode == 40)
-       debugfilter("down");
-else if (event.keyCode == 38)
-       debugfilter("up");
-
-}
+//Called when a column is selected. It displays the detailed description
+//on the right panel
 
 function highlightOption(divid) {
 
-//debugfilter("highlighting option "+divid);
+       //debugfilter("highlighting option "+divid);
 
-for (var kk in column_headers) {
+       var columns = document.getElementsByName('columnlist');
+       for(var j = 0; j < columns.length; j++)
+               columns[j].className = 'out'; 
 
-if (document.getElementById(kk))
-       document.getElementById(kk).className = 'out'; 
-}
+       document.getElementById(divid).className = 'selected';
 
-document.getElementById(divid).className = 'selected';
+       showDescription(divid);
 
-showDescription(divid);
+//panos: to IMPROVE 
+       if (document.getElementById('selectperiod'+divid))
+               document.getElementById('selectperiod'+divid).value = document.getElementById('period'+divid).value;
 
 }
 
 
+//Displays the detailed column description 
+
 function showDescription(h) {
 
        //debugfilter("showing description "+h);
 
+//Checks if the detailed description div exists 
        if (document.getElementById('selectdescr'))
        {
+               //Checks if there is a detailed description defined
                if (window['desc'+h])
                        document.getElementById('selectdescr').innerHTML = ""+window['desc'+h];
-               else if (column_table[h] && column_table[h]['description'])
-                       document.getElementById('selectdescr').innerHTML = column_table[h]['description'];
+               //else if (document.getElementById('fdesc'+h))
+                       //document.getElementById('selectdescr').innerHTML = document.getElementById('fdesc'+h).value;
                else 
-                       document.getElementById('selectdescr').innerHTML = "No description provided";
+                       document.getElementById('selectdescr').innerHTML = "No detailed description provided";
        }
 }
 
 
+//Overrides the titles of the columns as they are shown in the column selection panel.
+//If no overriding variable exists the tag's description is used
 function overrideTitles() {
 
-       //debugfilter("<p>overriding...");
+       var columns = document.getElementsByName('columnlist');
 
-       for (var kk in column_headers) {
-
-       //debugfilter("here "+kk);
-
-       if (document.getElementById(kk) && window['title'+kk])
-               document.getElementById('htitle'+kk).innerHTML = window['title'+kk];
+       for(var j = 0; j < columns.length; j++)
+       {
+               var kk = columns[j].id;
+               if (window['title'+kk])
+                       document.getElementById('htitle'+kk).innerHTML = window['title'+kk];
        }
-
 }
 
+//When the checkbox is clicked. Adds/removes column respectively
 function changeCheckStatus(column) {
 
+       if (document.getElementById('selectdescr'))
+               showDescription(document.getElementById(column).value);
 
-if (document.getElementById('selectdescr'))
-{
-showDescription(document.getElementById(column).value);
-
-if (document.getElementById(column).checked)
-       addColumn(document.getElementById(column).value);
-else
-       deleteColumn(document.getElementById(column).value);
+       if (document.getElementById(column).checked)
+               addColumn(document.getElementById(column).value, true);
+       else
+               deleteColumn(document.getElementById(column).value);
 }
 
-}
+//This function is used when the alternative "quick" selection list is used
+function changeSelectStatus(column) {
 
-function updatePeriod(h) {
-       deleteColumn2(h, h+'w');
-       deleteColumn2(h, h+'m');
-       deleteColumn2(h, h+'y');
-       addColumn(h);
-}
+       var optionClass = "";
+       var selected_index = document.getElementById('quicklist').selectedIndex;
 
-function filterByType(selectedtype) {
+       if (document.getElementById('quicklist'))
+       {
 
-var notselectedyet = true;
+               optionClass = document.getElementById('quicklist').options[selected_index].className;
 
-for (var kk in column_headers) {
+               if (optionClass == "in")
+               {
+                       deleteColumn(document.getElementById('quicklist').value);
+                       document.getElementById('quicklist').options[selected_index].className = "out";
+               }
+               else
+               {
+                       addColumn(document.getElementById('quicklist').value, true);
+                       document.getElementById('quicklist').options[selected_index].className = "in";
+               }
+       }
+}
 
-       if (document.getElementById(kk))
+//When the period of an already selected column is changed
+function updatePeriod(h, new_period) {
+
+       var old_period = document.getElementById('period'+h).value;
+       document.getElementById('period'+h).value=new_period;
+
+       //debugfilter(h+''+old_period+'-'+h+''+new_period);
+       if (document.getElementById('check'+h).checked)
        {
-               if (window['type'+kk] == selectedtype)
-               {
-                       document.getElementById(kk).className = 'in';
-                       if (notselectedyet)
-                               highlightOption(kk);
-                       notselectedyet = false;
-               }
-               else
-                       document.getElementById(kk).className = 'out';
+               deleteColumnCells(h+''+old_period);
+               addColumnCells(h+''+new_period);
+               addColumnAjax(h, h+''+new_period);
+
+               replaceColumnConfiguration(h+''+old_period,h+''+new_period);
        }
 }
-}
-
 
 /*
  
 RESET/SAVE CONFIGURATION
 */
 
+function getHTTPObject()
+{
+        if (typeof XMLHttpRequest != 'undefined')
+        { return new XMLHttpRequest(); }
 
-function resetColumns() {
+        try
+        { return new ActiveXObject("Msxml2.XMLHTTP"); }
+        catch (e)
+        {
+                try { return new ActiveXObject("Microsoft.XMLHTTP"); }
+                catch (e) {}
+        }
+        return false;
+}
 
-       for (var kk in column_table) {
 
-       if (column_table[kk]['visible'] == true && column_table[kk]['fetch'] == false)
-               deleteColumn(kk);
-       else if (column_table[kk]['visible'] == false && column_table[kk]['fetch'] == true)
-               addColumn(kk);
-       }
+function closeShowReservable()
+{
+       var slice_id = document.getElementById('slice_id').value;
+       var person_id = document.getElementById('person_id').value;
+       var tag_id = document.getElementById('show_tag_id').value;
+        document.getElementById('note_reservable_div').style.display = "none";
+
+        var url = "/plekit/php/updateConfiguration.php?value="+slice_id+";reservable:no&slice_id="+slice_id+"&person_id="+person_id+"&tag_id="+tag_id;
+
+       var req = getHTTPObject();
+       req.open('GET', url, true);
+       req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+       req.onreadystatechange =
+        function() {
+                if (req.readyState == 4)
+                { debugfilter(req.responseText); }
+        }
+       req.send(null);
 
 }
 
-function resetCols(which_conf) {
 
-       var target_configuration = "|"+document.getElementById(which_conf).value+"|";
-       
-       //debugfilter("<p>Target configuration =  "+target_configuration);
+function updateColumnConfiguration(slice_id, value, reload)
+{
+       var person_id = document.getElementById('person_id').value;
+       var tag_id = document.getElementById('conf_tag_id').value;
+       var full_column_configuration = document.getElementById('full_column_configuration').value;
 
-       for (var kk in column_table) {
-               //debugfilter("in "+kk+" ");
+       //debugfilter("<br>OLD = "+full_column_configuration);
+       //debugfilter("<br>value = "+value);
+       
+       var old_columns = full_column_configuration.split(";");
+       var new_columns = new Array();
 
-               if (target_configuration.indexOf("|"+kk+"|")>=0)
-               {
-                       if (document.getElementById('check'+kk))
-                       if (document.getElementById('check'+kk).checked == false)
-                       {
-                               debugfilter("<p>Adding "+kk);
-                               addColumn(kk);
-                       }
-               }
+       for (var column_index = 0; column_index < old_columns.length ; column_index++) {
+               new_columns.push(old_columns[column_index]);
+               if (old_columns[column_index] != slice_id)
+                       new_columns.push(old_columns[++column_index]);
                else
                {
-                       if (document.getElementById('check'+kk))
-                       if (document.getElementById('check'+kk).checked == true)
-                       {
-                               debugfilter("<p>Deleting "+kk);
-                               deleteColumn(kk);
-                       }
+                       column_index++;
+                       new_columns.push(value);
                }
        }
-}
-
-function saveConfiguration(which_conf)
-{
-       var slice_id = document.getElementById('slice_id').value;
-
-       var target_configuration = document.getElementById(which_conf).value;
 
-       debugfilter("saving configuration "+target_configuration);
-       updateColumnConfiguration(slice_id, target_configuration);
-}
-
-function updateColumnConfiguration(slice_id, value)
-{
+       var new_configuration = new_columns.join(";");
+       //debugfilter("<br>NEW = "+new_configuration);
 
         if (window.XMLHttpRequest)
           {// code for IE7+, Firefox, Chrome, Opera, Safari
@@ -205,49 +473,57 @@ function updateColumnConfiguration(slice_id, value)
           if (xmlhttp.readyState==4) // && xmlhttp.status==200)
             {
                 //value=xmlhttp.responseText;
-                //debugfilter(value);
-               if (document.getElementById('column_configuration'))
+                //debugfilter(value+"-----"+new_configuration);
                document.getElementById('column_configuration').value=value;
+               document.getElementById('full_column_configuration').value=new_configuration;
+
+               if (reload)
+                       window.location.reload(true);
             }
           }
-        xmlhttp.open("GET","/plekit/php/updateConf.php?value="+value+"&slice_id="+slice_id+"&tagName=Configuration",true);
+
+        xmlhttp.open("GET","/plekit/php/updateConfiguration.php?value="+new_configuration+"&slice_id="+slice_id+"&person_id="+person_id+"&tag_id="+tag_id,true);
+        //xmlhttp.open("GET","/plekit/php/updateConf.php?value="+value+"&slice_id="+slice_id+"&person_id="+person_id+"&tagName=Columnconf",true);
 
         xmlhttp.send();
 }
 
+function logSortingAction(slice_id, value)
+{
 
+       if (value.indexOf("column-1")!=-1)
+               return;
 
-function resetConfiguration(which_conf)
-{
-       var slice_id = document.getElementById('slice_id').value;
-       var target_configuration = document.getElementById(which_conf).value;
+       var req = getHTTPObject();
+        var url = "/plekit/php/logSorting.php?value="+value+"&slice_id="+slice_id;
+
+       req.open('GET', url, true);
+       req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+       req.onreadystatechange =
+        function() {
+                if (req.readyState == 4)
+                { debugfilter(req.responseText); }
+        }
+       req.send(null);
+}
 
-       debugfilter("reseting configuration "+target_configuration);
+function sortCompleteCallback(tableid) {
 
-        if (window.XMLHttpRequest)
-          {// code for IE7+, Firefox, Chrome, Opera, Safari
-          xmlhttp=new XMLHttpRequest();
-          }
-        else
-          {// code for IE6, IE5
-          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
-          }
-        xmlhttp.onreadystatechange=function()
-          {
-          if (xmlhttp.readyState==4) // && xmlhttp.status==200)
-            {
-                //value=xmlhttp.responseText;
-                //debugfilter(value);
-                window.location.reload(true);
-            }
-          }
-        xmlhttp.open("GET","/plekit/php/updateConf.php?value="+target_configuration+"&slice_id="+slice_id+"&tagName=Configuration",true);
+       var slice_id = document.getElementById('slice_id').value;
 
-        xmlhttp.send();
+       var ths = document.getElementById(tableid).getElementsByTagName("th");
+       for(var i = 0, th; th = ths[i]; i++) {
+       if (th.className.indexOf("Sort") != -1)
+       {
+               var column = th.className.substr(th.className.indexOf("column"),th.className.indexOf("column")+1);
+               var sortdirection = th.className.substr(th.className.indexOf("Sort")-8,th.className.indexOf("Sort"));
+               logSortingAction(slice_id, tableid+"|"+column+"|"+sortdirection);
+       }
+       }
 }
 
-function addColumnToConfiguration(column) {
 
+function addColumnToConfiguration(column) {
 
        var old_configuration = document.getElementById('column_configuration').value;
        var slice_id = document.getElementById('slice_id').value;
@@ -261,10 +537,49 @@ function addColumnToConfiguration(column) {
 
        //debugfilter("new configuration = "+new_configuration);
 
-       updateColumnConfiguration(slice_id, new_configuration);
+       updateColumnConfiguration(slice_id, new_configuration, false);
 }
 
 
+function deleteColumnFromConfiguration(column) {
+
+       var old_configuration = document.getElementById('column_configuration').value;
+       var slice_id = document.getElementById('slice_id').value;
+
+       var old_columns = old_configuration.split("|");
+       var new_columns = new Array();
+
+       for (var column_index = 0; column_index < old_columns.length ; column_index++) {
+               var conf = old_columns[column_index].split(':');
+               if (conf[0] != column)
+                       new_columns.push(old_columns[column_index]);
+       }
+
+       var new_configuration = new_columns.join("|");
+       updateColumnConfiguration(slice_id, new_configuration, false);
+
+}
+
+function replaceColumnConfiguration(column_old, column_new) {
+
+       var old_configuration = document.getElementById('column_configuration').value;
+       var slice_id = document.getElementById('slice_id').value;
+
+       var old_columns = old_configuration.split("|");
+       var new_columns = new Array();
+
+       for (var column_index = 0; column_index < old_columns.length ; column_index++) {
+               var conf = old_columns[column_index].split(':');
+               if (conf[0] != column_old)
+                       new_columns.push(old_columns[column_index]);
+               else
+                       new_columns.push(column_new);
+       }
+
+       var new_configuration = new_columns.join("|");
+       
+       updateColumnConfiguration(slice_id, new_configuration);
+}
 
 /*
  
@@ -273,23 +588,11 @@ ADD/REMOVE COLUMNS
 */
 
 
-function getHTTPObject()
-{
-        if (typeof XMLHttpRequest != 'undefined')
-        { return new XMLHttpRequest(); }
 
-        try
-        { return new ActiveXObject("Msxml2.XMLHTTP"); }
-        catch (e)
-        {
-                try { return new ActiveXObject("Microsoft.XMLHTTP"); }
-                catch (e) {}
-        }
-        return false;
-}
 
+function load_data(column, header, url) {
 
-function load_html(column, url) {
+       //debugfilter("<br>loading "+url);
        var req = getHTTPObject();
        var res;
        req.open('GET', url, true);
@@ -297,15 +600,15 @@ function load_html(column, url) {
        req.onreadystatechange =
         function() {
                 if (req.readyState == 4)
-                { updateColumnData(column, req.responseText); }
+                { updateColumnData(column, header, req.responseText); }
         }
        req.send(null);
 }
 
-function updateColumnData(column,data) {
 
+function updateColumnData(column, header, data) {
 
-var headers = column.split("|");
+var headers = header.split("|");
 var data_table = data.split("|"); 
 
 //debugfilter("<p>headers[0] = "+headers[0]);
@@ -345,13 +648,20 @@ var data_table = data.split("|");
     var tr=rows[row_index];
 
     for (var column_index=0; column_index < tr.cells.length; column_index++) {
-               //debugfilter("<p>node id = "+tr.cells[0].innerHTML);
+               //debugfilter("<p>node id = "+tr.cells[0].innerHTML+" - "+tr.cells[column_index].getAttribute('name'));
+               if (tr.cells[column_index].getAttribute('name'))
+               {
                var found_index = headers.indexOf(tr.cells[column_index].getAttribute('name'));
                if (found_index != -1)
+                       //debugfilter(tr.cells[0].innerHTML+"-"+found_index);
                        tr.cells[column_index].innerHTML = data_array1[tr.cells[0].innerHTML][found_index];
+               }
     }
   }
 
+  fdTableSort.init(table_id1);
+  tablePaginater.init(table_id1);
+
 //potential nodes
 if (data_table[node_index] == '---potential---')       
 {
@@ -386,35 +696,36 @@ if (data_table[node_index] == '---potential---')
     var tr=rows2[row_index];
 
     for (var column_index=0; column_index < tr.cells.length; column_index++) {
+               if (tr.cells[column_index].getAttribute('name'))
+               {
                var found_index = headers.indexOf(tr.cells[column_index].getAttribute('name'));
                if (found_index != -1)
                        tr.cells[column_index].innerHTML = data_array2[tr.cells[0].innerHTML][found_index];
+               }
     }
   }
 
-}
+  //fdTableSort.removeTableCache(table_id2);
+  fdTableSort.init(table_id2);
+  tablePaginater.init(table_id2);
 
-  document.getElementById('loadingDiv').innerHTML = ""
 }
 
+document.getElementById('loading'+column).innerHTML = "";
 
+}
 
 
-
-function addColumnCells(column,header) {
-
-       //debugfilter("adding cells now: "+column+":"+header);
-       column_table[header]['visible']=true;
+function addColumnCells(header) {
 
        var cells = document.getElementsByName(header);
 
-
        //debugfilter("got cells -"+cells+"- for "+header);
        for(var j = 0; j < cells.length; j++) 
                cells[j].style.display = "table-cell";
 }
 
-function addColumnSamples(column) {
+function addSampleCells(column) {
 
        var cellsheader = document.getElementsByName("confheader"+column);
        for(var j = 0; j < cellsheader.length; j++) 
@@ -422,69 +733,179 @@ function addColumnSamples(column) {
 
 }
 
-function addColumnAjax(column) {
+function addColumnAjax(column, header) {
 
-       var selectedperiod="";
+       //var t = document.getElementById('check'+column).name;
+       var t = document.getElementById('tagname'+header).value;
+       var slice_id = document.getElementById('slice_id').value;
 
-       if (document.getElementById('selectperiod'+column))
-               selectedperiod = document.getElementById('selectperiod'+column).value;
+        var selectedperiod = document.getElementById('period'+column).value;
 
-       var header = column+""+selectedperiod;
+       var fetched = document.getElementById('fetched'+column).value;
+       var to_load = false;
 
-       addColumnCells(column, header);
+       //debugfilter("<br>adding "+column+","+header+','+fetched+','+t);
 
-       var t = column_table[header]['tagname'];
-       var slice_id = document.getElementById('slice_id').value;
-       document.getElementById('loadingDiv').innerHTML = "<img src=/plekit/icons/ajax-loader.gif>LOADING ...";
-       var url = "/plekit/php/updateColumn.php?slice_id="+slice_id+"&tagName="+t;
-       load_html(header, url);
+       if (fetched.indexOf("false")!=-1)
+       {
+               to_load = true;
+               document.getElementById('fetched'+column).value = ','+selectedperiod+',true';
+       }
+       else if (fetched.indexOf(','+selectedperiod+',')==-1)
+       {
+                       to_load = true;
+                       document.getElementById('fetched'+column).value = ','+selectedperiod+''+fetched;
+       }
 
-       addColumnToConfiguration(header);
+       if (to_load)
+       {
+               document.getElementById('loading'+column).innerHTML = "<img width=10 src=/plekit/icons/ajax-loader.gif>";
+               var url = "/plekit/php/updateColumn.php?slice_id="+slice_id+"&tagName="+t;
+               load_data(column, header, url);
+       }
 }
 
 
-function addColumn2(column) {
+
+function addColumn(column, fetch) {
 
        var selectedperiod="";
+       var header=column;
+
+       if (inTypeC(column)!=-1)
+       {
+               column = column.substring(0,column.length-1);
+       }
 
-       if (document.getElementById('selectperiod'+column))
-               selectedperiod = document.getElementById('selectperiod'+column).value;
+        selectedperiod = document.getElementById('period'+column).value;
+       header = column+""+selectedperiod;
 
-       var header = column+""+selectedperiod;
+       //debugfilter("adding column "+column+" and header "+header);
 
-       addColumnCells(column,header);
+       addColumnCells(header);
 
-       addColumnToConfiguration(column);
+       if (fetch)
+               addColumnAjax(column, header);
 
-       checkDataToFetch();
+       addColumnToConfiguration(header);
+       
 }
 
-function addColumn(column) {
+
+function deleteColumnCells(header) {
+
+       var cells = document.getElementsByName(header);
+       for(var j = 0; j < cells.length; j++) 
+               cells[j].style.display = "none";
+
+}
+
+
+
+function deleteColumn(column) {
 
        var selectedperiod="";
        var header=column;
 
-       //debugfilter("adding column "+column+" and header "+header);
+        selectedperiod = document.getElementById('period'+column).value;
+       header = column+""+selectedperiod;
 
-       if (inTypeC(column)!=-1)
-       {
-               column = column.substring(0,column.length-1);
+       //debugfilter("deleting "+column+","+header);
+
+       deleteColumnCells(header);
+
+       deleteColumnFromConfiguration(header);
+
+       //document.getElementById('check'+column).checked = false;
+}
+
+
+/* 
+EXTRA
+
+//to be used for scrolling the column list with down/up arrows 
+
+function scrollList(tableid) {
+
+debugfilter("here");
+
+if (event.keyCode == 40)
+       debugfilter("down");
+else if (event.keyCode == 38)
+       debugfilter("up");
+
+}
+
+function resetColumns() {
+
+       for (var kk in column_table) {
+
+       if (column_table[kk]['visible'] == true && column_table[kk]['fetch'] == false)
+               deleteColumn(kk);
+       else if (column_table[kk]['visible'] == false && column_table[kk]['fetch'] == true)
+               addColumn(kk, true);
        }
-       else if (document.getElementById('selectperiod'+column))
-       {
-               selectedperiod = document.getElementById('selectperiod'+column).value;
-               header = column+""+selectedperiod;
+
+}
+
+function resetCols(which_conf) {
+
+       var target_configuration = "|"+document.getElementById(which_conf).value+"|";
+       
+       //debugfilter("<p>Target configuration =  "+target_configuration);
+
+       for (var kk in column_table) {
+               //debugfilter("in "+kk+" ");
+
+               if (target_configuration.indexOf("|"+kk+"|")>=0)
+               {
+                       if (document.getElementById('check'+kk))
+                       if (document.getElementById('check'+kk).checked == false)
+                       {
+                               debugfilter("<p>Adding "+kk);
+                               addColumn(kk, true);
+                       }
+               }
+               else
+               {
+                       if (document.getElementById('check'+kk))
+                       if (document.getElementById('check'+kk).checked == true)
+                       {
+                               debugfilter("<p>Deleting "+kk);
+                               deleteColumn(kk);
+                       }
+               }
        }
+}
 
-       //debugfilter("adding "+column+","+header);
+function filterByType(selectedtype) {
 
-       addColumnCells(column, header);
+var notselectedyet = true;
 
-       addColumnToConfiguration(header);
+for (var kk in column_headers) {
+
+       if (document.getElementById(kk))
+       {
+               if (window['type'+kk] == selectedtype)
+               {
+                       document.getElementById(kk).className = 'in';
+                       if (notselectedyet)
+                               highlightOption(kk);
+                       notselectedyet = false;
+               }
+               else
+                       document.getElementById(kk).className = 'out';
+       }
+}
+}
+
+
+function deleteColumnSample() {
+       var cellsheader = document.getElementsByName("confheader"+column);
+       for(var j = 0; j < cellsheader.length; j++) 
+               cellsheader[j].style.display = "none";
 
-       column_table[header]['visible'] = true;
-       
-       checkDataToFetch();
 }
 
 function checkDataToFetch() {
@@ -538,85 +959,9 @@ if (column_table[kk]['visible'] == true && column_table[kk]['fetch'] == false)
        var slice_id = document.getElementById('slice_id').value;
        document.getElementById('loadingDiv').innerHTML = "&nbsp;&nbsp;&nbsp;<img src=/plekit/icons/ajax-loader.gif>&nbsp;Loading data. Please wait ...";
        var url = "/plekit/php/updateColumn.php?slice_id="+slice_id+"&tagName="+tagnames;
-       load_html(headers, url);
-}
-
-function deleteColumnCells(column, header) {
-
-       column_table[header]['visible']=false;
-
-       var cells = document.getElementsByName(header);
-       for(var j = 0; j < cells.length; j++) 
-               cells[j].style.display = "none";
-
-}
-
-function deleteColumnSample() {
-       var cellsheader = document.getElementsByName("confheader"+column);
-       for(var j = 0; j < cellsheader.length; j++) 
-               cellsheader[j].style.display = "none";
-
+       load_data(headers, url);
 }
 
-function deleteColumnFromConfiguration(column) {
-
-
-       var old_configuration = document.getElementById('column_configuration').value;
-       var slice_id = document.getElementById('slice_id').value;
-
-       var old_columns = old_configuration.split("|");
-       var new_columns = new Array();
-
-       for (var column_index = 0; column_index < old_columns.length ; column_index++) {
-               var conf = old_columns[column_index].split(':');
-               if (conf[0] != column)
-                       new_columns.push(old_columns[column_index]);
-       }
-
-       var new_configuration = new_columns.join("|");
-       updateColumnConfiguration(slice_id, new_configuration);
-
-       checkDataToFetch();
-}
-
-function deleteColumn2(column, header) {
-
-       deleteColumnCells(column,header);
-
-       deleteColumnFromConfiguration(column);
-
-       column_table[header]['visible'] = false;
-       document.getElementById('check'+column).checked = false;
-}
-
-function deleteColumn(column) {
-
-       var selectedperiod="";
-       var header=column;
-
-       if (inTypeC(column)!=-1)
-       {
-               column = column.substring(0,column.length-1);
-       }
-       else if (document.getElementById('selectperiod'+column))
-       {
-               selectedperiod = document.getElementById('selectperiod'+column).value;
-               header = column+""+selectedperiod;
-       }
-
-       //debugfilter("deleting "+column+","+header);
-
-       deleteColumnCells(column,header);
-
-       deleteColumnFromConfiguration(header);
-
-       column_table[header]['visible'] = false;
-
-       //document.getElementById('check'+column).checked = false;
-}
-
-
-
 
 /*