Module: check_mk
Branch: master
Commit: 2fa420517aaafab38cb5caadbeb376fcd21a0759
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2fa420517aaafa…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Oct 5 16:11:30 2017 +0200
5363 Exporting graph data in JSON format via GUI is now possible
When viewing a graph in the GUI it is now possible to open the context menu
and click on "Export as JSON" to get the data that is shown in the graph as
JSON output.
Change-Id: Ib734272b43ba2da640b63be1d5d6c5bccf0aee55
---
.werks/5363 | 12 ++++++++++++
web/htdocs/js/checkmk.js | 8 ++++++++
web/htdocs/visuals.py | 17 +++++++++++++++++
3 files changed, 37 insertions(+)
diff --git a/.werks/5363 b/.werks/5363
new file mode 100644
index 0000000..d1b562d
--- /dev/null
+++ b/.werks/5363
@@ -0,0 +1,12 @@
+Title: Exporting graph data in JSON format via GUI is now possible
+Level: 2
+Component: multisite
+Compatible: compat
+Edition: cee
+Version: 1.5.0i1
+Date: 1507210788
+Class: feature
+
+When viewing a graph in the GUI it is now possible to open the context menu
+and click on "Export as JSON" to get the data that is shown in the graph as
+JSON output.
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 6de3b29..33b35d6 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -3262,6 +3262,14 @@ function pagetype_add_to_container(page_type, page_name)
});
}
+function graph_export()
+{
+ var request = {
+ "specification": popup_data[2]
+ };
+ location.href = "graph_export.py?request=" +
encodeURIComponent(JSON.stringify(request));
+}
+
//#.
//# .-HoverMenu----------------------------------------------------------.
//# | _ _ __ __ |
diff --git a/web/htdocs/visuals.py b/web/htdocs/visuals.py
index 731be69..19308f4 100644
--- a/web/htdocs/visuals.py
+++ b/web/htdocs/visuals.py
@@ -1538,6 +1538,7 @@ def ajax_popup_add():
add_type = html.var("add_type")
html.open_ul()
+
pagetypes.render_addto_popup(add_type)
for visual_type_name, visual_type in visual_types.items():
@@ -1564,6 +1565,22 @@ def ajax_popup_add():
html.write(title)
html.close_a()
html.close_li()
+
+ # TODO: Find a good place for this special case. This needs to be modularized.
+ if add_type == "pnpgraph":
+ html.open_li()
+ html.open_span()
+ html.write("%s:" % _("Export"))
+ html.close_span()
+ html.close_li()
+
+ html.open_li()
+ html.open_a(href="javascript:graph_export()")
+ html.img(src="images/icon_download.png")
+ html.write(_("Export as JSON"))
+ html.close_a()
+ html.close_li()
+
html.close_ul()