var y_sep = 10;
// 1-grain leases attributes
-var x_grain = 24;
+var x_grain = 20;
var y_node = 15;
var radius= 6;
// vertical rules
var attr_rules={'fill':"#888", 'stroke-dasharray':'- ', 'stroke-width':0.5};
-var txt_timelabel = {"font": '"Trebuchet MS", Verdana, Arial, Helvetica, sans-serif', stroke: "none", fill: "#008"};
+// set font-size separately in here rather than depend on the height
+var txt_timelabel = {"font": 'Times, "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif',
+ stroke: "none", fill: "#008", 'font-size': 9};
var txt_allnodes = {"font": '"Trebuchet MS", Verdana, Arial, Helvetica, sans-serif', stroke: "none", fill: "#404"};
var txt_nodelabel = {"font": '"Trebuchet MS", Verdana, Arial, Helvetica, sans-serif', stroke: "none", fill: "#008"};
var attr_timebutton = {'fill':'#bbf', 'stroke': '#338','stroke-width':2,
'stroke-linecap':'round', 'stroke-linejoin':'miter', 'stroke-miterlimit':3};
// keep consistent with sizes above - need for something nicer
-var timebutton_path = "M1,0L23,0L12,13L1,0";
+var timebutton_path = "M1,0L19,0L10,8L1,0";
/* lease dimensions and colors */
/* refrain from using gradient color, seems to not be animated properly */
col +=1;
// display time label
var timelabel=paper.text(left,y,timelabel).attr(txt_timelabel)
- .attr({"font-size":y_header, "text-anchor":"middle"});
+ .attr({"text-anchor":"middle"});
// draw vertical line
var path_spec="M"+left+" "+(y+y_header/2)+"L"+left+" "+this.total_height;
var rule=paper.path(path_spec).attr(attr_rules);
array('visible'=>get_arg('show_nodes_resa',false)));
$toggle_nodes->start();
$grain=$api->GetLeaseGranularity();
+ // 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
- $now=time();
- // xxx ditto,
+ $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=min(72*3600,72*$grain);
+ $duration=$resa_slots*$grain;
$steps=$duration/$grain;
- $start=intval($now/$grain)*$grain;
- $end=$now+$duration;
+ $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'=>$now,'[t_from'=>$end,'-SORT'=>'t_from'),$lease_columns);
+ $leases=$api->GetLeases(array(']t_until'=>$rough_start,'[t_from'=>$end,'-SORT'=>'t_from'),$lease_columns);
// hash nodes -> leases
$host_hash=array();
foreach ($leases as $lease) {
}
# leases_data is the name used by leases.js to locate this table
echo "<table id='leases_data'>";
- # pass the slicename as the [0,0] coordinate as thead>tr>td
+ # pass (slice_id,slicename) as the [0,0] coordinate as thead>tr>td
echo "<thead><tr><td>" . $slice['slice_id'] . '&' . $slice['name'] . "</td>";
- for ($i=0; $i<$steps; $i++)
+ # 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>" . ($start+$i*$grain) . "&" . strftime("%H:%M",$start+$i*$grain). "</th>";
+ 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;}