Author: eallen
Date: 2008-12-02 14:06:47 -0500 (Tue, 02 Dec 2008)
New Revision: 2906
Modified:
mgmt/trunk/cumin/python/cumin/stat.py
mgmt/trunk/cumin/python/cumin/stat.strings
Log:
Don't use borders, margin, or background images if the number of columns in a
visualization grid is more than 15
Modified: mgmt/trunk/cumin/python/cumin/stat.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/stat.py 2008-12-02 17:03:00 UTC (rev 2905)
+++ mgmt/trunk/cumin/python/cumin/stat.py 2008-12-02 19:06:47 UTC (rev 2906)
@@ -153,9 +153,10 @@
ajax = self.Updater(app, "grid_updater")
self.add_child(ajax)
- self.ems = 480.0
+ self.max_px = 480.0
self.max_item_em = 28.0
self.max_columns = 20.0
+ self.max_background_cols = 15 # max columns with background image
def render_title(self, session):
return "Utilization"
@@ -168,20 +169,27 @@
columns = self.cells.calculate_columns(count)
return columns <= self.max_columns
+ def get_cell_class(self, session):
+ count = len(self.cells.get_items(session))
+ columns = self.cells.calculate_columns(count)
+ return columns > self.max_background_cols and "small" or
"big"
+
def get_grid_width(self, session):
count = len(self.cells.get_items(session))
columns = self.cells.calculate_columns(count)
# we have approx 15em to work with
# we'd like each column to be between 1em and 2em
width = float(columns) * self.max_item_em
- if width > self.ems:
- width = self.ems
+ if width > self.max_px:
+ width = self.max_px
extra = 3.0 * columns # left right border plus 1 right margin
- return width + extra
+ if columns > self.max_background_cols:
+ extra = 0
+ return int(width + extra)
def render_grid_width(self, session):
width = self.get_grid_width(session)
- return "%fpx" % width
+ return "%ipx" % int(width)
class GridCells(ItemSet):
def __init__(self, app, name):
@@ -206,6 +214,9 @@
def render_cell_width(self, session, cell):
return self.width.get(session)
+ def render_cell_class(self, session, cell):
+ return self.parent.get_cell_class(session)
+
def calculate_columns(self, count):
sq = sqrt(count)
isq = int(sq)
@@ -217,9 +228,9 @@
columns = self.calculate_columns(count)
width = self.parent.max_item_em
if columns:
- min = self.parent.ems / float(columns)
+ min = self.parent.max_px / float(columns)
width = min > self.parent.max_item_em and self.parent.max_item_em or
min
- return "%fpx" % width
+ return "%ipx" % int(width)
def render_href(self, session, cell):
return self.parent.get_href(session, cell)
Modified: mgmt/trunk/cumin/python/cumin/stat.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/stat.strings 2008-12-02 17:03:00 UTC (rev 2905)
+++ mgmt/trunk/cumin/python/cumin/stat.strings 2008-12-02 19:06:47 UTC (rev 2906)
@@ -226,6 +226,13 @@
position: relative;
color: black;
}
+div.StatGrid a.small {
+ float:left;
+ position: relative;
+ color: black;
+}
+div.StatGrid a.small:hover { border: 0px; }
+
div.StatGrid a:hover { border: 1px solid #a00; }
.btn.yellow { background: #ffc; }
.btn.green { background: #cfc; }
@@ -304,7 +311,7 @@
{items}
[GridCells.item_html]
- <a href="{href}">
+ <a class="{cell_class}" href="{href}">
<div id="button_{cell_id}" class="btn {color}"
style="width:{cell_width}; height:{cell_width};">
{contents}
</div>
Show replies by date