##
## Licensed to the Apache Software Foundation (ASF) under one
## or more contributor license agreements.  See the NOTICE file
## distributed with this work for additional information
## regarding copyright ownership.  The ASF licenses this file
## to you under the Apache License, Version 2.0 (the
## "License"); you may not use this file except in compliance
## with the License.  You may obtain a copy of the License at
##
##     http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.

#macro( makeChart $attr_map )
#if ($attr_map.type == "bar") 
  <script>
    makeBarChart($attr_map.labelStr, $attr_map.boundaryStr, $attr_map.dataStr);
  </script>
#end

#if ($attr_map.type == "dot") 
  <script>
    makeDotChart($attr_map.dataStr);
  </script>
#end
#end

#macro( makeChartHeader $attr_map )
#if ($attr_map.type == "bar") 
  <p>
    $attr_map.title <br>
    Average: $attr_map.avg$attr_map.units<br>
    Stdev: $attr_map.stdDev$attr_map.units
  </p>
#end

#if ($attr_map.type == "dot") 
  <p>
    $attr_map.title <br>
    Most recent calls
  </p>
#end
#end

<html>
<head>
<title>$title</title>
<script type="text/javascript" src="static/protovis-r3.2.js"></script>
<script type="text/javascript" src="static/tipsy.js"></script>
<script src="static/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="static/jquery.tipsy.js" type="text/javascript"></script>
<script src="static/tipsy.js" type="text/javascript"></script>
<link href="static/tipsy.css" type="text/css" rel="stylesheet"/>
<script src="static/avro.js" type="text/javascript"></script>
<link href="static/avro.css" type="text/css" rel="stylesheet"/>

<script>

</script>
</head>
<body>
  <h1>$title</h1>
  <p>
    Running since: $startupTime<br>
    Currently: $currTime
  </p>
  
  #if ($inFlightRpcs.size() != 0) 
  <h4>Active RPC's</h4>
    <ol>
    #foreach( $rpc in $inFlightRpcs ) 
      <li>$rpc</li>
    #end
    </ol>
  #end
    #foreach ($message in $messages)
    #set( $width = $message.charts.size() * 300 ) 
    <table id="charts_table" width=$width>
      <h3>$message.name ($message.numCalls calls)</h3>
      <tr valign="top">
      #foreach ($chart in $message.charts)
        <td>#makeChartHeader($chart) </td>
      #end
      </tr>
      <tr>
      #foreach ($chart in $message.charts)
        <td>#makeChart($chart) </td>
      #end
      </tr>
    </table>
    #end

</body>
</html>