- allow filtering by enabled/disabled on the hosts page (default to showing only enabled hosts)
This commit is contained in:
parent
c81079b551
commit
5b11e90fea
3 changed files with 49 additions and 16 deletions
|
|
@ -6239,9 +6239,15 @@ class RootExports(object):
|
|||
joins.append('host_channels on host.id = host_channels.host_id')
|
||||
clauses.append('host_channels.channel_id = %(channelID)i')
|
||||
if ready != None:
|
||||
clauses.append('ready is %s' % ready)
|
||||
if ready:
|
||||
clauses.append('ready is true')
|
||||
else:
|
||||
clauses.append('ready is false')
|
||||
if enabled != None:
|
||||
clauses.append('enabled is %s' % enabled)
|
||||
if enabled:
|
||||
clauses.append('enabled is true')
|
||||
else:
|
||||
clauses.append('enabled is false')
|
||||
if userID != None:
|
||||
clauses.append('user_id = %(userID)i')
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,32 @@
|
|||
#from kojiweb import util
|
||||
|
||||
#attr _PASSTHROUGH = ['state', 'order']
|
||||
|
||||
#include "includes/header.chtml"
|
||||
|
||||
<h4>Hosts</h4>
|
||||
<table class="data-list">
|
||||
<tr>
|
||||
<td colspan="6">
|
||||
<table class="nested">
|
||||
<tr><td>
|
||||
<strong>State</strong>:
|
||||
</td><td>
|
||||
<select name="state" class="filterlist" onchange="javascript: window.location = 'hosts?state=' + this.value + '$util.passthrough_except($self, 'state')';">
|
||||
<option value="enabled" #if $state == 'enabled' then 'selected="selected"' else ''#>enabled</option>
|
||||
<option value="disabled" #if $state == 'disabled' then 'selected="selected"' else ''#>disabled</option>
|
||||
<option value="all" #if $state == 'all' then 'selected="selected"' else ''#>all</option>
|
||||
</select>
|
||||
</td></tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paginate" colspan="6">
|
||||
#if $len($hostPages) > 1
|
||||
<form class="pageJump" action="">
|
||||
Page:
|
||||
<select onchange="javascript: window.location = 'hosts?start=' + this.value * $hostRange + '$util.passthrough($self, 'order')';">
|
||||
<select onchange="javascript: window.location = 'hosts?start=' + this.value * $hostRange + '$util.passthrough_except($self)';">
|
||||
#for $pageNum in $hostPages
|
||||
<option value="$pageNum"#if $pageNum == $hostCurrentPage then ' selected="selected"' else ''#>#echo $pageNum + 1#</option>
|
||||
#end for
|
||||
|
|
@ -17,23 +34,23 @@
|
|||
</form>
|
||||
#end if
|
||||
#if $hostStart > 0
|
||||
<a href="hosts?start=#echo $hostStart - $hostRange #$util.passthrough($self, 'order')"><<<</a>
|
||||
<a href="hosts?start=#echo $hostStart - $hostRange #$util.passthrough_except($self)"><<<</a>
|
||||
#end if
|
||||
#if $totalHosts != 0
|
||||
<strong>Hosts #echo $hostStart + 1 # through #echo $hostStart + $hostCount # of $totalHosts</strong>
|
||||
#end if
|
||||
#if $hostStart + $hostCount < $totalHosts
|
||||
<a href="hosts?start=#echo $hostStart + $hostRange#$util.passthrough($self, 'order')">>>></a>
|
||||
<a href="hosts?start=#echo $hostStart + $hostRange#$util.passthrough_except($self)">>>></a>
|
||||
#end if
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="list-header">
|
||||
<th><a href="hosts?order=$util.toggleOrder($self, 'id')">ID</a> $util.sortImage($self, 'id')</th>
|
||||
<th><a href="hosts?order=$util.toggleOrder($self, 'name')">Name</a> $util.sortImage($self, 'name')</th>
|
||||
<th><a href="hosts?order=$util.toggleOrder($self, 'arches')">Arches</a> $util.sortImage($self, 'arches')</th>
|
||||
<th><a href="hosts?order=$util.toggleOrder($self, 'enabled')">Enabled?</a> $util.sortImage($self, 'enabled')</th>
|
||||
<th><a href="hosts?order=$util.toggleOrder($self, 'ready')">Ready?</a> $util.sortImage($self, 'ready')</th>
|
||||
<th><a href="hosts?order=$util.toggleOrder($self, 'last_update')">Last Update</a> $util.sortImage($self, 'last_update')</th>
|
||||
<th><a href="hosts?order=$util.toggleOrder($self, 'id')$util.passthrough_except($self, 'order')">ID</a> $util.sortImage($self, 'id')</th>
|
||||
<th><a href="hosts?order=$util.toggleOrder($self, 'name')$util.passthrough_except($self, 'order')">Name</a> $util.sortImage($self, 'name')</th>
|
||||
<th><a href="hosts?order=$util.toggleOrder($self, 'arches')$util.passthrough_except($self, 'order')">Arches</a> $util.sortImage($self, 'arches')</th>
|
||||
<th><a href="hosts?order=$util.toggleOrder($self, 'enabled')$util.passthrough_except($self, 'order')">Enabled?</a> $util.sortImage($self, 'enabled')</th>
|
||||
<th><a href="hosts?order=$util.toggleOrder($self, 'ready')$util.passthrough_except($self, 'order')">Ready?</a> $util.sortImage($self, 'ready')</th>
|
||||
<th><a href="hosts?order=$util.toggleOrder($self, 'last_update')$util.passthrough_except($self, 'order')">Last Update</a> $util.sortImage($self, 'last_update')</th>
|
||||
</tr>
|
||||
#if $len($hosts) > 0
|
||||
#for $host in $hosts
|
||||
|
|
@ -56,7 +73,7 @@
|
|||
#if $len($hostPages) > 1
|
||||
<form class="pageJump" action="">
|
||||
Page:
|
||||
<select onchange="javascript: window.location = 'hosts?start=' + this.value * $hostRange + '$util.passthrough($self, 'order')';">
|
||||
<select onchange="javascript: window.location = 'hosts?start=' + this.value * $hostRange + '$util.passthrough_except($self)';">
|
||||
#for $pageNum in $hostPages
|
||||
<option value="$pageNum"#if $pageNum == $hostCurrentPage then ' selected="selected"' else ''#>#echo $pageNum + 1#</option>
|
||||
#end for
|
||||
|
|
@ -64,13 +81,13 @@
|
|||
</form>
|
||||
#end if
|
||||
#if $hostStart > 0
|
||||
<a href="hosts?start=#echo $hostStart - $hostRange #$util.passthrough($self, 'order')"><<<</a>
|
||||
<a href="hosts?start=#echo $hostStart - $hostRange #$util.passthrough_except($self)"><<<</a>
|
||||
#end if
|
||||
#if $totalHosts != 0
|
||||
<strong>Hosts #echo $hostStart + 1 # through #echo $hostStart + $hostCount # of $totalHosts</strong>
|
||||
#end if
|
||||
#if $hostStart + $hostCount < $totalHosts
|
||||
<a href="hosts?start=#echo $hostStart + $hostRange#$util.passthrough($self, 'order')">>>></a>
|
||||
<a href="hosts?start=#echo $hostStart + $hostRange#$util.passthrough_except($self)">>>></a>
|
||||
#end if
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -1238,13 +1238,23 @@ def cancelbuild(req, buildID):
|
|||
|
||||
mod_python.util.redirect(req, 'buildinfo?buildID=%i' % build['id'])
|
||||
|
||||
def hosts(req, start=None, order='name'):
|
||||
def hosts(req, state='enabled', start=None, order='name'):
|
||||
values = _initValues(req, 'Hosts', 'hosts')
|
||||
server = _getServer(req)
|
||||
|
||||
values['order'] = order
|
||||
|
||||
hosts = server.listHosts()
|
||||
args = {}
|
||||
|
||||
if state == 'enabled':
|
||||
args['enabled'] = True
|
||||
elif state == 'disabled':
|
||||
args['enabled'] = False
|
||||
else:
|
||||
state = 'all'
|
||||
values['state'] = state
|
||||
|
||||
hosts = server.listHosts(**args)
|
||||
|
||||
server.multicall = True
|
||||
for host in hosts:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue