Module: check_mk
Branch: master
Commit: 418ca64bfeeee864a6965c6fa617086249df135c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=418ca64bfeeee8…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jul 24 16:34:41 2015 +0200
#2485 FIX Fix Icon "BI Aggregations containing this service", also avoid BI
compilation without need
This werk contains a fix and a speedup: The fix repairs the BI icon that is now contained
in
the drop down menu rather than directly in the view. The URL where the icon pointed was
broken.
The second change is a speedup: Pages that do not show BI aggregates now do now trigger
BI
compilation anymore. This is delayed until the command/icon menu is being opened. Here
the
BI icon needs to be displayed and hence the compilation triggered.
---
.werks/2485 | 13 +++++++++++++
ChangeLog | 1 +
web/htdocs/bi.py | 22 ---------------------
web/htdocs/views.py | 6 +++---
web/plugins/icons/builtin.py | 2 +-
web/plugins/views/painters.py | 43 ++++++++++++++++++-----------------------
6 files changed, 37 insertions(+), 50 deletions(-)
diff --git a/.werks/2485 b/.werks/2485
new file mode 100644
index 0000000..fc90c00
--- /dev/null
+++ b/.werks/2485
@@ -0,0 +1,13 @@
+Title: Fix Icon "BI Aggregations containing this service", also avoid BI
compilation without need
+Level: 2
+Component: bi
+Compatible: compat
+Version: 1.2.7i3
+Date: 1437748351
+Class: fix
+
+This werk contains a fix and a speedup: The fix repairs the BI icon that is now contained
in
+the drop down menu rather than directly in the view. The URL where the icon pointed was
broken.
+The second change is a speedup: Pages that do not show BI aggregates now do now trigger
BI
+compilation anymore. This is delayed until the command/icon menu is being opened. Here
the
+BI icon needs to be displayed and hence the compilation triggered.
diff --git a/ChangeLog b/ChangeLog
index d7f24df..04dca7a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -131,6 +131,7 @@
BI:
* 2369 FIX: Fix exception in BI availability via table "Hostname
Aggregations"
* 2370 FIX: Fix computation of "in downtime" and "acknownledged"
of hosts in BI aggregations...
+ * 2485 FIX: Fix Icon "BI Aggregations containing this service", also avoid
BI compilation without need...
Event Console:
* 2411 Check check_mkevents: Now able to look for events matching the host alias...
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index 4477107..060abb8 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -1713,28 +1713,6 @@ def filter_tree_only_problems(tree):
return state, assumed_state, node, new_subtrees
-def page_timeline():
- aggr_group = html.var("av_aggr_group")
- aggr_name = html.var("av_aggr_name")
-
- # First compile the required BI aggregates.
- if config.bi_precompile_on_demand:
- compile_forest(config.user_id, only_groups = [ aggr_group ])
- else:
- compile_forest(config.user_id)
-
- # In the resulting collection of BI aggregates find
- # our tree
- for tree in g_user_cache["forest"][aggr_group]:
- if tree["title"] == aggr_name:
- break
- else:
- raise MKGeneralException("No aggregation with the name %s" %
- aggr_name)
- row = { "aggr_tree" : tree, "aggr_group" : aggr_group }
- views.render_bi_availability(aggr_name, [row])
-
-
# ____ _
# | _ \ __ _| |_ __ _ ___ ___ _ _ _ __ ___ ___ ___
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 88df516..2ed61a0 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -2541,8 +2541,8 @@ def ajax_popup_action_menu():
html.write('<ul>\n')
for icon in icons:
html.write('<li>\n')
- if len(icon) == 5:
- icon_name, title, url = icon[2:]
+ if len(icon) == 4:
+ icon_name, title, url = icon[1:]
if url:
url = replace_action_url_macros(url, what, row)
onclick = ''
@@ -2555,6 +2555,6 @@ def ajax_popup_action_menu():
if url:
html.write('</a>')
else:
- html.write(icon[2])
+ html.write(icon[1])
html.write('</li>\n')
html.write('</ul>\n')
diff --git a/web/plugins/icons/builtin.py b/web/plugins/icons/builtin.py
index 824ec70..1895e6c 100644
--- a/web/plugins/icons/builtin.py
+++ b/web/plugins/icons/builtin.py
@@ -713,7 +713,7 @@ def paint_aggregations(what, row, tags, host_custom_vars):
urivars += [
( "aggr_service_service",
row["service_description"])
]
- url = html.makeuri_contextless(urivars)
+ url = html.makeuri_contextless(urivars, filename="view.py")
return 'aggr', _("BI Aggregations containing this %s") % \
(what == "host" and _("Host") or
_("Service")), url
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index de8614f..2f6b5de 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -162,14 +162,16 @@ def get_multisite_icons():
return icons
-def process_multisite_icons(what, row, tags, custom_vars):
+def process_multisite_icons(what, row, tags, custom_vars, toplevel):
icons = []
for icon_id, icon in get_multisite_icons().items():
if icon.get('type', 'icon') == 'icon':
try:
title = None
url = None
- toplevel = icon['toplevel']
+ if icon['toplevel'] != toplevel:
+ continue
+
sort_index = icon['sort_index']
# In old versions, the icons produced html code directly. The new API
@@ -190,7 +192,7 @@ def process_multisite_icons(what, row, tags, custom_vars):
# case (html), it can simply be appended to the output.
Otherwise
# extract the icon name from icon images
if html.output_format == "html":
- icons.append((toplevel, sort_index, result))
+ icons.append((sort_index, result))
else:
# Strip icon names out of HTML code that is generated by
htmllib.render_icon()
for n in regex('<img
src="([^"]*)"[^>]*>').findall(result):
@@ -202,7 +204,7 @@ def process_multisite_icons(what, row, tags, custom_vars):
n = n[:-4]
elif n.endswith(".gif"):
n = n[:-4]
- icons.append((toplevel, sort_index,
n.encode('utf-8'), None, None))
+ icons.append((sort_index, n.encode('utf-8'),
None, None))
continue
else:
@@ -212,15 +214,15 @@ def process_multisite_icons(what, row, tags, custom_vars):
icon_name, title = result
elif len(result) == 3:
icon_name, title, url = result
- icons.append((toplevel, sort_index, icon_name, title, url))
+ icons.append((sort_index, icon_name, title, url))
except Exception, e:
import traceback
- icons.append((toplevel, sort_index, 'Exception in icon plugin!<br
/>' + traceback.format_exc()))
+ icons.append((sort_index, 'Exception in icon plugin!<br />'
+ traceback.format_exc()))
return icons
-def process_custom_user_icons_and_actions(user_action_ids):
+def process_custom_user_icons_and_actions(user_action_ids, toplevel):
icons = []
for id in user_action_ids:
try:
@@ -228,10 +230,9 @@ def process_custom_user_icons_and_actions(user_action_ids):
except KeyError:
continue # Silently skip not existing icons
- toplevel = icon.get('toplevel', False)
- sort_index = icon.get('sort_index', 15)
-
- icons.append((toplevel, sort_index, icon['icon'],
icon.get('title'), icon.get('url')))
+ if icon.get('toplevel', False) == toplevel:
+ sort_index = icon.get('sort_index', 15)
+ icons.append((sort_index, icon['icon'], icon.get('title'),
icon.get('url')))
return icons
@@ -257,15 +258,9 @@ def get_icons(what, row, toplevel):
# is written to HTML
# -> or when an exception occured
# (toplevel, sort_index, icon_name, title, url)
- icons = process_multisite_icons(what, row, tags, host_custom_vars)
- icons += process_custom_user_icons_and_actions(user_action_ids)
-
- if toplevel:
- # Returns the toplevel icons
- return sorted([ i for i in icons if i[0] ], key = lambda i: i[1])
- else:
- # Returns the menu icons
- return sorted([ i for i in icons if not i[0] ], key = lambda i: i[1])
+ icons = process_multisite_icons(what, row, tags, host_custom_vars, toplevel)
+ icons += process_custom_user_icons_and_actions(user_action_ids, toplevel)
+ return sorted(icons, key = lambda i: i[0])
def replace_action_url_macros(url, what, row):
@@ -288,12 +283,12 @@ def paint_icons(what, row):
# In case of non HTML output, just return the top level icon names
# as space separated string
if html.output_format != 'html':
- return 'icons', ' '.join([ i[2] for i in toplevel_icons ])
+ return 'icons', ' '.join([ i[1] for i in toplevel_icons ])
output = ''
for icon in toplevel_icons:
- if len(icon) == 5:
- icon_name, title, url = icon[2:]
+ if len(icon) == 4:
+ icon_name, title, url = icon[1:]
if url:
url = replace_action_url_macros(url, what, row)
onclick = ''
@@ -305,7 +300,7 @@ def paint_icons(what, row):
if url:
output += '</a>'
else:
- output += icon[2]
+ output += icon[1]
return "icons", output