paginate the list of buildroots an archive has been included in

This commit is contained in:
Mike Bonnet 2009-06-12 14:47:22 -04:00
parent d8055a2274
commit cd6733167f
2 changed files with 39 additions and 12 deletions

View file

@ -2,6 +2,8 @@
#from kojiweb import util
#import urllib
#attr _PASSTHROUGH = ['archiveID', 'fileOrder', 'fileStart', 'buildrootOrder', 'buildrootStart']
#include "includes/header.chtml"
<h4>Information for archive $archive.filename</h4>
@ -50,7 +52,7 @@
#if $len($filePages) > 1
<form class="pageJump">
Page:
<select onchange="javascript: window.location = 'archiveinfo?fileStart=' + this.value * $fileRange + '$util.passthrough($self, 'archiveID', 'fileOrder')#filelist';">
<select onchange="javascript: window.location = 'archiveinfo?fileStart=' + this.value * $fileRange + '$util.passthrough_except($self, 'fileStart')#filelist';">
#for $pageNum in $filePages
<option value="$pageNum"#if $pageNum == $fileCurrentPage then ' selected' else ''#>#echo $pageNum + 1#</option>
#end for
@ -58,17 +60,17 @@
</form>
#end if
#if $fileStart > 0
<a href="archiveinfo?fileStart=#echo $fileStart - $fileRange #$util.passthrough($self, 'archiveID', 'fileOrder')#filelist">&lt;&lt;&lt;</a>
<a href="archiveinfo?fileStart=#echo $fileStart - $fileRange#$util.passthrough_except($self, 'fileStart')#filelist">&lt;&lt;&lt;</a>
#end if
<strong>#echo $fileStart + 1 # through #echo $fileStart + $fileCount # of $totalFiles</strong>
#if $fileStart + $fileCount < $totalFiles
<a href="archiveinfo?fileStart=#echo $fileStart + $fileRange#$util.passthrough($self, 'archiveID', 'fileOrder')#filelist">&gt;&gt;&gt;</a>
<a href="archiveinfo?fileStart=#echo $fileStart + $fileRange#$util.passthrough_except($self, 'fileStart')#filelist">&gt;&gt;&gt;</a>
#end if
</td>
</tr>
<tr class="list-header">
<th><a href="archiveinfo?fileOrder=$util.toggleOrder($self, 'name', 'fileOrder')$util.passthrough($self, 'archiveID')#filelist">Name</a> $util.sortImage($self, 'name', 'fileOrder')</th>
<th><a href="archiveinfo?fileOrder=$util.toggleOrder($self, 'size', 'fileOrder')$util.passthrough($self, 'archiveID')#filelist">Size</a> $util.sortImage($self, 'size', 'fileOrder')</th>
<th><a href="archiveinfo?fileOrder=$util.toggleOrder($self, 'name', 'fileOrder')$util.passthrough_except($self, 'fileOrder', 'fileStart')#filelist">Name</a> $util.sortImage($self, 'name', 'fileOrder')</th>
<th><a href="archiveinfo?fileOrder=$util.toggleOrder($self, 'size', 'fileOrder')$util.passthrough_except($self, 'fileOrder', 'fileStart')#filelist">Size</a> $util.sortImage($self, 'size', 'fileOrder')</th>
</tr>
#for $file in $files
<tr class="$util.rowToggle($self)">
@ -82,24 +84,48 @@
</td>
</tr>
<tr>
<th>Component&nbsp;of</th>
<th id="buildrootlist">Component&nbsp;of</th>
<td class="container">
#if $len($buildroots) > 0
<table class="nested data-list">
<tr>
<td class="paginate" colspan="3">
#if $len($buildrootPages) > 1
<form class="pageJump" action="">
Page:
<select onchange="javascript: window.location = 'archiveinfo?buildrootStart=' + this.value * $buildrootRange + '$util.passthrough_except($self, 'buildrootStart')#buildrootlist';">
#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="archiveinfo?buildrootStart=#echo $buildrootStart - $buildrootRange #$util.passthrough_except($self, 'buildrootStart')#buildrootlist">&lt;&lt;&lt;</a>
#end if
<strong>#echo $buildrootStart + 1 # through #echo $buildrootStart + $buildrootCount # of $totalBuildroots</strong>
#if $buildrootStart + $buildrootCount < $totalBuildroots
<a href="archiveinfo?buildrootStart=#echo $buildrootStart + $buildrootRange#$util.passthrough_except($self, 'buildrootStart')#buildrootlist">&gt;&gt;&gt;</a>
#end if
</td>
</tr>
<tr class="list-header">
<th>Buildroot</th><th>State</th>
<th><a href="archiveinfo?buildrootOrder=$util.toggleOrder($self, 'id', 'buildrootOrder')$util.passthrough_except($self, 'buildrootOrder', 'buildrootStart')#buildrootlist">Buildroot</a> $util.sortImage($self, 'id', 'buildrootOrder')</th>
<th><a href="archiveinfo?buildrootOrder=$util.toggleOrder($self, 'create_event_time', 'buildrootOrder')$util.passthrough_except($self, 'buildrootOrder', 'buildrootStart')#buildrootlist">Created</a> $util.sortImage($self, 'create_event_time', 'buildrootOrder')</th>
<th><a href="archiveinfo?buildrootOrder=$util.toggleOrder($self, 'state', 'buildrootOrder')$util.passthrough_except($self, 'buildrootOrder', 'buildrootStart')#buildrootlist">State</a> $util.sortImage($self, 'state', 'buildrootOrder')</th>
</tr>
#for $buildroot in $buildroots
<tr class="$util.rowToggle($self)">
<td><a href="buildrootinfo?buildrootID=$buildroot.id">$buildroot.tag_name-$buildroot.id-$buildroot.repo_id</a></td>
<td>$util.formatTime($buildroot.create_event_time)</td>
<td>$util.imageTag($util.brStateName($buildroot.state))</td>
</tr>
#end for
</table>
#else
No Buildroots
No buildroots
#end if
</td>
</td>
</tr>
</table>

View file

@ -1224,7 +1224,7 @@ def rpminfo(req, rpmID, fileOrder='name', fileStart=None, buildrootOrder='-id',
return _genHTML(req, 'rpminfo.chtml')
def archiveinfo(req, archiveID, fileOrder='name', fileStart=None):
def archiveinfo(req, archiveID, fileOrder='name', fileStart=None, buildrootOrder='-id', buildrootStart=None):
values = _initValues(req, 'Archive Info', 'builds')
server = _getServer(req)
@ -1238,8 +1238,9 @@ def archiveinfo(req, archiveID, fileOrder='name', fileStart=None):
builtInRoot = server.getBuildroot(archive['buildroot_id'])
files = kojiweb.util.paginateMethod(server, values, 'listArchiveFiles', args=[archive['id']],
start=fileStart, dataName='files', prefix='file', order=fileOrder)
buildroots = server.listBuildroots(archiveID=archive['id'])
buildroots.sort(kojiweb.util.sortByKeyFunc('-create_event_time'))
buildroots = kojiweb.util.paginateMethod(server, values, 'listBuildroots', kw={'archiveID': archive['id']},
start=buildrootStart, dataName='buildroots', prefix='buildroot',
order=buildrootOrder)
values['title'] = archive['filename'] + ' | Archive Info'