#from kojiweb import util

#def printOption(value, label=None)
#if not $label
#set $label = $value
#end if
<option value="$value"#if $value == $days then ' selected="selected"' else ''#>$label</option>
#end def

#set $numTotal = $numSucceeded + $numFailed + $numCanceled

#include "includes/header.chtml"

  <h4>Succeeded/Failed/Canceled Builds#if $days != -1 then ' in the last %i days' % $days else ''#</h4>
  <table class="data-list">
    <tr style="text-align: left">
      <td colspan="3">
        <form action="">
          Show last
          <select onchange="javascript: window.location = 'buildsbystatus?days=' + this.value;">
            $printOption(1)
            $printOption(3)
            $printOption(5)
            $printOption(7)
            $printOption(14)
            $printOption(30)
            $printOption(60)
            $printOption(90)
            $printOption(120)
            $printOption(180)
            $printOption(365)
            $printOption(-1, 'all')
          </select> days
        </form>
      </td>
    </tr>
    <tr class="list-header">
      <th>Type</th>
      <th>Builds</th>
      <th>&nbsp;</th>
    </tr>
    <tr class="row-odd taskclosed">
      <td>Succeeded</td>
      <td width="#echo $graphWidth + 5#"><img src="$util.themePath('images/1px.gif')" width="#echo $increment * $numSucceeded#" height="15" class="graphrow" alt="graph row"/></td>
      <td>$numSucceeded</td>
    </tr>
    <tr class="row-even taskfailed">
      <td>Failed</td>
      <td width="#echo $graphWidth + 5#"><img src="$util.themePath('images/1px.gif')" width="#echo $increment * $numFailed#" height="15" class="graphrow" alt="graph row"/></td>
      <td>$numFailed</td>
    </tr>
    <tr class="row-odd taskcanceled">
      <td>Canceled</td>
      <td width="#echo $graphWidth + 5#"><img src="$util.themePath('images/1px.gif')" width="#echo $increment * $numCanceled#" height="15" class="graphrow" alt="graph row"/></td>
      <td>$numCanceled</td>
    </tr>
    <tr class="row-even">
      <td>Total</td>
      <td></td>
      <td>$numTotal</td>
    </tr>
  </table>

#include "includes/footer.chtml"
