Author: eallen Date: 2011-03-09 01:17:21 +0000 (Wed, 09 Mar 2011) New Revision: 4589
Modified: trunk/cumin/python/cumin/grid/dashboard.py Log: Added a few comments
Modified: trunk/cumin/python/cumin/grid/dashboard.py =================================================================== --- trunk/cumin/python/cumin/grid/dashboard.py 2011-03-09 00:52:56 UTC (rev 4588) +++ trunk/cumin/python/cumin/grid/dashboard.py 2011-03-09 01:17:21 UTC (rev 4589) @@ -137,6 +137,8 @@ slices = self.get_pie_slices(session) return PieChartPage.get_href(slices, self.color_scheme, self.radius)
+ # we generate the style sheet for the legend based on + # the colors defined in the PieChartPage def render_legend_styles(self, session): colors = PieChartPage.color_schemes[self.color_scheme] styles = list() @@ -145,6 +147,7 @@ styles.append(".DefinitionSet dt.legend%s span { background-color: #%s;}" % (hx, hx)) return "\n".join(styles)
+ # don't put a line under the legend if there is a total def render_class(self, session): cls = super(PieStatSet, self).render_class(session) return "%s%s" % (cls, self.has_total and " hastotal" or "") @@ -152,6 +155,7 @@ def is_total(self, item): return False
+ # the color block next to each legend line is based on the class def render_legend_class(self, session, item): classes = list() if self.is_total(item): @@ -167,6 +171,7 @@ dt_class = self.render_legend_class(session, item) return "total" is dt_class and " class="total"" or ""
+ # don't show a chart icon on hover if there is no chart def render_span_class(self, session): return self.chart and "chart" or "blank"
@@ -235,6 +240,7 @@
self.title = title and title or name
+ # attr1 and 2 could be strings or they could be rosemary attributes try: id1 = attr1.sql_column.identifier except AttributeError: @@ -243,6 +249,7 @@ id2 = attr2.sql_column.identifier except AttributeError: id2 = attr2 + # avoid divide by 0 by using nullif nullif = "NULLIF(%s,0)" % id2 identifier = "(%s/%s)" % (id1, nullif) @@ -274,6 +281,7 @@ def get_title(self, session): return self.title
+# Create a sortable column that is the quotient of two extisting columns class QuotientSqlColumn(DerivedTableColumn): def __init__(self, app, name, attr1, attr2): super(QuotientSqlColumn, self).__init__(app, name) @@ -291,6 +299,7 @@ # change quotient into a percent self.field.column.identifier = "%s*100" % self.field.column.identifier
+# Create a sortable column that is the sum of two extisting columns class SumSqlColumn(DerivedTableColumn): def __init__(self, app, name, attr, title): super(SumSqlColumn, self).__init__(app, name) @@ -724,6 +733,8 @@ self.pool = pool self.add_filter(self.pool, cls.Pool)
+ # Do we want the name column to link to the objects page? + # In the case of collector we don't if frame: col = ObjectLinkColumn(app, "name", cls.Name, cls._id, frame) else: @@ -836,9 +847,13 @@ "SubmittersFailed", "SubmittersOutOfTime", "SubmittersShareLimit", "Time", "End", "Period")
+ # create a chart for each statistic + # I wonder if there is a way to use a single instance + # of the StatFlashChart class to do this cls = app.model.com_redhat_grid.Negotiator self.popup_charts = dict() for attr in self.attrs: + # don't try and chart the strings if cls._statistics_by_name[attr].type != "lstr": chart = StatFlashChart(app, "popup%s" % attr, self.object) chart.stats = [attr]
cumin-developers@lists.fedorahosted.org