Module: check_mk
Branch: master
Commit: 5686cf7da2a3f5117fa8a963c4a2e07c3ce15028
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5686cf7da2a3f5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Aug 25 14:44:51 2015 +0200
#2512 Custom Icons/Actions: URLs target frames can now be configured
In previous versions the URLs were always opened within the current frameset
instead of the current content frame page. Now you can configure the URLs to
be opened in new frames/tabs or instead of the frameset.
---
.werks/2512 | 11 +++++++++
ChangeLog | 1 +
web/htdocs/views.py | 26 ++++++++++++++++----
web/plugins/views/painters.py | 15 ++++++++----
web/plugins/wato/check_mk_configuration.py | 36 ++++++++++++++++++++--------
5 files changed, 71 insertions(+), 18 deletions(-)
diff --git a/.werks/2512 b/.werks/2512
new file mode 100644
index 0000000..1ea10f9
--- /dev/null
+++ b/.werks/2512
@@ -0,0 +1,11 @@
+Title: Custom Icons/Actions: URLs target frames can now be configured
+Level: 1
+Component: multisite
+Compatible: compat
+Version: 1.2.7i3
+Date: 1440506631
+Class: feature
+
+In previous versions the URLs were always opened within the current frameset
+instead of the current content frame page. Now you can configure the URLs to
+be opened in new frames/tabs or instead of the frameset.
diff --git a/ChangeLog b/ChangeLog
index c08a728..4b8d591 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -149,6 +149,7 @@
* 2484 Virtual Host Tree now allows adding levels of WATO folders...
* 2501 Implemented new crash report handling...
* 2491 Allow clickable URLs in comments and downtime texts...
+ * 2512 Custom Icons/Actions: URLs target frames can now be configured...
* 2314 FIX: Availability: fixed exception when grouping by host or service group
* 2361 FIX: Fix exception for missing key 'title' in certain cases of older
customized views
* 2379 FIX: Plugin-Output: Fixed handling of URLs within output of check_http...
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 7ed9456..92f988f 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -2542,22 +2542,40 @@ def ajax_popup_action_menu():
for icon in icons:
html.write('<li>\n')
if len(icon) == 4:
- icon_name, title, url = icon[1:]
- if url:
+ icon_name, title, url_spec = icon[1:]
+ if url_spec:
+ url, target_frame = sanitize_action_url(url_spec)
+
url = replace_action_url_macros(url, what, row)
+
onclick = ''
if url.startswith('onclick:'):
onclick = ' onclick="%s"' % url[8:]
url = 'javascript:void(0)'
- html.write('<a href="%s"%s>' % (url, onclick))
+
+ target = ""
+ if target_frame != "_self":
+ target = " target=\"%s\"" % target_frame
+
+ html.write('<a href="%s"%s%s>' % (url, target,
onclick))
+
html.icon('', icon_name)
+
if title:
html.write(title)
else:
html.write(_("No title"))
- if url:
+
+ if url_spec:
html.write('</a>')
else:
html.write(icon[1])
html.write('</li>\n')
html.write('</ul>\n')
+
+
+def sanitize_action_url(url_spec):
+ if type(url_spec) == tuple:
+ return url_spec
+ else:
+ return (url_spec, "_self")
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index fc9f0b9..fd085cf 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -288,16 +288,23 @@ def paint_icons(what, row):
output = ''
for icon in toplevel_icons:
if len(icon) == 4:
- icon_name, title, url = icon[1:]
- if url:
+ icon_name, title, url_spec = icon[1:]
+ if url_spec:
+ url, target_frame = sanitize_action_url(url_spec)
url = replace_action_url_macros(url, what, row)
+
onclick = ''
if url.startswith('onclick:'):
onclick = ' onclick="%s"' % url[8:]
url = 'javascript:void(0)'
- output += '<a href="%s"%s>' % (url, onclick)
+
+ target = ""
+ if target_frame != "_self":
+ target = " target=\"%s\"" % target_frame
+
+ output += '<a href="%s"%s%s>' % (url, target,
onclick)
output += html.render_icon(icon_name, title)
- if url:
+ if url_spec:
output += '</a>'
else:
output += icon[1]
diff --git a/web/plugins/wato/check_mk_configuration.py
b/web/plugins/wato/check_mk_configuration.py
index 2660b37..7df6b18 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -494,16 +494,32 @@ register_configvar(group,
allow_empty = False
)),
('title', TextUnicode(title = _('Title'))),
- ('url', TextAscii(
- title = _('Action URL'),
- help = _('This URL is opened when clicking on the
action / icon. You '
- 'can use some macros within the URL which
are dynamically '
- 'replaced for each object. These
are:<br>'
- '<ul><li>$HOSTNAME$: Contains
the name of the host</li>'
- '<li>$SERVICEDESC$: Contains the
service description '
- '(in case this is a
service)</li>'
- '<li>$HOSTADDRESS$: Contains the
network address of the host</li></ul>'),
- size = 80,
+ ('url', Transform(
+ Tuple(
+ title = _('Action'),
+ elements = [
+ TextAscii(
+ title = _('URL'),
+ help = _('This URL is opened when
clicking on the action / icon. You '
+ 'can use some macros within the
URL which are dynamically '
+ 'replaced for each object. These
are:<br>'
+ '<ul><li>$HOSTNAME$:
Contains the name of the host</li>'
+ '<li>$SERVICEDESC$:
Contains the service description '
+ '(in case this is a
service)</li>'
+ '<li>$HOSTADDRESS$:
Contains the network address of the host</li></ul>'),
+ size = 80,
+ ),
+ DropdownChoice(
+ title = _("Open in"),
+ choices = [
+ ("_blank", _("Load in a
new window / tab")),
+ ("_self", _("Load in
current content area (keep sidebar)")),
+ ("_top", _("Load as new
page (hide sidebar)")),
+ ],
+ ),
+ ],
+ ),
+ forth = lambda x: type(x) != tuple and (x,
"_self") or x,
)),
('toplevel', FixedValue(True,
title = _('Show in column'),