Module: check_mk
Branch: master
Commit: 7dda352e0461eb80c0844d8000dc9e26146c3c88
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7dda352e0461eb…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Sun Nov 20 23:57:54 2011 +0100
WATO: add inheritance for dependent attributes
---
web/htdocs/js/wato.js | 9 +++++++++
web/htdocs/wato.py | 9 +++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/web/htdocs/js/wato.js b/web/htdocs/js/wato.js
index ae99f42..e86abea 100644
--- a/web/htdocs/js/wato.js
+++ b/web/htdocs/js/wato.js
@@ -76,6 +76,15 @@ function wato_fix_visibility() {
for (var i in oTable.childNodes) {
var oTr = oTable.childNodes[i];
if (oTr.nodeName == 'TR') {
+ /* If the Checkbox is unchecked try to get a value from the inherited_tags
*/
+ var oCheckbox = oTr.childNodes[1].childNodes[0]
+ if( oCheckbox.checked == false ){
+ attrname = oCheckbox.parentNode.parentNode.id
+ if( attrname in inherited_tags ){
+ currentTags =
currentTags.concat(inherited_tags[oCheckbox.parentNode.parentNode.id].split("|"))
+ }
+ continue
+ }
/* Find the <select>/<checkbox> object in this tr */
/* td.content div select/checkbox */
var oElement = oTr.childNodes[2].childNodes[0].childNodes[0];
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 91cd94e..2ecc2e5 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -3669,6 +3669,7 @@ def configure_attributes(hosts, for_what, parent, myself=None,
without_attribute
# Collect dependency mapping for attributes (attributes that are only
# visible, if certain host tags are set).
dependency_mapping = {}
+ inherited_tags = {}
for topic in topics:
if len(topics) > 1:
@@ -3743,6 +3744,8 @@ def configure_attributes(hosts, for_what, parent, myself=None,
without_attribute
inherited_from = _("Inherited from ") + '<a
href="%s">%s</a>' % (url, container["title"])
inherited_value = container["attributes"][attrname]
has_inherited = True
+ if topic == _("Host tags"):
+ inherited_tags["attr_%s" % attrname] = inherited_value
break
container = container.get(".parent")
@@ -3809,7 +3812,7 @@ def configure_attributes(hosts, for_what, parent, myself=None,
without_attribute
html.hidden_field(checkbox_name, "on")
else:
html.checkbox(checkbox_name, active,
- onclick = "wato_toggle_attribute(this, '%s');" %
attrname ) # Only select if value is unique
+ onclick = "wato_fix_visibility(); wato_toggle_attribute(this,
'%s');" % attrname) # Only select if value is unique
html.write("</td>")
# Now comes the input fields and the inherited / default values
@@ -3862,7 +3865,9 @@ def configure_attributes(hosts, for_what, parent, myself=None,
without_attribute
# Provide Javascript world with the tag dependency information
# of all attributes.
- html.javascript("var wato_depends_on = %r;\nwato_fix_visibility();\n" %
dependency_mapping)
+ html.javascript("var inherited_tags = %r;\n"\
+ "var wato_depends_on = %r;\n"\
+ "wato_fix_visibility();\n" % (inherited_tags,
dependency_mapping))
# Check if at least one host in a folder (or its subfolders)