Module: check_mk
Branch: master
Commit: 69ad9c41aedae232398cf96be438eddd2f5a1fde
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=69ad9c41aedae2…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Oct 12 15:29:07 2017 +0200
"Add to" visual/pagetype gets more info about graphs
* CSV export of graphs respects the current graph data range now
* When adding a graph to a visual (dashboard, report) or pagetype (graph
collection, custom graph) the grah tells the "add to" function now
more than the graph specification. The function could now also use
the data range somehow.
However, the new information are currently not used by the "add to"
functions.
Change-Id: I3953685117e565927bd157bba3c6e64a3762654c
---
web/htdocs/dashboard.py | 21 ++++++++++++---------
web/htdocs/js/checkmk.js | 3 ++-
2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/web/htdocs/dashboard.py b/web/htdocs/dashboard.py
index 24cfed1..145935e 100644
--- a/web/htdocs/dashboard.py
+++ b/web/htdocs/dashboard.py
@@ -1296,33 +1296,36 @@ def popup_add_dashlet(dashboard_name, dashlet_type, context,
params):
return
if dashlet_type == "pnpgraph":
- # Context will always be None here, but the graph_identification (in params)
+ # Context will always be None here, but the specification (in params)
# will contain it. Transform the data to the format needed by the dashlets.
# Example:
# params = [ 'template', {'service_description': 'CPU
load', 'site': 'mysite',
# 'graph_index': 0, 'host_name':
'server123'}])
- graph_identification = params[1]
- if params[0] == "template":
+ specification = params["definition"]["specification"]
+ if specification[0] == "template":
context = {
- "host" : graph_identification["host_name"]
+ "host" : specification[1]["host_name"]
}
- if graph_identification.get("service_description") !=
"_HOST_":
- context["service"] =
graph_identification["service_description"]
+ if specification[1].get("service_description") !=
"_HOST_":
+ context["service"] =
specification[1]["service_description"]
params = {
- "source" : graph_identification["graph_index"] + 1
+ "source" : specification[1]["graph_index"] + 1
}
- elif params[0] == "custom":
+ elif specification[0] == "custom":
# Override the dashlet type here. It would be better to get the
# correct dashlet type from the menu. But this does not seem to
# be a trivial change.
dashlet_type = "custom_graph"
context = {}
params = {
- "custom_graph": params[1],
+ "custom_graph": specification[1],
}
+ else:
+ raise MKGeneralException(_("Invalid graph type '%s'") %
specification[0])
+
load_dashboards(lock=True)
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 33b35d6..1790116 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -3265,7 +3265,8 @@ function pagetype_add_to_container(page_type, page_name)
function graph_export()
{
var request = {
- "specification": popup_data[2]
+ "specification":
popup_data[2]["definition"]["specification"],
+ "data_range": popup_data[2]["data_range"],
};
location.href = "graph_export.py?request=" +
encodeURIComponent(JSON.stringify(request));
}