Author: eallen
Date: 2010-10-29 14:01:29 -0400 (Fri, 29 Oct 2010)
New Revision: 4407
Modified:
mgmt/trunk/cumin/python/cumin/grid/job.py
mgmt/trunk/cumin/python/cumin/qmfadapter.py
Log:
BZ 63536: Change the qmf tables to have non-sortable columns if the record count gets too
large
Modified: mgmt/trunk/cumin/python/cumin/grid/job.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/job.py 2010-10-28 22:09:55 UTC (rev 4406)
+++ mgmt/trunk/cumin/python/cumin/grid/job.py 2010-10-29 18:01:29 UTC (rev 4407)
@@ -109,7 +109,6 @@
results = self.app.model.get_submission_job_summaries(submission)
rows = self.process_list_results(results.data)
- rows = rows[:self.max_records]
# sort the entore results set
rows = self.sort_rows(rows, options)
@@ -149,7 +148,7 @@
def get_count(self, values):
submission = values["obj"]
results = self.app.model.get_submission_job_summaries(submission)
- return results.data and min(self.max_records, len(results.data)) or 0
+ return results.data and len(results.data) or 0
class NonSortableObjectTableColumn(ObjectTableColumn):
def __init__(self, app, name, attr):
@@ -158,13 +157,42 @@
self.header = StaticColumnHeader(app, "header")
self.replace_child(self.header)
-class NonSortableObjectLinkColumn(ObjectLinkColumn):
- def __init__(self, app, name, attr, id_attr, frame_path):
- super(NonSortableObjectLinkColumn, self).__init__(app, name, attr, id_attr,
frame_path)
+class DynamicColumnHeader(Widget):
+ def __init__(self, app, name, selector_method, col):
+ super(DynamicColumnHeader, self).__init__(app, name)
- self.header = StaticColumnHeader(app, "header")
- self.replace_child(self.header)
+ # save the original sortable header
+ self.sortable_header = col.header
+ # add a static header
+ self.static_header = StaticColumnHeader(app, "static_header")
+ col.add_child(self.static_header)
+
+ self.selector_method = selector_method
+
+ def render(self, session):
+ render_sortable = self.selector_method(session)
+
+ if render_sortable:
+ return self.sortable_header.render(session)
+ else:
+ return self.static_header.render(session)
+
+class DynamicSortableObjectLinkColumn(ObjectLinkColumn):
+ def __init__(self, app, name, attr, id_attr, frame_path, selector_method):
+ super(DynamicSortableObjectLinkColumn, self).__init__(app, name, attr, id_attr,
frame_path)
+
+ # add an object that selects between the static and sortable header
+ self.header = DynamicColumnHeader(app, "dynamic_header",
selector_method, self)
+ self.add_child(self.header)
+
+class DynamicSortableObjectTableColumn(ObjectTableColumn):
+ def __init__(self, app, name, attr, selector_method):
+ super(DynamicSortableObjectTableColumn, self).__init__(app, name, attr)
+
+ self.header = DynamicColumnHeader(app, "dynamic_header",
selector_method, self)
+ self.add_child(self.header)
+
class JobSelector(ObjectSelector):
def __init__(self, app, name, submission):
cls = app.model.com_redhat_cumin_grid.JobSummary
@@ -175,10 +203,10 @@
self.submission = submission
frame = "main.grid.pool.submission.job"
- self.job_id_col = self.JobIdColumn(app, "job", cls.GlobalJobId,
cls.JobId, frame)
+ self.job_id_col = self.JobIdColumn(app, "job", cls.GlobalJobId,
cls.JobId, frame, self.render_dynamic_header)
self.add_column(self.job_id_col)
- status_column = ObjectTableColumn(app, "status", cls.JobStatus)
+ status_column = DynamicSortableObjectTableColumn(app, "status",
cls.JobStatus, self.render_dynamic_header)
self.add_column(status_column)
cmd_column = NonSortableObjectTableColumn(app, cls.Cmd.name, cls.Cmd)
@@ -206,6 +234,13 @@
(app, "id", cls.JobId, self.ids)
self.add_column(self.checkbox_column)
+ def render_dynamic_header(self, session):
+ values = self.get_data_values(session)
+ count = self.adapter.get_count(values)
+ max_sort = self.adapter.max_sortable_records
+
+ return count <= max_sort
+
def render_title(self, session):
return "Jobs"
@@ -243,7 +278,7 @@
values['args'] = ()
return values
- class JobIdColumn(ObjectLinkColumn):
+ class JobIdColumn(DynamicSortableObjectLinkColumn):
def render_cell_href(self, session, record):
job_id = record[self.parent.job_id_column.field.index]
#frame = self.page.page_widgets_by_path[self.frame_path]
@@ -252,11 +287,6 @@
submission = self.parent.submission.get(session)
return frame.get_href(session, submission._id, job_id)
- class Status(ObjectTableColumn):
- def render_cell_content(self, session, record):
- status = self.field.get_content(session, record)
- return JobStatusInfo.get_status_string(status)
-
class JobObjectSelectorTask(ObjectSelectorTask):
def __init__(self, app, selector, verb):
super(JobObjectSelectorTask, self).__init__(app, selector)
Modified: mgmt/trunk/cumin/python/cumin/qmfadapter.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/qmfadapter.py 2010-10-28 22:09:55 UTC (rev 4406)
+++ mgmt/trunk/cumin/python/cumin/qmfadapter.py 2010-10-29 18:01:29 UTC (rev 4407)
@@ -12,7 +12,7 @@
self.method = method
self.default = list()
self.columns = list()
- self.max_records = 1000
+ self.max_sortable_records = 1000
def get_count(self, values):
obj = values['obj']
@@ -21,7 +21,7 @@
action = QmfCall(self.app)
results = action.execute(obj, self.method, args)
- return results and min(len(results), self.max_records) or 0
+ return results and len(results) or 0
def get_data(self, values, options):
obj = values['obj']
@@ -40,7 +40,6 @@
else:
rows = []
- rows = rows[:self.max_records]
rows = self.sort_rows(rows, options)
return rows[options.offset:options.offset + options.limit]
@@ -54,8 +53,6 @@
for key in results:
row = self.process_record(key, results[key])
records.append(row)
- if len(records) >= self.max_records:
- break
return records
@@ -67,8 +64,6 @@
for rec in results:
row = self.process_record(None, rec)
records.append(row)
- if len(records) >= self.max_records:
- break
return records
@@ -83,6 +78,9 @@
return field_data
def sort_rows(self, rows, options):
+ if len(rows) > self.max_sortable_records:
+ return rows
+
sort_field = options.sort_field
rev = options.sort_ascending == False