Author: tmckay
Date: 2011-01-12 22:25:28 +0000 (Wed, 12 Jan 2011)
New Revision: 4462
Modified:
branches/1.3.2/cumin/bin/cumin-web
branches/1.3.2/cumin/python/cumin/grid/pool.py
branches/1.3.2/wooly/python/wooly/datatable.py
branches/1.3.2/wooly/python/wooly/widgets.py
branches/1.3.2/wooly/python/wooly/widgets.strings
Log:
Merged revisions 4457 and 4461 from trunk.
Revision 4461 is for BZ 626972
Modified: branches/1.3.2/cumin/bin/cumin-web
===================================================================
--- branches/1.3.2/cumin/bin/cumin-web 2011-01-12 20:28:21 UTC (rev 4461)
+++ branches/1.3.2/cumin/bin/cumin-web 2011-01-12 22:25:28 UTC (rev 4462)
@@ -17,7 +17,7 @@
parser = CuminOptionParser(values.web)
parser.add_option("--host", default=values.web.host)
- parser.add_option("--port", default=values.web.port)
+ parser.add_option("--port", default=values.web.port, type=int)
opts, args = parser.parse_args()
Modified: branches/1.3.2/cumin/python/cumin/grid/pool.py
===================================================================
--- branches/1.3.2/cumin/python/cumin/grid/pool.py 2011-01-12 20:28:21 UTC (rev 4461)
+++ branches/1.3.2/cumin/python/cumin/grid/pool.py 2011-01-12 22:25:28 UTC (rev 4462)
@@ -160,6 +160,7 @@
self.add_child(chart)
chart = self.SlotFlashChart(app, "slots", self.collector)
+ chart.duration.param.default = "3600"
chart.stats = ("HostsClaimed", "HostsUnclaimed",
"HostsOwner")
chart.chart_type = "stacked"
self.add_child(chart)
Modified: branches/1.3.2/wooly/python/wooly/datatable.py
===================================================================
--- branches/1.3.2/wooly/python/wooly/datatable.py 2011-01-12 20:28:21 UTC (rev 4461)
+++ branches/1.3.2/wooly/python/wooly/datatable.py 2011-01-12 22:25:28 UTC (rev 4462)
@@ -111,6 +111,12 @@
options.limit = self.header.limit.get(session)
options.offset = self.header.offset.get(session)
+ # make sure offset is a multiple of limit
+ # this happens sometimes when we change limits
+ if options.offset % options.limit:
+ options.offset = (options.offset / options.limit) * options.limit
+ self.header.offset.set(session, options.offset)
+
return options
def get_count(self, session):
@@ -230,6 +236,9 @@
if self.parent.selection.get(session) == option[0]:
return "selected"
+ def render_title(self, session, option):
+ return option[2]
+
def edit_session(self, session, option):
self.parent.selection.set(session, option[0])
@@ -238,26 +247,65 @@
class DataTableFontSelector(DataTableSelector):
def get_options(self, session):
- return ((0.8, "S"), (0.9, "M"), (1.0, "L"))
+ return ((0.8, "S", "Small"), (0.9, "M",
"Medium"), (1.0, "L", "Large"))
def render_title(self, session):
return "Font"
class DataTablePageSelector(DataTableSelector):
+ max_page_links = 16
+
def get_options(self, session):
+ # number of items in the table
count = self.table.count.get(session)
+ if not count:
+ return []
+
+ # number of items per page
limit = self.table.header.limit.get(session)
- count = min(count, 20 * limit)
+ # info for each possible page of results
+ options = [(x[1], x[0] + 1, "Goto Page %i" % (x[0] + 1, )) for x in
enumerate(range(0, count, limit))]
- return [(x[1], x[0] + 1) for x in enumerate(range(0, count, limit))]
+ # the starting item on the current page
+ selection = self.selection.get(session)
+ #find the index of the current page
+ cur_page = 0
+ for page in options:
+ if selection == page[0]:
+ cur_page = page[1] - 1
+ break
+
+ pages = list()
+
+ # adjust the page links shown so that the current page is in the list
+ first_page = max(cur_page - 1, 0)
+ last_page = min(first_page + self.max_page_links, len(options))
+ first_page = max(last_page - self.max_page_links, 0)
+
+ if first_page:
+ pages.append((0, "«", "First Page"))
+ prev = max(selection - limit, 0)
+ pages.append((prev, "‹", "Previous Page"))
+
+ pages.extend(options[first_page : last_page])
+
+ if last_page < len(options):
+ next = options[cur_page + 1][0]
+ pages.append((next, "›", "Next Page"))
+
+ last = options[len(options) - 1][0]
+ pages.append((last, "»", "Last Page"))
+
+ return pages
+
def render_title(self, session):
- return "Page"
+ return self.table.count.get(session) and "Page" or ""
class DataTableLimitSelector(DataTableSelector):
def get_options(self, session):
- return ((25, 25), (50, 50), (100, 100))
+ return ((25, 25, "25 items per page"), (50, 50, "50 items per
page"), (100, 100, "100 items per page"))
def render_title(self, session):
return "Limit"
Modified: branches/1.3.2/wooly/python/wooly/widgets.py
===================================================================
--- branches/1.3.2/wooly/python/wooly/widgets.py 2011-01-12 20:28:21 UTC (rev 4461)
+++ branches/1.3.2/wooly/python/wooly/widgets.py 2011-01-12 22:25:28 UTC (rev 4462)
@@ -131,6 +131,9 @@
self.edit_session(branch, *args)
return branch.marshal()
+ def render_title(self, session, *args):
+ return ""
+
class Toggle(Link):
def __init__(self, app, name):
super(Toggle, self).__init__(app, name)
Modified: branches/1.3.2/wooly/python/wooly/widgets.strings
===================================================================
--- branches/1.3.2/wooly/python/wooly/widgets.strings 2011-01-12 20:28:21 UTC (rev 4461)
+++ branches/1.3.2/wooly/python/wooly/widgets.strings 2011-01-12 22:25:28 UTC (rev 4462)
@@ -67,7 +67,7 @@
<li>{link}</li>
[Link.html]
-<a class="{class}" href="{href}">{content}</a>
+<a class="{class}" href="{href}"
title="{title}">{content}</a>
[Toggle.css]
a.Toggle.on {