Module: check_mk
Branch: master
Commit: ed7dba5a254d77e27577715774b22c7d217aa8bf
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ed7dba5a254d77…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu Jan 28 16:11:28 2016 +0100
#2974 Added short cut icon 'archive this event' to event console events view
---
.werks/2974 | 9 +++++++++
ChangeLog | 1 +
mkeventd/web/plugins/views/mkeventd.py | 32 +++++++++++++++++++++++++++++---
web/htdocs/htmllib.py | 2 +-
web/htdocs/views.py | 23 +++++++++++++++++++----
5 files changed, 59 insertions(+), 8 deletions(-)
diff --git a/.werks/2974 b/.werks/2974
new file mode 100644
index 0000000..9c2658f
--- /dev/null
+++ b/.werks/2974
@@ -0,0 +1,9 @@
+Title: Added short cut icon 'archive this event' to event console events view
+Level: 1
+Component: ec
+Compatible: compat
+Version: 1.2.7i4
+Date: 1453993730
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 818fa7c..65cd3ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -333,6 +333,7 @@
* 2733 Visibility of Event Console events more flexible now...
* 1306 mkeventd: The Recent event history can you be filtered by extended regexes
* 2903 Added "Service Level" to event simulation...
+ * 2974 Added short cut icon 'archive this event' to event console events
view
* 2719 FIX: Events Check: Links to EC were broken when using regular expressions as
application...
* 2757 FIX: Events Check: Fixed check finding too many events (host search was infix
search instead of full match)...
* 2795 FIX: mkeventd: send email action did not work if message text contains
umlauts...
diff --git a/mkeventd/web/plugins/views/mkeventd.py
b/mkeventd/web/plugins/views/mkeventd.py
index 5f6f488..8982fa2 100644
--- a/mkeventd/web/plugins/views/mkeventd.py
+++ b/mkeventd/web/plugins/views/mkeventd.py
@@ -25,7 +25,7 @@
# Boston, MA 02110-1301 USA.
import mkeventd
-from valuespec import *
+from valuespec import *
try:
mkeventd_enabled = config.mkeventd_enabled
@@ -495,7 +495,7 @@ if mkeventd_enabled:
"paint" : lambda row: ("",
mkeventd.phase_names.get(row["event_phase"], ''))
}
- def paint_event_icons(row):
+ def render_event_phase_icons(row):
phase = row["event_phase"]
if phase == "ack":
title = _("This event has been acknowledged.")
@@ -504,8 +504,33 @@ if mkeventd_enabled:
elif phase == "delayed":
title = _("The action of this event is still delayed in the hope of a
cancelling event.")
else:
+ return ''
+ return html.render_icon(phase, help=title)
+
+ def render_delete_event_icons(row):
+ if config.may("mkeventd.delete"):
+ # Found no cleaner way to get the view. Sorry.
+ view = get_view_by_name(html.var("view_name"))
+ urlvars = [
+ ("filled_in", "actions"),
+ ("actions", "yes"),
+ ("_do_actions", "yes"),
+ ("_row_id", row_id(view, row)),
+ ("_delete_event", _("Archive Event")),
+ ("_show_result", "0"),
+ ]
+ url = html.makeactionuri(urlvars)
+ return html.render_icon_button(url, _("Archive this event"),
"delete")
+ else:
+ return ''
+
+ def paint_event_icons(row):
+ htmlcode = render_event_phase_icons(row)
+ htmlcode += render_delete_event_icons(row)
+ if htmlcode:
+ return "icons", htmlcode
+ else:
return "", ""
- return 'icons', '<img class=icon title="%s"
src="images/icon_%s.png">' % (title, phase)
multisite_painters["event_icons"] = {
"title" : _("Event Icons"),
@@ -515,6 +540,7 @@ if mkeventd_enabled:
"paint" : paint_event_icons,
}
+
def paint_event_contact_groups(row):
cgs = row.get("event_contact_groups")
if cgs == None:
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 6f1c521..d73cb17 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -337,7 +337,7 @@ class html(GUITester):
def makeuri_contextless(self, vars, filename=None):
if not filename:
- filename = self.myfile + ".py"
+ filename = self.myfile + ".py"
if vars:
return filename + "?" + self.urlencode_vars(vars)
else:
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index b4c5f69..5f054c0 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -1211,6 +1211,11 @@ def render_view(view, rows, datasource, group_painters, painters,
if show_checkboxes and html.do_actions():
rows = filter_selected_rows(view, rows,
weblib.get_rowselection('view-' + view['name']))
+ # 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)
+
if html.do_actions() and html.transaction_valid(): # submit button pressed, no
reload
try:
# Create URI with all actions variables removed
@@ -1994,10 +1999,22 @@ def do_actions(view, what, action_rows, backurl):
weblib.selection_id()
backurl += "&selection=" + html.var("selection")
message += '<br><a href="%s">%s</a>'
% (backurl, _('Back to view with checkboxes reset'))
+ if html.var("_show_result") == "0":
+ html.immediate_browser_redirect(0.5, backurl)
html.message(message)
return True
+
+def filter_by_row_id(view, rows):
+ wanted_row_id = html.var("_row_id")
+
+ for row in rows:
+ if row_id(view, row) == wanted_row_id:
+ return [row]
+ return []
+
+
def filter_selected_rows(view, rows, selected_ids):
action_rows = []
for row in rows:
@@ -2165,11 +2182,9 @@ def link_to_view(content, row, view_name):
def docu_link(topic, text):
return '<a href="%s" target="_blank">%s</a>'
% (config.doculink_urlformat % topic, text)
+# Calculates a uniq id for each data row which identifies the current
+# row accross different page loadings.
def row_id(view, row):
- '''
- Calculates a uniq id for each data row which identifies the current
- row accross different page loadings.
- '''
key = ''
for col in multisite_datasources[view['datasource']]['idkeys']:
key += '~%s' % row[col]