Module: check_mk
Branch: master
Commit: 2b25ae6d8bdc6b2b2028a0744c0dafd6f765ec9a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2b25ae6d8bdc6b…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Oct 27 16:15:33 2015 +0100
Cleaned up duplicated code
---
web/htdocs/htmllib.py | 26 ++++++++++++--------------
web/plugins/sidebar/shipped.py | 12 +++---------
2 files changed, 15 insertions(+), 23 deletions(-)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 2a18684..9c54750 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -405,7 +405,8 @@ class html:
def empty_icon(self):
self.write('<img class=icon src="images/trans.png" />')
- def icon_button(self, url, help, icon, id="", onclick="",
style="", target="", cssclass=""):
+
+ def render_icon_button(self, url, help, icon, id="", onclick="",
style="", target="", cssclass=""):
if id:
id = "id='%s' " % id
@@ -422,19 +423,16 @@ class html:
if cssclass:
cssclass = 'class="%s" ' % cssclass
- self.write('<a %s%s%s%s%sonfocus="if (this.blur) this.blur();"
href="%s">'
- '<img align=absmiddle class=iconbutton title="%s"
'
- 'src="images/button_%s_lo.png" '
- 'onmouseover=\"hilite_icon(this, 1)\" '
- 'onmouseout=\"hilite_icon(this, 0)\">'
- '</a>' % (id, onclick, style, target, cssclass, url,
self.attrencode(help), icon))
-
- def render_icon_button(self, *args, **kwargs):
- self.plug()
- self.icon_button(*args, **kwargs)
- code = self.drain()
- self.unplug()
- return code
+ return '<a %s%s%s%s%sonfocus="if (this.blur) this.blur();"
href="%s">' \
+ '<img align=absmiddle class=iconbutton title="%s"
' \
+ 'src="images/button_%s_lo.png" ' \
+ 'onmouseover=\"hilite_icon(this, 1)\" ' \
+ 'onmouseout=\"hilite_icon(this, 0)\">' \
+ '</a>' % (id, onclick, style, target, cssclass, url,
self.attrencode(help), icon)
+
+
+ def icon_button(self, *args, **kwargs):
+ self.write(self.render_icon_button(*args, **kwargs))
def empty_icon_button(self):
diff --git a/web/plugins/sidebar/shipped.py b/web/plugins/sidebar/shipped.py
index 022246e..e3b7b7d 100644
--- a/web/plugins/sidebar/shipped.py
+++ b/web/plugins/sidebar/shipped.py
@@ -1726,15 +1726,9 @@ def render_tag_tree_level(taggroups, path, cwd, title, tree):
if path != cwd and is_tag_subdir(path, cwd):
bullet = tag_tree_bullet(tag_tree_worst_state(tree), path, False)
if tag_tree_has_svc_problems(tree):
- # We cannot use html.plug() here, since this is not (yet)
- # reentrant and it is used by the sidebar snapin updater.
- # So we need to duplicate the code of icon_button here:
- bullet += ('<a target="main" onfocus="if (this.blur)
this.blur();" href="%s">'
- '<img align=absmiddle class=iconbutton title="%s"
src="images/button_svc_problems_lo.png" '
- 'onmouseover="hilite_icon(this, 1)"
onmouseout="hilite_icon(this, 0)"></a>' % (
- tag_tree_url(taggroups, path, "svcproblems"),
- _("Show the service problems contained in this
branch")))
-
+ bullet += html.render_icon_button(tag_tree_url(taggroups, path,
"svcproblems"),
+ _("Show the service problems contained in
this branch"),
+ "svc_problems")
if path:
html.begin_foldable_container("tag-tree",
".".join(map(str, path)), False, bullet + title)