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() result = self.transport.get_add_schema()
return result 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 """Return a list: counter followed by a User object for each user that
matches the criteria. If the results are truncated, counter will matches the criteria. If the results are truncated, counter will
be set to -1""" be set to -1"""
result = self.transport.find_users(criteria, sattrs) result = self.transport.find_users(criteria, sattrs, searchlimit)
counter = result[0] counter = result[0]
users = [counter] users = [counter]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -413,7 +413,7 @@ class IPAServer:
return users 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. """Returns a list: counter followed by the results.
If the results are truncated, counter will be set to -1.""" If the results are truncated, counter will be set to -1."""
# Assume the list of fields to search will come from a central # Assume the list of fields to search will come from a central
@ -435,13 +435,13 @@ class IPAServer:
try: try:
try: try:
exact_results = conn.getListAsync(self.basedn, self.scope, 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): except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND):
exact_results = [0] exact_results = [0]
try: try:
partial_results = conn.getListAsync(self.basedn, self.scope, 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): except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND):
partial_results = [0] partial_results = [0]
finally: finally: