#from kojiweb import util

#include "includes/header.chtml"
#
#def getID()
  #if $type == 'image'
imageID=$image.id #slurp
  #else
buildrootID=$buildroot.id #slurp
  #end if
#end def

  #if $type == 'component'
  <h4>Component Archives of buildroot <a href="buildrootinfo?buildrootID=$buildroot.id">$util.brLabel($buildroot)</a></h4>
  #elif $type == 'image'
  <h4>Archives installed in <a href="archiveinfo?archiveID=$image.id">$image.filename</a></h4>
  #else
  <h4>Archives built in buildroot <a href="buildrootinfo?buildrootID=$buildroot.id">$util.brLabel($buildroot)</a></h4>
  #end if

  <table class="data-list">
    <tr>
      <td class="paginate" colspan="#if $type == 'component' then '3' else '2'#">
        #if $len($archivePages) > 1
        <form class="pageJump">
          Page:
          <select onchange="javascript: window.location = 'archivelist?$getID()&start=' + this.value * $archiveRange + '$util.passthrough($self, 'order', 'type')';">
            #for $pageNum in $archivePages
            <option value="$pageNum"#if $pageNum == $archiveCurrentPage then ' selected' else ''#>#echo $pageNum + 1#</option>
            #end for
          </select>
        </form>
        #end if
        #if $archiveStart > 0
        <a href="archivelist?$getID()&start=#echo $archiveStart - $archiveRange #$util.passthrough($self, 'order', 'type')">&lt;&lt;&lt;</a>
        #end if
        #if $totalArchives != 0
        <strong>Archives #echo $archiveStart + 1 # through #echo $archiveStart + $archiveCount # of $totalArchives</strong>
        #end if
        #if $archiveStart + $archiveCount < $totalArchives
        <a href="archivelist?$getID()&start=#echo $archiveStart + $archiveRange#$util.passthrough($self, 'order', 'type')">&gt;&gt;&gt;</a>
        #end if
      </td>
    </tr>
    <tr class="list-header">
      <th><a href="archivelist?$getID()&order=$util.toggleOrder($self, 'filename')$util.passthrough($self, 'type')">Filename</a> $util.sortImage($self, 'filename')</th>
      <th><a href="archivelist?$getID()&order=$util.toggleOrder($self, 'type_name')$util.passthrough($self, 'type')">Type</a> $util.sortImage($self, 'type_name')</th>
      #if $type == 'component'
      <th><a href="archivelist?$getID()&order=$util.toggleOrder($self, 'project')$util.passthrough($self, 'type')">Build Dependency?</a> $util.sortImage($self, 'project')</th>
      #end if
    </tr>
    #if $len($archives) > 0
    #for $archive in $archives
    <tr class="$util.rowToggle($self)">
      <td><a href="archiveinfo?archiveID=$archive.id">$archive.filename</a></td>
      <td>$archive.type_name</td>
      #if $type == 'component'
      #set $project = $archive.project and 'yes' or 'no'
      <td class="$project">$util.imageTag($project)</td>
      #end if
    </tr>
    #end for
    #else
    <tr class="row-odd">
      <td colspan="#if $type == 'component' then '3' else '2'#">No Archives</td>
    </tr>
    #end if
    <tr>
      <td class="paginate" colspan="#if $type == 'component' then '3' else '2'#">
        #if $len($archivePages) > 1
        <form class="pageJump">
          Page:
          <select onchange="javascript: window.location = 'archivelist?$getID()&start=' + this.value * $archiveRange + '$util.passthrough($self, 'order', 'type')';">
            #for $pageNum in $archivePages
            <option value="$pageNum"#if $pageNum == $archiveCurrentPage then ' selected' else ''#>#echo $pageNum + 1#</option>
            #end for
          </select>
        </form>
        #end if
        #if $archiveStart > 0
        <a href="archivelist?$getID()&start=#echo $archiveStart - $archiveRange #$util.passthrough($self, 'order', 'type')">&lt;&lt;&lt;</a>
        #end if
        #if $totalArchives != 0
        <strong>Archives #echo $archiveStart + 1 # through #echo $archiveStart + $archiveCount # of $totalArchives</strong>
        #end if
        #if $archiveStart + $archiveCount < $totalArchives
        <a href="archivelist?$getID()&start=#echo $archiveStart + $archiveRange#$util.passthrough($self, 'order', 'type')">&gt;&gt;&gt;</a>
        #end if
      </td>
    </tr>
  </table>

#include "includes/footer.chtml"
