Module: check_mk
Branch: master
Commit: 2f88f9125573200226981b015a809da867275075
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2f88f912557320…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri May 18 17:21:13 2012 +0200
Use dynamic items in rule editor for hosts and items
---
ChangeLog | 2 +
web/htdocs/check_mk.css | 25 ++++++++++++++
web/htdocs/pages.css | 1 +
web/htdocs/wato.py | 84 ++++++++++-------------------------------------
4 files changed, 46 insertions(+), 66 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 67a9bf4..52f994d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,8 @@
* New layout and new internal implementation of input forms
* New layout for view overview and view editor
* Split up host search in two distinct pages
+ * Use dynamic items in rule editor for hosts and items (making use
+ of ListOfStrings())
* FIX: audit log was not shown if no entry for today existed
* FIX: fix parent scan on single site installations
* FIX: fix folder visibility permission handling
diff --git a/web/htdocs/check_mk.css b/web/htdocs/check_mk.css
index 416c201..8c12bcc 100644
--- a/web/htdocs/check_mk.css
+++ b/web/htdocs/check_mk.css
@@ -137,6 +137,28 @@ select.icon option {
input.buttonlink {
padding: 1px;
font-size: 8pt;
+}
+
+input.button {
+ border-color: #86A9B8 #22404D #22414D #86A9B8;
+ border-radius: 5px 5px 5px 5px;
+ border-style: solid;
+ border-width: 1px;
+ box-shadow: 0 0 1.5px #000000;
+ margin-left: 5px;
+ padding: 2px 6px;
+ background-color: #497E95;
+ color: white;
+}
+
+input.button:hover {
+ background-color: #6da1b8;
+ text-decoration: none;
+}
+input.button:active {
+ border-color: #22414d #86a9b8 #86a9b8 #22404d;
+ background-color: #3b6678;
+ box-shadow: inset 0 0 0.5px #444444;
}
a.button {
@@ -443,6 +465,9 @@ div.listofstrings.horizontal > div {
float: left;
margin-right: 2px;
}
+div.listofstrings.horizontal > div:last-child {
+ float: none;
+}
table.listchoice {
cell-spacing: 0px;
diff --git a/web/htdocs/pages.css b/web/htdocs/pages.css
index bec54c3..50418a3 100644
--- a/web/htdocs/pages.css
+++ b/web/htdocs/pages.css
@@ -635,6 +635,7 @@ div.help {
font-weight: normal;
text-align: left;
color: black;
+ display: inline-block;
}
table.data div.help {
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 732dded..a96106f 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -9705,17 +9705,7 @@ def get_rule_conditions(ruleset):
else:
negate = html.get_checkbox("negate_hosts")
nr = 0
- host_list = []
- while True:
- var = "host_%d" % nr
- host = html.var(var)
- if nr > config.wato_num_itemspecs and not host:
- break
- if host:
- if negate:
- host = "!" + host
- host_list.append(host)
- nr += 1
+ host_list = ListOfStrings().from_html_vars("hostlist")
# append ALL_HOSTS to negated host lists
if len(host_list) > 0 and host_list[0][0] == '!':
host_list += ALL_HOSTS
@@ -9734,16 +9724,8 @@ def get_rule_conditions(ruleset):
itemspec = ListChoice(choices = itemenum, columns = 3)
item_list = [ x+"$" for x in
itemspec.from_html_vars("item") ]
else:
- nr = 0
- item_list = []
- while True:
- var = "item_%d" % nr
- item = html.var(var, "").strip()
- if nr > config.wato_num_itemspecs and not item:
- break
- if item:
- item_list.append(item)
- nr += 1
+ item_list = ListOfStrings().from_html_vars("itemlist")
+
if len(item_list) == 0:
raise MKUserError("item_0", _("Please specify at least one
%s or "
"this rule will never match.") %
ruleset["itemname"])
@@ -9857,29 +9839,13 @@ def mode_edit_rule(phase):
div_id, not checked and "none" or ""))
negate_hosts = len(host_list) > 0 and host_list[0].startswith("!")
- html.write("<table class=itemlist>")
- num_cols = 3
- for nr in range(config.wato_num_itemspecs):
- x = nr % num_cols
- if x == 0:
- html.write("<tr>")
- if nr < len(host_list) and host_list[nr] != ALL_HOSTS[0]:
- host_name = host_list[nr].strip("!")
- else:
- host_name = ""
- html.write("<td>")
- html.text_input("host_%d" % nr, host_name)
- html.write("</td>")
- if x == num_cols - 1:
- html.write("</tr>")
- while x < num_cols - 1:
- html.write("<td></td>")
- if x == num_cols - 1:
- html.write("</tr>")
- x += 1
- html.write("</table>")
- html.checkbox("negate_hosts", negate_hosts)
- html.write(" " + _("<b>Negate:</b> make Rule apply for
<b>all but</b> the above hosts") + "\n")
+ explicit_hosts = [ h.strip("!") for h in host_list if h != ALL_HOSTS[0] ]
+ ListOfStrings(
+ orientation = "horizontal",
+ valuespec = TextAscii(size = 30)).render_input("hostlist",
explicit_hosts)
+
+ html.checkbox("negate_hosts", negate_hosts, label =
+ _("<b>Negate:</b> make Rule apply for <b>all
but</b> the above hosts"))
html.write("</div>")
html.help(_("You can enter a number of explicit host names that rule should or
should "
"not apply to here. Leave this option disabled if you want the rule
to "
@@ -9914,9 +9880,9 @@ def mode_edit_rule(phase):
checked = html.get_checkbox("explicit_services")
if checked == None: # read from rule itself
checked = len(item_list) == 0 or item_list[0] != ""
- div_id = "itemlist"
- html.checkbox("explicit_services", checked,
onclick="valuespec_toggle_option(this, %r)" % div_id)
- html.write(" " + _("Specify explicit values"))
+ div_id = "item_list"
+ html.checkbox("explicit_services", checked,
onclick="valuespec_toggle_option(this, %r)" % div_id,
+ label = _("Specify explicit values"))
html.write('<div id="%s" style="display: %s; padding:
0px;">' % (
div_id, not checked and "none" or ""))
itemenum = rulespec["itemenum"]
@@ -9925,25 +9891,11 @@ def mode_edit_rule(phase):
itemspec = ListChoice(choices = itemenum, columns = 3)
itemspec.render_input("item", value)
else:
- html.write("<table class=itemlist>")
- num_cols = 3
- for nr in range(config.wato_num_itemspecs):
- x = nr % num_cols
- if x == 0:
- html.write("<tr>")
- html.write("<td>")
- item = nr < len(item_list) and item_list[nr] or ""
- html.text_input("item_%d" % nr, item)
- html.write("</td>")
- if x == num_cols - 1:
- html.write("</tr>")
- while x < num_cols - 1:
- html.write("<td></td>")
- if x == num_cols - 1:
- html.write("</tr>")
- x += 1
- html.write("</table>")
- html.write(_("The entries here are regular expressions to match the
beginning. "
+ ListOfStrings(
+ orientation = "horizontal",
+ valuespec = TextAscii(size = 30)).render_input("itemlist",
item_list)
+
+ html.help(_("The entries here are regular expressions to match the
beginning. "
"Add a <tt>$</tt> for an exact match. An
arbitrary substring is matched "
"with <tt>.*</tt>"))
html.write("</div>")