#import koji
#from kojiweb import util

#attr _PASSTHROUGH = ['repoID', 'order', 'state']

#include "includes/header.chtml"

  <h4>Buildroots in repo <a href="repoinfo?repoID=$repoID">$repoID</a></h4>

  <table class="data-list">
  <tr>
      <td colspan="5">
        <table class="nested">
        <tr><td>
        <strong>State</strong>:
        </td><td>
        <select name="state" class="filterlist" onchange="javascript: window.location = 'buildroots?state=' + this.value + '$util.passthrough_except($self, 'state')';">
          <option value="all">all</option>
          #for $stateOpt in ['INIT', 'WAITING', 'BUILDING', 'EXPIRED']
          <option value="$koji.BR_STATES[$stateOpt]" #if $state == $koji.BR_STATES[$stateOpt] then 'selected="selected"' else ''#>$stateOpt.lower()</option>
          #end for
        </select>
        </table>
        </td>
       </tr>
      <tr>
      <td class="paginate" colspan="5">
        #if $len($buildrootPages) > 1
        <form class="pageJump" action="">
          Page:
          <select onchange="javascript: window.location = 'builds?start=' + this.value * $buildrootRange + '$util.passthrough_except($self)';">
            #for $pageNum in $buildrootPages
            <option value="$pageNum"#if $pageNum == $buildrootCurrentPage then ' selected="selected"' else ''#>#echo $pageNum + 1#</option>
            #end for
          </select>
        </form>
        #end if
        #if $buildrootStart > 0
        <a href="builds?start=#echo $buildrootStart - $buildrootRange #$util.passthrough_except($self)">&lt;&lt;&lt;</a>
        #end if
        #if $totalBuildroots != 0
        <strong>Buildroots #echo $buildrootStart + 1 # through #echo $buildrootStart + $buildrootCount # of $totalBuildroots</strong>
        #end if
        #if $buildrootStart + $buildrootCount < $totalBuildroots
        <a href="builds?start=#echo $buildrootStart + $buildrootRange#$util.passthrough_except($self)">&gt;&gt;&gt;</a>
        #end if
      </td>
    </tr>
    <tr class="list-header">
      <th><a href="buildroots?order=$util.toggleOrder($self, 'id')$util.passthrough_except($self, 'order')">BuildrootID</a> $util.sortImage($self, 'id')</th>
      <th><a href="buildroots?order=$util.toggleOrder($self, 'repo_id')$util.passthrough_except($self, 'order')">Repo ID</a> $util.sortImage($self, 'repo_id')</th>
      <th><a href="buildroots?order=$util.toggleOrder($self, 'task_id')$util.passthrough_except($self, 'order')">Task ID</a> $util.sortImage($self, 'task_id')</th>
      <th><a href="buildroots?order=$util.toggleOrder($self, 'tag_name')$util.passthrough_except($self, 'order')">Tag name</a> $util.sortImage($self, 'tag_name')</th>
      <th><a href="buildroots?order=$util.toggleOrder($self, 'state')$util.passthrough_except($self, 'order')">State</a> $util.sortImage($self, 'state')</th>
    </tr>
    #if $len($buildroots) > 0
      #for $buildroot in $buildroots
        <tr class="$util.rowToggle($self)">
          <td><a href="buildrootinfo?buildrootID=$buildroot.id">$buildroot.id</a></td>
          <td><a href="repoinfo?repoID=$buildroot.repo_id">$buildroot.repo_id</a></td>
          <td><a href="taskinfo?taskID=$buildroot.task_id">$buildroot.task_id</a></td>
          <td><a href="taginfo?tagID=$buildroot.tag_id">$util.escapeHTML($buildroot.tag_name)</a></td>
          #set $stateName = $util.brStateName($buildroot.state)
          <td class="$stateName">$util.brStateImage($buildroot.state)</td>
        </tr>
      #end for
    #else
      <tr class="row-odd">
        <td colspan="5">No buildroots</td>
      </tr>
    #end if
    <tr>
      <td class="paginate" colspan="5">
        #if $len($buildrootPages) > 1
        <form class="pageJump" action="">
          Page:
          <select onchange="javascript: window.location = 'builds?start=' + this.value * $buildrootRange + '$util.passthrough_except($self)';">
            #for $pageNum in $buildrootPages
            <option value="$pageNum"#if $pageNum == $buildrootCurrentPage then ' selected="selected"' else ''#>#echo $pageNum + 1#</option>
            #end for
          </select>
        </form>
        #end if
        #if $buildrootStart > 0
        <a href="builds?start=#echo $buildrootStart - $buildrootRange #$util.passthrough_except($self)">&lt;&lt;&lt;</a>
        #end if
        #if $totalBuildroots != 0
        <strong>Buildroots #echo $buildrootStart + 1 # through #echo $buildrootStart + $buildrootCount # of $totalBuildroots</strong>
        #end if
        #if $buildrootStart + $buildrootCount < $totalBuildroots
        <a href="builds?start=#echo $buildrootStart + $buildrootRange#$util.passthrough_except($self)">&gt;&gt;&gt;</a>
        #end if
      </td>
    </tr>
  </table>

#include "includes/footer.chtml"
