Module: check_mk
Branch: master
Commit: 98c72c4ca2a7e5b0f3cac738294637281d733805
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=98c72c4ca2a7e5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Mar 15 11:13:16 2016 +0100
3290 FIX Fixed broken event quick delete icon when used in dashlets
---
.werks/3290 | 10 ++++++++++
ChangeLog | 1 +
mkeventd/web/plugins/views/mkeventd.py | 29 ++++++++++++++++++++++++++---
web/htdocs/dashboard.py | 21 ++++++++++++---------
web/htdocs/views.py | 6 ++++++
5 files changed, 55 insertions(+), 12 deletions(-)
diff --git a/.werks/3290 b/.werks/3290
new file mode 100644
index 0000000..6a25fa0
--- /dev/null
+++ b/.werks/3290
@@ -0,0 +1,10 @@
+Title: Fixed broken event quick delete icon when used in dashlets
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1458036774
+
+
diff --git a/ChangeLog b/ChangeLog
index b0a6b2c..1d19bbb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -99,6 +99,7 @@
* 3279 FIX: LDAP: Fixed default values of attribute selections...
* 3285 FIX: Fixed exception when editing large bookmark lists
* 3287 FIX: Fixed broken crash reporting (Submission of crashes did not work)
+ * 3290 FIX: Fixed broken event quick delete icon when used in dashlets
WATO:
* 3244 WATO BI Module: swap order of aggregation function and child node
selection...
diff --git a/mkeventd/web/plugins/views/mkeventd.py
b/mkeventd/web/plugins/views/mkeventd.py
index 10b1c44..42e95ae 100644
--- a/mkeventd/web/plugins/views/mkeventd.py
+++ b/mkeventd/web/plugins/views/mkeventd.py
@@ -510,9 +510,32 @@ if mkeventd_enabled:
def render_delete_event_icons(row):
if config.may("mkeventd.delete"):
+ urlvars = []
+
# Found no cleaner way to get the view. Sorry.
- view = get_view_by_name(html.var("view_name"))
- urlvars = [
+ # TODO: This needs to be cleaned up with the new view implementation.
+ if html.has_var("name") and html.has_var("id"):
+ ident = int(html.var("id"))
+
+ import dashboard
+ dashboard.load_dashboards()
+ view = dashboard.get_dashlet(html.var("name"), ident)
+
+ # These actions are not performed within the dashlet. Assume the title
url still
+ # links to the source view where the action can be performed.
+ title_url = view.get("title_url")
+ if title_url:
+ from urlparse import urlparse, parse_qsl
+ url = urlparse(title_url)
+ filename = url.path
+ urlvars += parse_qsl(url.query)
+ else:
+ # Regular view
+ view = get_view_by_name(html.var("view_name"))
+ target = None
+ filename = None
+
+ urlvars += [
("filled_in", "actions"),
("actions", "yes"),
("_do_actions", "yes"),
@@ -520,7 +543,7 @@ if mkeventd_enabled:
("_delete_event", _("Archive Event")),
("_show_result", "0"),
]
- url = html.makeactionuri(urlvars)
+ url = html.makeactionuri(urlvars, filename=filename)
return html.render_icon_button(url, _("Archive this event"),
"delete")
else:
return ''
diff --git a/web/htdocs/dashboard.py b/web/htdocs/dashboard.py
index 7ae5125..8388315 100644
--- a/web/htdocs/dashboard.py
+++ b/web/htdocs/dashboard.py
@@ -610,6 +610,17 @@ def get_dashlet_type(dashlet):
return dashlet_types[dashlet["type"]]
+def get_dashlet(board, ident):
+ if board not in available_dashboards:
+ raise MKGeneralException(_('The requested dashboard does not exist.'))
+ dashboard = available_dashboards[board]
+
+ try:
+ return dashboard['dashlets'][ident]
+ except IndexError:
+ raise MKGeneralException(_('The dashlet does not exist.'))
+
+
# Use the URL returned by urlfunc as dashlet URL
#
# We need to support function pointers to be compatible to old dashboard plugin
@@ -1187,15 +1198,7 @@ def check_ajax_update():
ident = int(html.var('id'))
load_dashboards(lock=True)
-
- if board not in available_dashboards:
- raise MKGeneralException(_('The requested dashboard does not exist.'))
- dashboard = available_dashboards[board]
-
- try:
- dashlet = dashboard['dashlets'][ident]
- except IndexError:
- raise MKGeneralException(_('The dashlet does not exist.'))
+ dashlet = get_dashlet(board, ident)
return dashlet, dashboard
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index fe9b553..fc23571 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -1238,6 +1238,12 @@ def render_view(view, rows, datasource, group_painters, painters,
# web service e.g. for NagStaMon)
elif row_count > 0 and config.may("general.act") \
and html.do_actions() and html.transaction_valid():
+
+ # There are one shot actions which only want to affect one row, filter the rows
+ # by this id during actions
+ if html.has_var("_row_id") and html.do_actions():
+ rows = filter_by_row_id(view, rows)
+
try:
do_actions(view, datasource["infos"][0], rows, '')
except: