cleanup
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 16 Feb 2011 13:16:46 +0000 (14:16 +0100)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 16 Feb 2011 13:16:46 +0000 (14:16 +0100)
planetlab/css/my_slice.css
planetlab/slices/leases.js
planetlab/slices/slice.php
plekit/php/toggle.php
plekit/table/table.css

index 2cf7430..ecb684a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- $Id: toggle.css 12435 2009-03-11 15:07:00Z thierry $
+ Thierry Parmentelat -- INRIA
  */
 
 /* space around various messages */
@@ -25,23 +25,25 @@ div#toggle-container-my-slice-nodes-reserve {
 
 /* where the graphics go */
 div#leases_area {
-  padding: 10px 25px;
+  padding: 10px 20px;
 }
 
 /* this class is used to store data that needs to get passed to javascript code */
-/* these elements re not meant to be rendered */
+/* these elements are not meant to be rendered */
 .hidden {
     display: none;
 }
+.center {
+    text-align: center;
+}
 
 /* the various controls for the scheduler */
-/* upper section, with selection mode */
-#leases_modes { padding: 10px; text-align: center; color: #333; }
-
-#leases_buttons { padding: 0px 10px 10px 10px; }
-#leases_clear { position: relative; left: 30%;}
-#leases_submit { position: relative; left: 60%; }
-        
+/* bottom section with the buttons */
+input.leases_input { width: 28px; text-align: right; }
+.leases_label { padding-left: 12px; padding-right: 8px; }
+#leases_settings { padding: 15px 30px 10px 30px; }
+#leases_buttons { text-align: center; padding: 0px 10px 10px 10px; }
+#leases_refresh,#leases_submit { padding-left: 20px; padding-right: 20px; margin-left: 10px; margin-right:10px; }
 
 /* column configuation style */
 
index 741e32e..ee0efcd 100644 (file)
@@ -1,3 +1,5 @@
+/*  Thierry Parmentelat -- INRIA */
+
 /* need to put some place else in CSS ? */
 
 // space for the nodenames
@@ -72,14 +74,11 @@ function Scheduler () {
     // the names of the hidden fields that hold the input to this class
     // are hard-wired for now
     this.parse_html = function () {
-       window.console.log('in parse_html');
        
        var table = $$("table#leases_data")[0];
        // no reservable nodes - no data
-       if ( ! table) {
-           window.console.log('no table');
-           return false;
-       }
+       if ( ! table) return false;
+
        // the nodelabels
        var data = [], axisx = [], axisy = [];
        table.getElementsBySelector("tbody>tr>th").each(function (cell) {
@@ -87,11 +86,7 @@ function Scheduler () {
        });
        // test for at least one entry; other wise this means we haven't retrieved
        // the html dta yet
-       if (axisy.length <1) {
-           window.console.log('no axisy');
-           window.console.log('have retrieved html text as'+getInnerText(table));
-           return false;
-       }
+       if (axisy.length <1) return false;
 
        // the timeslot labels
        table.getElementsBySelector("thead>tr>th").each(function (cell) {
@@ -115,7 +110,6 @@ function Scheduler () {
        });
 
        this.axisx=axisx;
-       window.console.log('in parse_html, set axisx to'+axisx.length);
        this.axisy=axisy;
        this.data=data;
        return true;
@@ -127,7 +121,6 @@ function Scheduler () {
     ////////////////////
     // draw 
     this.draw_area = function (canvas_id) {
-       window.console.log('in draw_area');
        this.total_width = x_nodelabel + this.nb_grains()*this.leases_w; 
        this.total_height =   2*y_header /* the timelabels */
                            + 2*y_sep    /* extra space */
@@ -150,7 +143,6 @@ function Scheduler () {
        this.timebutton_path="M1,0L"+(this.leases_w-1)+",0L"+(this.leases_w/2)+","+y_header+"L1,0";
 
        var axisx=this.axisx;
-       window.console.log('in draw_area, retrieved axisx' + axisx.length);
        
        var axisy=this.axisy;
        // maintain the list of nodelabels for the 'all nodes' button
@@ -270,7 +262,7 @@ function Scheduler () {
                if (lease.current=='mine') {
                    var j=i+1;
                    while (j<len && lease_methods.compare (lease, until_time, this.leases[j])) {
-//                     window.console.log('merging index='+i+' initial='+this.leases[i].initial+' current='+this.leases[i].current);
+//                     window.console.log('merging index='+i+' initial='+lease.initial+' current='+lease.current);
 //                     window.console.log('merged index='+j+' initial='+this.leases[j].initial+' current='+this.leases[j].current);
                        until_time=this.leases[j].until_time;
                        ++j; ++i;
@@ -322,13 +314,12 @@ function Scheduler () {
     // re-read settings from the html, ajax-aquire the html text for the leases_data table
     // store it in the html tree, parse it, and refresh graphic
     this.refresh = function () {
-       window.console.log('in refresh');
        this.slice_id=getInnerText($$("span#leases_slice_id")[0]).strip();
        this.slicename=getInnerText($$("span#leases_slicename")[0]).strip();
        this.leases_granularity=getInnerText($$("span#leases_granularity")[0]).strip();
-       this.leases_offset=getInnerText($$("span#leases_offset")[0]).strip();
-       this.leases_slots=getInnerText($$("span#leases_slots")[0]).strip();
-       this.leases_w=parseInt(getInnerText($$("span#leases_w")[0]).strip());
+       this.leases_offset=$("leases_offset_input").value.strip();
+       this.leases_slots=$("leases_slots_input").value.strip();
+       this.leases_w=parseInt($("leases_w_input").value.strip());
 
        document.body.style.cursor = "wait";
        var ajax=new Ajax.Request('/planetlab/slices/leases-data.php',
@@ -341,7 +332,7 @@ function Scheduler () {
                                               'leases_w':this.leases_w},
                                   onSuccess: function (transport) {
                                       var response = transport.responseText || "no response text";
-                                      window.console.log("received from ajax=[["+response+"]]");
+//                                    window.console.log("received from ajax=[["+response+"]]");
                                       var scheduler=Scheduler.scheduler;
                                       if ( ! scheduler.set_html (response)) 
                                           alert ("Something wrong .. Could not store ajax result..");
@@ -496,14 +487,11 @@ function init_scheduler () {
     // Grab the data
     var scheduler = new Scheduler ();
     // parse the table with data, and if not empty, draw the scheduler
-    window.console.log('in init_scheduler');
     scheduler.refresh();
     
     // attach behaviour to buttons
-    var refresh=$$("button#leases_refresh")[0];
-    if (refresh) refresh.onclick = function () { scheduler.refresh();}
-    var submit=$$("button#leases_submit")[0];
-    submit.onclick = function () { scheduler.submit(); }
+    $("leases_submit").onclick = function () { scheduler.submit(); }
+    $("leases_refresh").onclick = function () { scheduler.refresh();}
 
 }
 
index 7bd81bc..744a718 100644 (file)
@@ -466,61 +466,45 @@ $show_configuration = "";
 $show_reservable_message = '1';
 $show_columns_message = '1';
 
-
-//$PersonTags=$api->GetPersonTags (array('person_id'=>$plc->person['person_id']));
 $PersonTags=$api->GetPersonTags (array('person_id'=>$plc->person['person_id']));
-//print_r($PersonTags);
+//plc_debug('ptags',$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'];
-       }
+  if ($ptag['tagname'] == 'columnconf') {
+    $column_configuration = $ptag['value'];
+    $conf_tag_id = $ptag['person_tag_id'];
+  } else if ($ptag['tagname'] == 'showconf') {
+    $show_configuration = $ptag['value'];
+    $show_tag_id = $ptag['person_tag_id'];
+  }
 }
 
-//print("<br>person column configuration = ".$column_configuration);
-//print("<br>person show configuration = ".$show_configuration);
-
 $sliceconf_exists = false;
-if ($column_configuration == "")
-{
-       $first_time_configuration = true;
-       $column_configuration = $slice_id.";default";
-       $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];
-               }
-       }        
+if ($column_configuration == "") {
+  $first_time_configuration = true;
+  $column_configuration = $slice_id.";default";
+  $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];
+    }
+  }        
 }
 
 if ($sliceconf_exists == false)
-       $column_configuration = $column_configuration.";".$slice_id.";default";
-
-//print("<br>slice configuration = ".$slice_column_configuration);
-
+  $column_configuration = $column_configuration.";".$slice_id.";default";
 
 if ($slice_column_configuration == "")
-       $full_configuration = $default_configuration;
+  $full_configuration = $default_configuration;
 else
-       $full_configuration = $default_configuration."|".$slice_column_configuration;
+  $full_configuration = $default_configuration."|".$slice_column_configuration;
 
 
 //instantiate the column configuration class, which prepares the headers array
@@ -529,23 +513,18 @@ $ConfigureColumns =new PlekitColumns($full_configuration, $fix_columns, $tag_col
 $visiblecolumns = $ConfigureColumns->node_tags();
 
 $node_columns=array_merge($node_fixed_columns,$visiblecolumns);
-//print_r($node_columns);
 $all_nodes=$api->GetNodes(NULL,$node_columns);
 
 $ConfigureColumns->fetch_live_data($all_nodes);
 
-//print("<br>person show configuration = ".$show_configuration);
-
 $show_conf = explode(";",$show_configuration);
 foreach ($show_conf as $ss) {
-       if ($ss =="reservable")
-               $show_reservable_message = '0';
-       if ($ss =="columns")
-               $show_columns_message = '0';
+  if ($ss =="reservable")
+    $show_reservable_message = '0';
+  else if ($ss =="columns")
+    $show_columns_message = '0';
 }        
 
-//print("res:".$show_reservable_message." - cols:".$show_columns_message);
-
 $slice_nodes=array();
 $potential_nodes=array();
 $reservable_nodes=array();
@@ -576,13 +555,13 @@ 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'=>$show_reservable_message, 'info_div'=>'note_reservable_div'));
+                                array('visible'=>get_arg('show_nodes_resa',false), 'info_div'=>'note_reservable_div'));
   $toggle_nodes->start();
 
 if ($show_reservable_message) 
-$note_display = "";
+  $note_display = "";
 else
-$note_display = "display:none;";
+  $note_display = "display:none;";
 
 ////////// show a notice to people having attached a reservable node
 if (count($reservable_nodes) && $privileges) {
@@ -610,10 +589,10 @@ EOF;
   if ( ! $leases_offset ) $leases_offset=0;
   // how many timeslots to show
   $leases_slots=$_GET['leases_slots'];
-  if ( ! $leases_slots ) $leases_slots = 36;
+  if ( ! $leases_slots ) $leases_slots = 48;
   // offset in hours (in the future) from now 
   $leases_w = $_GET['leases_w'];
-  if ( ! $leases_w) $leases_w=20;
+  if ( ! $leases_w) $leases_w=14;
   // number of timeslots to display
 
   $granularity=$api->GetLeaseGranularity();
@@ -622,9 +601,15 @@ EOF;
   echo "<span class='hidden' id='leases_slicename'>" . $slice['name'] . "</span>";
   echo "<span class='hidden' id='leases_slice_id'>" . $slice['slice_id']. "</span>";
   echo "<span class='hidden' id='leases_granularity'>" . $granularity . "</span>";
-  echo "<span class='hidden' id='leases_offset'>" . $leases_offset . "</span>";
-  echo "<span class='hidden' id='leases_slots'>" . $leases_slots . "</span>";
-  echo "<span class='hidden' id='leases_w'>" . $leases_w . "</span>";
+  // ditto, and editable - very rough for now
+  echo "<div class='center' id='leases_settings'>";
+  echo "<label id='leases_offset_label' class='leases_label'>start, in hours from now</label>";
+  echo "<input type='text' class='leases_input' id='leases_offset_input' value='$leases_offset' />";
+  echo "<label id='leases_slots_label' class='leases_label'># of timeslots</label>";
+  echo "<input type='text' class='leases_input' id='leases_slots_input' value='$leases_slots' />";
+  echo "<label id='leases_w_label' class='leases_label'>slot width, in pixels</label>";
+  echo "<input type='text' class='leases_input' id='leases_w_input' value='$leases_w' />";
+  echo "</div>";
 
   // leases_data is the name used by leases.js to locate this place
   // first population will be triggered by init_scheduler from leases.js
@@ -645,7 +630,6 @@ EOF;
 
 
 //////////////////// node configuration panel
-
 if ($first_time_configuration) 
 $column_conf_visible = '1';
 else
@@ -674,9 +658,9 @@ print("<input type='hidden' id='defaultConf' value='".$default_configuration."'
 
 //print ("showing column message = ".$show_columns_message);
 if ($show_columns_message == '0') 
-$note_display = "display:none;";
+  $note_display = "display:none;";
 else
-$note_display = "";
+  $note_display = "";
 
   print <<<EOF
 <div id='note_columns_div' style="align:center; background-color:#CAE8EA; padding:4px; width:800px; $note_display">
index 038b302..98085a6 100644 (file)
@@ -1,7 +1,5 @@
 <?php
 
-  // $Id$
-
 require_once 'prototype.php';
 require_once 'nifty.php';
 
@@ -106,7 +104,7 @@ class PlekitToggle {
     $html .= $this->trigger;
     $html .= "</$tagname>";
     if ($this->info_div != "")
-    $html .= "&nbsp;(<a href=javascript:plc_show_toggle_info('$this->info_div','$this->id')>?</a>)";
+      $html .= "&nbsp;(<a href=javascript:plc_show_toggle_info('$this->info_div','$this->id')>?</a>)";
     return $html;
   }
 
index cb38819..725c18b 100644 (file)
@@ -1,4 +1,5 @@
-/* $Id$ */
+/* Thierry Parmentelat - INRIA */
+
 table.plekit_table {
     width: auto;
     padding: 0;