Module: check_mk
Branch: master
Commit: d188540f6fb95b37dd56d978d4107f009077c11e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d188540f6fb95b…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu May 28 13:54:30 2015 +0200
Matrix layout: new painter option for omitting identical rows
---
web/htdocs/views.py | 46 ++++++++++++++++++++++-------------------
web/plugins/config/builtin.py | 3 ---
web/plugins/views/layouts.py | 5 +++--
web/plugins/views/painters.py | 10 +++++++++
4 files changed, 38 insertions(+), 26 deletions(-)
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 5a56e0c..ae8a896 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -1057,6 +1057,28 @@ def show_view(view, show_heading = False, show_buttons = True,
colset.remove("site")
columns = list(colset)
+ # The layout of the view: it can be overridden by several specifying
+ # an output format (like json or python). Note: the layout is not
+ # always needed. In case of an embedded view in the reporting this
+ # field is simply missing, because the rendering is done by the
+ # report itself.
+ # TODO: CSV export should be handled by the layouts. It cannot
+ # be done generic in most cases
+ if html.output_format == "html":
+ if "layout" in view:
+ layout = multisite_layouts[view["layout"]]
+ else:
+ layout = None
+ else:
+ if "layout" in view and "csv_export" in
multisite_layouts[view["layout"]]:
+ multisite_layouts[view["layout"]]["csv_export"](rows,
view, group_painters, painters)
+ return
+ else:
+ # Generic layout of export
+ layout = multisite_layouts.get(html.output_format)
+ if not layout:
+ layout = multisite_layouts["json"]
+
# Get list of painter options we need to display (such as PNP time range
# or the format being used for timestamp display)
painter_options = []
@@ -1066,6 +1088,9 @@ def show_view(view, show_heading = False, show_buttons = True,
if p.get("load_inv"):
need_inventory_data = True
+ # Also layouts can register painter options
+ painter_options += layout.get("options", [])
+
painter_options = list(set(painter_options))
painter_options.sort()
@@ -1115,27 +1140,6 @@ def show_view(view, show_heading = False, show_buttons = True,
if browser_reload and 'R' in display_options and not only_count:
html.set_browser_reload(browser_reload)
- # The layout of the view: it can be overridden by several specifying
- # an output format (like json or python). Note: the layout is not
- # always needed. In case of an embedded view in the reporting this
- # field is simply missing, because the rendering is done by the
- # report itself.
- # TODO: CSV export should be handled by the layouts. It cannot
- # be done generic in most cases
- if html.output_format == "html":
- if "layout" in view:
- layout = multisite_layouts[view["layout"]]
- else:
- layout = None
- else:
- if "layout" in view and "csv_export" in
multisite_layouts[view["layout"]]:
- multisite_layouts[view["layout"]]["csv_export"](rows,
view, group_painters, painters)
- return
- else:
- # Generic layout of export
- layout = multisite_layouts.get(html.output_format)
- if not layout:
- layout = multisite_layouts["json"]
# Until now no single byte of HTML code has been output.
# Now let's render the view. The render_function will be
diff --git a/web/plugins/config/builtin.py b/web/plugins/config/builtin.py
index cd840ab..8ae8501 100644
--- a/web/plugins/config/builtin.py
+++ b/web/plugins/config/builtin.py
@@ -110,9 +110,6 @@ sounds = [
view_option_refreshes = [ 30, 60, 90, 0 ]
view_option_columns = [ 1, 2, 3, 4, 5, 6, 8, 10, 12 ]
-# Experimental:
-matrix_omit_uniform_lines = False
-
# MISC
doculink_urlformat = "http://mathias-kettner.de/checkmk_%s.html";
diff --git a/web/plugins/views/layouts.py b/web/plugins/views/layouts.py
index 2f3ab9d..67c8b3a 100644
--- a/web/plugins/views/layouts.py
+++ b/web/plugins/views/layouts.py
@@ -546,7 +546,7 @@ def render_matrix(rows, view, group_painters, painters, num_columns,
_ignore_sho
# Now for each unique service^H^H^H^H^H^H ID column paint one row
for row_id in unique_row_ids:
# Omit rows where all cells have the same values
- if config.matrix_omit_uniform_lines:
+ if get_painter_option("matrix_omit_uniform"):
at_least_one_different = False
for counts in value_counts[row_id].values():
if len(counts) > 1:
@@ -602,7 +602,7 @@ def csv_export_matrix(rows, view, group_painters, painters):
for row_id in unique_row_ids:
# Omit rows where all cells have the same values
- if config.matrix_omit_uniform_lines:
+ if get_painter_option("matrix_omit_uniform"):
at_least_one_different = False
for counts in value_counts[row_id].values():
if len(counts) > 1:
@@ -721,4 +721,5 @@ multisite_layouts["matrix"] = {
"csv_export" : csv_export_matrix,
"group" : True,
"checkboxes" : False,
+ "options" : [ "matrix_omit_uniform" ],
}
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index ba0dfc3..b44ef96 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -100,6 +100,16 @@ multisite_painter_options["ts_date"] = {
'valuespec' : DateFormat(),
}
+multisite_painter_options["matrix_omit_uniform"] = {
+ 'valuespec' : DropdownChoice(
+ title = _("Find differences..."),
+ choices = [
+ ( False, _("Always show all rows") ),
+ ( True, _("Omit rows where all columns are identical") ),
+ ]
+ )
+}
+
# This helper function returns the value of the given custom var
def paint_custom_var(what, key, row):
if what: