Module: check_mk
Branch: master
Commit: 209496b8b52fc387af3ffba734856a9d3bb9afd1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=209496b8b52fc3…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sat Oct 29 11:44:38 2011 +0200
WATO: rule editor: add titles to host tags
---
web/htdocs/js/wato.js | 9 +++++++
web/htdocs/wato.py | 63 +++++++++++++++++++++++++++++++-----------------
2 files changed, 50 insertions(+), 22 deletions(-)
diff --git a/web/htdocs/js/wato.js b/web/htdocs/js/wato.js
index f10930f..0480f9b 100644
--- a/web/htdocs/js/wato.js
+++ b/web/htdocs/js/wato.js
@@ -84,6 +84,15 @@ function wato_toggle_dropdown(oDropdown, divid) {
oDiv = null;
}
+function wato_toggle_dropdownn(oDropdown, divid) {
+ var oDiv = document.getElementById(divid);
+ if (oDropdown.value == "ignore")
+ oDiv.style.display = "none";
+ else
+ oDiv.style.display = "";
+ oDiv = null;
+}
+
// ----------------------------------------------------------------------------
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index b0827fe..7b6f936 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -4432,9 +4432,9 @@ class ElementSelection(ValueSpec):
self.load_elements()
if len(self._elements) == 0:
raise MKUserError(varprefix,
- _("You cannot save this rule. There are not defined any elements for
this selection yet." % self._what))
+ _("You cannot save this rule. There are not defined any elements for
this selection yet."))
if value not in self._elements:
- raise MKUserError(varprefix, _("%s is not an existing element in this
selection.") % (value, self._what))
+ raise MKUserError(varprefix, _("%s is not an existing element in this
selection.") % (value,))
def validate_datatype(self, value, varprefix):
if type(value) != str:
@@ -7830,29 +7830,48 @@ def mode_edit_rule(phase):
html.write(_("You have not configured any host tags. If you work with rules
"
"you should better do so and add a <tt>wato_host_tags =
..</tt> "
"to your <tt>multisite.mk</tt>. You will find an
example there."))
- for id, title, tags in config.wato_host_tags:
- default_tag = None
- ignore = True
- for t in tag_specs:
- if t[0] == '!':
- n = True
- t = t[1:]
+ else:
+ html.write("<table>")
+ for id, title, tags in config.wato_host_tags:
+ html.write("<tr><td>%s: </td>" %
title)
+ default_tag = None
+ ignore = True
+ for t in tag_specs:
+ if t[0] == '!':
+ n = True
+ t = t[1:]
+ else:
+ n = False
+ if t in [ x[0] for x in tags]:
+ ignore = False
+ negate = n
+ if ignore:
+ deflt = "ignore"
+ elif negate:
+ deflt = "isnot"
+ else:
+ deflt = "is"
+
+ html.write("<td>")
+ html.select("tag_" + id, [
+ ("ignore", _("ignore")),
+ ("is", _("is")),
+ ("isnot", _("isnot"))], deflt,
+ onchange="wato_toggle_dropdownn(this, 'tag_sel_%s');" %
id)
+ html.write("</td><td>")
+ if html.form_submitted():
+ div_is_open = html.var("tag_" + id) != "ignore"
else:
- n = False
- if t in [ x[0] for x in tags]:
- ignore = False
- negate = n
-
- html.radiobutton("tag_" + id, "ignore", ignore,
_("ignore"))
- html.write(" ")
- html.radiobutton("tag_" + id, "is", not ignore and not
negate, _("is"))
- html.write(" ")
- html.radiobutton("tag_" + id, "isnot", not ignore and
negate, _("is not"))
- html.write(" ")
- html.select("tagvalue_" + id, [t[0:2] for t in tags if t[0] != None],
deflt=default_tag)
- html.write("<br>")
+ div_is_open = deflt != "ignore"
+ html.write('<div id="tag_sel_%s" style="white-space:
nowrap; %s">' % (
+ id, not div_is_open and "display: none;" or ""))
+ html.select("tagvalue_" + id, [t[0:2] for t in tags if t[0] !=
None], deflt=default_tag)
+ html.write("</div>")
+ html.write("</td></tr>")
+ html.write("</table>")
html.write("</td></tr>")
+
# Explicit hosts / ALL_HOSTS
html.write("<tr><td class=legend>")
html.write(_("Explicit hosts"))