Module: check_mk
Branch: master
Commit: afc64b910b2e80499a190e8fbc0851f7009b6d7a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=afc64b910b2e80…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jan 19 19:47:22 2017 +0100
CEE: Graph collections can now be added to reports
Change-Id: If1cca70228a48d006fdbc230cb1c6b11844e6ea1
---
web/htdocs/dashboard.py | 5 ++++-
web/htdocs/htmllib.py | 13 +++++++++++++
web/htdocs/pagetypes.py | 1 -
web/htdocs/visuals.py | 8 ++++++--
4 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/web/htdocs/dashboard.py b/web/htdocs/dashboard.py
index 39f71ca..a6340cd 100644
--- a/web/htdocs/dashboard.py
+++ b/web/htdocs/dashboard.py
@@ -1267,10 +1267,13 @@ def ajax_dashlet_pos():
# | |
# '----------------------------------------------------------------------'
-def popup_list_dashboards():
+def popup_list_dashboards(add_type):
if not config.user.may("general.edit_dashboards"):
return []
+ if add_type == "graph_collection":
+ return
+
load_dashboards()
return [ (name, board["title"])
for (name, board)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index b09a5ef..a5df3f2 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -2385,6 +2385,8 @@ class html(DeprecationWrapper):
self.store_new_transids()
+ # TODO: Rename the status_icons because they are not only showing states. There are
also actions.
+ # Something like footer icons or similar seems to be better
def _write_status_icons(self):
self.icon_button(self.makeuri([]), _("URL to this frame"),
"frameurl", target="_top",
cssclass="inline")
@@ -2398,6 +2400,7 @@ class html(DeprecationWrapper):
_("Export as CSV"),
"download_csv", target="_top",
cssclass="inline")
+ # TODO: This needs to be realized as plugin mechanism
if self.myfile == "view":
mode_name = self.var('mode') == "availability" and
"availability" or "view"
@@ -2414,6 +2417,16 @@ class html(DeprecationWrapper):
'add_visual', 'add_visual', data=[mode_name,
encoded_vars, {'name': self.var('view_name')}],
url_vars=[("add_type", "view")])
+ # TODO: This should be handled by pagetypes.py
+ elif self.myfile == "graph_collection":
+
+ self.popup_trigger(
+ self.render_icon("menu", _("Add this graph collection
to..."),
+ cssclass="iconbutton inline"),
+ 'add_visual', 'add_visual',
data=["graph_collection", {}, {'name': self.var('name')}],
+ url_vars=[("add_type", "graph_collection")])
+
+
for img, tooltip in self.status_icons.items():
if type(tooltip) == tuple:
tooltip, url = tooltip
diff --git a/web/htdocs/pagetypes.py b/web/htdocs/pagetypes.py
index eb6f35e..c591fb7 100644
--- a/web/htdocs/pagetypes.py
+++ b/web/htdocs/pagetypes.py
@@ -393,7 +393,6 @@ class PageRenderer(Base):
return ""
-
#.
# .--Overridable---------------------------------------------------------.
# | ___ _ _ _ _ |
diff --git a/web/htdocs/visuals.py b/web/htdocs/visuals.py
index ea962b1..04c6617 100644
--- a/web/htdocs/visuals.py
+++ b/web/htdocs/visuals.py
@@ -1467,10 +1467,14 @@ def ajax_popup_add():
if "popup_add_handler" in visual_type:
module_name = visual_type["module_name"]
visual_module = __import__(module_name)
+
handler = visual_module.__dict__[visual_type["popup_add_handler"]]
- visuals = handler()
+ visuals = handler(add_type)
+ if not visuals:
+ continue
+
html.write('<li><span>%s %s:</span></li>' %
(_('Add to'), visual_type["title"]))
- for name, title in sorted(handler(), key=lambda x: x[1]):
+ for name, title in sorted(visuals, key=lambda x: x[1]):
html.write('<li><a href="javascript:void(0)"
'
'onclick="add_to_visual(\'%s\',
\'%s\')"><img src="images/icon_%s.png">
%s</a></li>' %
(visual_type_name, name, visual_type_name.rstrip('s'),
title))