Author: croberts
Date: 2012-02-02 22:05:32 +0000 (Thu, 02 Feb 2012)
New Revision: 5201
Modified:
branches/humility/cumin/python/cumin/grid/reports.py
branches/humility/cumin/python/cumin/grid/reports.strings
Log:
Work toward a generalized select box for reporting charts. Still not wired-in with JS to
change the stats URL, but that should come soon.
Modified: branches/humility/cumin/python/cumin/grid/reports.py
===================================================================
--- branches/humility/cumin/python/cumin/grid/reports.py 2012-02-01 21:21:45 UTC (rev
5200)
+++ branches/humility/cumin/python/cumin/grid/reports.py 2012-02-02 22:05:32 UTC (rev
5201)
@@ -8,6 +8,20 @@
strings = StringCatalog(__file__)
log = logging.getLogger("cumin.reports")
+class ReportStatFlashChart(StatFlashChart):
+ pass
+
+class ReportSelector(Widget):
+ def __init__(self, app, name):
+ super(ReportSelector, self).__init__(app, name)
+
+ def render_title(self, session):
+ return "Generic title:"
+
+ def render_item_list(self, session):
+ return "<option>generic item</option>"
+
+
class ReportsFrame(Frame):
def __init__(self, app, name):
super(ReportsFrame, self).__init__(app, name)
@@ -42,10 +56,23 @@
class ReportsUserInfo(Widget):
def __init__(self, app, name):
super(ReportsUserInfo, self).__init__(app, name)
+ self.cls = app.model.com_redhat_grid.Submitter
+
def render_title(self, session):
return "User"
+ def getUserList(self, session):
+ sub_list = ""
+ submitters = self.cls.get_selection(session.cursor)
+ for submitter in submitters:
+ sub_list += "<option>%s</option>" % submitter.Owner
+ return sub_list
+
+ def render_user_list(self, session):
+ users = self.getUserList(session)
+ return users
+
class ReportsJobInfo(Widget):
def __init__(self, app, name):
super(ReportsJobInfo, self).__init__(app, name)
@@ -55,13 +82,31 @@
def render_title(self, session):
return "Job"
+
+
+class SchedulerSelector(ReportSelector):
+ def __init__(self, app, name):
+ super(SchedulerSelector, self).__init__(app, name)
+ self.cls = app.model.com_redhat_grid.Scheduler
+
+ def render_title(self, session):
+ return "Scheduler:"
+ def render_item_list(self, session):
+ schedList = ""
+ schedulers = self.cls.get_selection(session.cursor)
+ for scheduler in schedulers:
+ schedList += "<option>%s</option>" % scheduler.Machine
+
+ return schedList
+
class ReportsJobChart(Widget):
def __init__(self, app, name):
super(ReportsJobChart, self).__init__(app, name)
self.cls = app.model.com_redhat_grid.Scheduler
-
+
+ #this attribute gets filled-in in the process loop
self.scheduler_object = Attribute(app, "object")
self.add_attribute(self.scheduler_object)
@@ -70,30 +115,30 @@
chart.duration.param.default = "3600"
self.add_child(chart)
+
def do_process(self, session):
obj = self.getDefaultScheduler(session)
self.scheduler_object.set(session, obj)
super(ReportsJobChart, self).do_process(session)
-
- def render_scheduler_list(self, session):
- schedList = ""
- schedulers = self.cls.get_selection(session.cursor)
- for scheduler in schedulers:
- schedList += "<option>%s</option>" % scheduler.Machine
-
- return schedList
-
+
def getDefaultScheduler(self, session):
schedulers = self.cls.get_selection(session.cursor)
return schedulers[0]
-
- class JobsChart(StatFlashChart):
+
+ class JobsChart(ReportStatFlashChart):
+ def __init__(self, app, name, object):
+ super(ReportsJobChart.JobsChart, self).__init__(app, name, object)
+
+ self.selector = SchedulerSelector(app, "selector")
+ self.add_child(self.selector)
+
def render_title(self, session):
return "Jobs"
-
-
-
+
+
+
+
\ No newline at end of file
Modified: branches/humility/cumin/python/cumin/grid/reports.strings
===================================================================
--- branches/humility/cumin/python/cumin/grid/reports.strings 2012-02-01 21:21:45 UTC (rev
5200)
+++ branches/humility/cumin/python/cumin/grid/reports.strings 2012-02-02 22:05:32 UTC (rev
5201)
@@ -1,5 +1,47 @@
[ReportsJobChart.html]
<div>
{jobs}
- Scheduler: <select>{scheduler_list}</select>
</div>
+
+<!--The plan here is to use an onchange handler for the select box to adjust the
chart.json URL for the stats,
+which will then load the chosen data. Not sure if the stat gathering code will need any
changes to support the filter
+-->
+
+
+[ReportsUserInfo.html]
+<div>
+ User: <select>{user_list}</select>
+</div>
+
+[ReportSelector.html]
+{title} <select id="{id}">{item_list}</select>
+
+[ReportStatFlashChart.html]
+<div>
+ <div class="StatValueChart{fullpageable}" id="{id}">
+ <h2>{title}</h2>
+ <div class="duration">{duration}</div>
+ <div id="{id}_chart">
+ <img id="{id}" src="{img_href}"
height="{img_height}" width="{img_width}" alt="stats" />
+ <div class="loading"
style="display:none;"><span>Loading...</span></div>
+ </div>
+ <div>{selector}</div>
+ </div>
+</div>
+<script type="text/javascript">
+//<![CDATA[
+ var flashversion = swfobject.getFlashPlayerVersion();
+ if (flashversion.major < 9) {
+ wooly.addPageUpdateListener(function () {if
(document.images["{id}"].className == "Loading") return;
cumin.updateChart("{id}");});
+ cumin.setupChart('{id}', {width});
+ } else {
+ swfobject.embedSWF("resource?name=open-flash-chart.swf",
"{id}_chart", "{width}", "{height}", "9.0.0",
"",
+ {"data-file":"{href}", "id":"{id}"},
{wmode: "opaque"});
+
+ wooly.addPageUpdateListener(function () { cumin.updateFlashChart('{id}');
});
+ window.addEvent('domready',function () {
+ cumin.setFullpageHandler('{id}', '{fullpage_href}');
+ });
+ }
+//]]>
+</script>