Add client-side search limit parameter for user search.

Limit editgroup user ajax search.
Minor UI cleanup for editgroup.
This commit is contained in:
Kevin McCarthy 2007-09-18 14:58:30 -07:00
parent c4998d3902
commit 6b3d1e85da
7 changed files with 32 additions and 17 deletions

View File

@ -93,11 +93,11 @@ class IPAClient:
result = self.transport.get_add_schema()
return result
def find_users(self, criteria, sattrs=None):
def find_users(self, criteria, sattrs=None, searchlimit=0):
"""Return a list: counter followed by a User object for each user that
matches the criteria. If the results are truncated, counter will
be set to -1"""
result = self.transport.find_users(criteria, sattrs)
result = self.transport.find_users(criteria, sattrs, searchlimit)
counter = result[0]
users = [counter]

View File

@ -150,7 +150,7 @@ class RPCClient:
return ipautil.unwrap_binary_data(result)
def find_users (self, criteria, sattrs=None):
def find_users (self, criteria, sattrs=None, searchlimit=0):
"""Return a list: counter followed by a User object for each user that
matches the criteria. If the results are truncated, counter will
be set to -1"""
@ -160,7 +160,7 @@ class RPCClient:
# None values are not allowed in XML-RPC
if sattrs is None:
sattrs = "__NONE__"
result = server.find_users(criteria, sattrs)
result = server.find_users(criteria, sattrs, searchlimit)
except xmlrpclib.Fault, fault:
raise ipaerror.gen_exception(fault.faultCode, fault.faultString)
except socket.error, (value, msg):

View File

@ -214,16 +214,18 @@ class Root(controllers.RootController):
This method is used for ajax calls."""
client.set_principal(identity.current.user_name)
users = []
searchlimit = 100
uid = kw.get('uid')
if uid != None and len(uid) > 0:
try:
users = client.find_users(uid.encode('utf-8'))
users = client.find_users(uid.encode('utf-8'), None, searchlimit)
counter = users[0]
users = users[1:]
except ipaerror.IPAError, e:
turbogears.flash("User list failed: " + str(e))
return dict(users=users, uid=uid, fields=forms.user.UserFields())
return dict(users=users, uid=uid, fields=forms.user.UserFields(),
counter=counter)
@expose("ipagui.templates.usershow")

View File

@ -148,6 +148,16 @@ body {
text-align: right;
}
.floatlist {
float: right;
width: 50%;
}
.floatheader {
color: #885555;
font-weight: bold;
}
.small {
font-size: small;
}

View File

@ -200,8 +200,8 @@
<div>
<div class="formsection">Group Members</div>
<div style="float:right; width:50%">
<div>To Remove:</div>
<div class="floatlist">
<div class="floatheader">To Remove:</div>
<div id="delmembers">
</div>
</div>
@ -229,8 +229,8 @@
<div style="clear:both">
<div class="formsection">Add Persons</div>
<div style="float:right; width:50%">
<div>To Add:</div>
<div class="floatlist">
<div class="floatheader">To Add:</div>
<div id="newmembers">
</div>
</div>

View File

@ -23,11 +23,14 @@
</div>
<script type="text/javascript">
if (results_counter == 0) {
$('search-results-count').appendChild(document.createTextNode(
"No results found for " + search_string));
var message = "No results found for " + search_string;
} else {
$('search-results-count').appendChild(document.createTextNode(
"" + results_counter + " results found:"));
var message = results_counter + " results found:";
}
$('search-results-count').appendChild(document.createTextNode(message));
</script>
<script py:if="counter &lt; 0">
$('search-results-count').appendChild(document.createTextNode(
" (truncated)"));
</script>
</div>

View File

@ -413,7 +413,7 @@ class IPAServer:
return users
def find_users (self, criteria, sattrs=None, opts=None):
def find_users (self, criteria, sattrs=None, searchlimit=0, opts=None):
"""Returns a list: counter followed by the results.
If the results are truncated, counter will be set to -1."""
# Assume the list of fields to search will come from a central
@ -435,13 +435,13 @@ class IPAServer:
try:
try:
exact_results = conn.getListAsync(self.basedn, self.scope,
exact_match_filter, sattrs)
exact_match_filter, sattrs, 0, None, None, -1, searchlimit)
except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND):
exact_results = [0]
try:
partial_results = conn.getListAsync(self.basedn, self.scope,
partial_match_filter, sattrs)
partial_match_filter, sattrs, 0, None, None, -1, searchlimit)
except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND):
partial_results = [0]
finally: