summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2007-10-31 13:54:25 -0400
committerMichael DeHaan <mdehaan@redhat.com>2007-10-31 13:54:25 -0400
commit02d2e0137f706018baf3b0b1794afdc3cbf4cda9 (patch)
tree9caeb437a13b921b659d9b3a85d9aa9c349523bf
parent8c179cbc21dcafd91671404607f1c290f18aeb11 (diff)
downloadthird_party-cobbler-02d2e0137f706018baf3b0b1794afdc3cbf4cda9.tar.gz
third_party-cobbler-02d2e0137f706018baf3b0b1794afdc3cbf4cda9.tar.xz
third_party-cobbler-02d2e0137f706018baf3b0b1794afdc3cbf4cda9.zip
Ongoing work on WUI pagination
-rw-r--r--Makefile4
-rw-r--r--cobbler/remote.py2
-rw-r--r--cobbler/webui/CobblerWeb.py37
-rw-r--r--tests/multi.py2
-rw-r--r--webui_templates/system_list.tmpl32
5 files changed, 57 insertions, 20 deletions
diff --git a/Makefile b/Makefile
index 85d6715..ca8f57c 100644
--- a/Makefile
+++ b/Makefile
@@ -39,12 +39,12 @@ devinstall:
cp /var/lib/cobbler/settings /tmp/cobbler_settings
cp /etc/cobbler/auth.conf /tmp/cobbler_auth.conf
cp /etc/cobbler/modules.conf /tmp/cobbler_modules.conf
- -cp /var/www/cobbler/cgi-bin/.htpasswd /tmp/cobbler_htpasswd
+ -cp /var/www/cgi-bin/cobbler/.htpasswd /tmp/cobbler_htpasswd
make install
cp /tmp/cobbler_settings /var/lib/cobbler/settings
cp /tmp/cobbler_auth.conf /etc/cobbler/auth.conf
cp /tmp/cobbler_modules.conf /etc/cobbler/modules.conf
- -cp /tmp/cobbler_htpasswd /var/www/cobbler/cgi-bin/.htpasswd
+ -cp /tmp/cobbler_htpasswd /var/www/cgi-bin/cobbler/.htpasswd
find /var/lib/cobbler/triggers | xargs chmod +x
chown -R apache /var/www/cobbler
chown -R apache /var/www/cgi-bin/cobbler
diff --git a/cobbler/remote.py b/cobbler/remote.py
index a292dee..a871e22 100644
--- a/cobbler/remote.py
+++ b/cobbler/remote.py
@@ -77,7 +77,7 @@ class CobblerXMLRPCInterface:
data = self.__get_all(collection_name)
return len(data)
- def __get_all(self,collection_name,page,results_per_page):
+ def __get_all(self,collection_name,page=None,results_per_page=None):
"""
Helper method to return all data to the WebUI or another caller
without going through the process of loading all the data into
diff --git a/cobbler/webui/CobblerWeb.py b/cobbler/webui/CobblerWeb.py
index 075bc60..6340b2b 100644
--- a/cobbler/webui/CobblerWeb.py
+++ b/cobbler/webui/CobblerWeb.py
@@ -326,21 +326,44 @@ class CobblerWeb(object):
# if the system list is huge, this will probably need to use an
# iterator so the list doesn't get copied around
- def system_list(self,page=0,results_per_page=100):
+ def __compute_pagination(self,page,results_per_page,collection_type):
+
+ default_page = 0
+ default_results_per_page = 50
+ total_size = self.remote.get_size(collection_type)
+
+ try:
+ page = int(page)
+ except:
+ page = default_page
+ try:
+ results_per_page = int(results_per_page)
+ except:
+ results_per_page = default_results_per_page
+
+ if page < 0:
+ page = default_page
+ if results_per_page <= 0:
+ results_per_page = default_results_per_page
+
+ pages = total_size / results_per_page
+ return (page, results_per_page, pages)
+
+
+ def system_list(self,page=None,results_per_page=None):
if not self.__xmlrpc_setup():
return self.xmlrpc_auth_failure()
- systems_size = self.remote.get_size("systems")
- pages = len(systems) / results_per_page
+ (page, results_per_page, pages) = self.__compute_pagination(page,results_per_page,"system")
systems = self.remote.get_systems(page,results_per_page)
-
if len(systems) > 0:
return self.__render( 'system_list.tmpl', {
- 'systems' : systems,
- 'pages' : pages,
- 'page' : page
+ 'systems' : systems,
+ 'pages' : pages,
+ 'page' : page,
+ 'results_per_page' : results_per_page
} )
else:
return self.__render('empty.tmpl',{})
diff --git a/tests/multi.py b/tests/multi.py
index 4c80618..ce3846c 100644
--- a/tests/multi.py
+++ b/tests/multi.py
@@ -2,7 +2,7 @@ import cobbler.api as capi
api = capi.BootAPI()
-SYSTEMS_COUNT = 5000
+SYSTEMS_COUNT = 146
distros = api.distros()
profiles = api.profiles()
diff --git a/webui_templates/system_list.tmpl b/webui_templates/system_list.tmpl
index 93f4602..1a6e178 100644
--- a/webui_templates/system_list.tmpl
+++ b/webui_templates/system_list.tmpl
@@ -4,21 +4,35 @@
## navigation for pages
- Pages:&nbsp;
+ <!-- DEBUG: num pages is $pages<br/> -->
+ <!-- DEBUG: current page is $page<br/> -->
+ <!-- DEBUG: results per page is $results_per_page</br> -->
+
+ Page:&nbsp;
#if $page != 0
#set $previous_page = $page - 1
<A HREF="${base_url}/system_list?page=${previous_page}&results_per_page=${results_per_page}">&lt;</A>&nbsp;
- #end
+ #else
+ [
+ #end if
- #for $this_page in $pages
- <A HREF="${base_url}/system_list?page=${this_page}&results_per_page=${results_per_page}">$p</A>&nbsp;
- #end
+ #for $this_page in range(0,$pages+1)
+ #if $this_page != $page
+ <A HREF="${base_url}/system_list?page=${this_page}&results_per_page=${results_per_page}">${this_page}</A>&nbsp;
+ #else
+ ${this_page}
+ #end if
+ #end for
- #if $page != $lastpage
+ #if $page != $pages
#set $next_page = $page + 1
- <A HREF="${base_url}/system_list?page=${next_page}&results_per_page=${results_per_page}">&rt;</A>
- #end
- </br>
+ <A HREF="${base_url}/system_list?page=${next_page}&results_per_page=${results_per_page}">&gt;</A>
+ #else
+ ]
+ #end if
+
+ <br/>
+ <br/>
<table class="sortable">