Module: check_mk
Branch: master
Commit: 2d3b9703970d787d40e01f88a169a471abebf974
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2d3b9703970d78…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Nov 24 15:50:19 2017 +0100
5540 FIX "Graph time range" display option had no effect on Check_MK graphs
The graph time range configured in the view is the "default" time range and
the display option is meant to override this view default.
Change-Id: I7d11f8e20049bc739c03b71b6a73fab9db16d379
---
.werks/5540 | 12 ++++++++++++
web/plugins/views/painters.py | 13 ++++++++++++-
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/.werks/5540 b/.werks/5540
new file mode 100644
index 0000000..3c41046
--- /dev/null
+++ b/.werks/5540
@@ -0,0 +1,12 @@
+Title: "Graph time range" display option had no effect on Check_MK graphs
+Level: 1
+Component: metrics
+Class: fix
+Compatible: compat
+Edition: cee
+State: unknown
+Version: 1.5.0i2
+Date: 1511534729
+
+The graph time range configured in the view is the "default" time range and
+the display option is meant to override this view default.
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index b0c7fe8..be8c166 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -1013,20 +1013,31 @@ def paint_time_graph_cmk(row, cell, show_timeranges=False):
"host_name" : row["host_name"],
"service_description" : row.get("service_description",
"_HOST_"),
})
- graph_data_range = { "time_range" :
get_graph_timerange_from_painter_options() }
# Load the graph render options from
# a) the painter parameters configured in the view
# b) the painter options set per user and view
graph_render_options = cell.painter_parameters().copy()
+ graph_data_range = {}
graph_render_options["show_time_range_previews"] = show_timeranges
options = painter_options.get_without_default("graph_render_options")
if options != None:
graph_render_options.update(options)
+ # Do not load this setting form the painter options
del graph_render_options["set_default_time_range"]
+ if "set_default_time_range" in graph_render_options:
+ duration = graph_render_options["set_default_time_range"]
+ now = time.time()
+ graph_data_range["time_range"] = now - duration, now
+
+ # Load timerange from painter option (overrides the defaults, if set by the user)
+ painter_option_pnp_timerange =
painter_options.get_without_default("pnp_timerange")
+ if painter_option_pnp_timerange is not None:
+ graph_data_range["time_range"] =
get_graph_timerange_from_painter_options()
+
if html.is_mobile():
graph_render_options.update({
"interaction" : False,