Module: check_mk
Branch: master
Commit: 846a8b8b4f2f9c0ac59492a8ba59ab6bff204dd4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=846a8b8b4f2f9c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Sep 9 09:26:01 2011 +0200
FIX: "bulk move to" at the top of wato hostlists works again
---
ChangeLog | 3 +++
web/htdocs/htmllib.py | 8 ++++++--
web/htdocs/js/wato.js | 8 ++++++++
web/htdocs/wato.py | 19 +++++++++++++------
4 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4192dfb..97eda78 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,9 @@
* Added display_option "w" to disable limit messages and livestatus errors
in views
* Service Perfdata Sorters are sorting correctly now
+ WATO:
+ * FIX: "bulk move to" at the top of wato hostlists works again
+
1.1.11i4:
Core, Setup, etc.:
* FIX: use hostgroups instead of host_groups in Nagios configuration.
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 70601a0..db65988 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -362,10 +362,14 @@ class html:
sorted.sort(lambda a,b: cmp(a[1].lower(), b[1].lower()))
html.select(self, varname, sorted, deflt, onchange)
- def select(self, varname, options, deflt="", onchange=None):
+ def select(self, varname, options, deflt="", onchange=None, attrs = {}):
current = self.var(varname, deflt)
onchange_code = onchange and " onchange=\"%s\"" % (onchange)
or ""
- self.write("<select%s name=\"%s\" id=\"%s\"
size=\"1\">\n" % (onchange_code, varname, varname))
+
+ attributes = ' ' + ' '.join([ '%s="%s"' % (k,
v) for k, v in attrs.iteritems() ])
+
+ self.write("<select%s name=\"%s\" id=\"%s\"
size=\"1\"%s>\n" %
+ (onchange_code, varname, varname, attributes))
for value, text in options:
if value == None: value = ""
sel = value == current and " selected" or ""
diff --git a/web/htdocs/js/wato.js b/web/htdocs/js/wato.js
index 68e7e40..649c50c 100644
--- a/web/htdocs/js/wato.js
+++ b/web/htdocs/js/wato.js
@@ -290,3 +290,11 @@ function progress_scheduler(mode, url_prefix, timeout, items,
end_url, success_s
setTimeout(function() { progress_scheduler(mode, url_prefix, timeout, [],
"", ""); }, timeout);
}
+function update_bulk_moveto(val) {
+ var fields = getElementsByClass('bulk_moveto');
+ for(var i = 0; i < fields.length; i++)
+ for(var a = 0; a < fields[i].options.length; a++)
+ if(fields[i].options[a].value == val)
+ fields[i].options[a].selected = true;
+ fields = null;
+}
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 9815934..f14a742 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -640,7 +640,7 @@ def mode_file(phase):
html.write("</tr>\n")
odd = "odd"
- def bulk_actions(at_least_one_imported):
+ def bulk_actions(at_least_one_imported, top = False):
# bulk actions
html.write('<tr class="data %s0">' % odd)
html.write("<td colspan=%d>" % colspan)
@@ -650,7 +650,7 @@ def mode_file(phase):
html.button("_bulk_edit", _("Edit"))
html.button("_bulk_cleanup", _("Cleanup"))
html.button("_bulk_inventory", _("Inventory"))
- host_move_combo(None)
+ host_move_combo(None, top)
if at_least_one_imported:
html.button("_bulk_movetotarget", _("Move to Target
Folders"))
html.write("</td></tr>\n")
@@ -678,7 +678,7 @@ def mode_file(phase):
# Add the bulk action buttons also to the top of the table when this
# list shows more than 10 rows
if more_than_ten_items:
- bulk_actions(at_least_one_imported)
+ bulk_actions(at_least_one_imported, top = True)
for hostname in hostnames:
if search_text and (search_text.lower() not in hostname.lower()):
@@ -2527,7 +2527,7 @@ def wato_html_head(title):
html.header(title)
html.write("<div class=wato>\n")
-def host_move_combo(host = None):
+def host_move_combo(host = None, top = False):
other_files = []
for path, afile in g_files.items():
if config.role in afile["roles"] and afile != g_file:
@@ -2535,10 +2535,17 @@ def host_move_combo(host = None):
other_files.append((os_path, "%s (%s)" % (afile["title"],
os_path)))
if len(other_files) > 0:
- selections = [("", _("(select file)"))] + other_files
+ selections = [("", _("(select file)"))] + other_files
if host == None:
html.button("_bulk_move", _("Move To:"))
- html.select("bulk_moveto", selections, "")
+ field_name = 'bulk_moveto'
+ if top:
+ field_name = '_top_bulk_moveto'
+ if html.has_var('bulk_moveto'):
+ html.javascript('update_bulk_moveto("%s")' %
html.var('bulk_moveto', ''))
+ html.select(field_name, selections, "",
+ onchange = "update_bulk_moveto(this.value)",
+ attrs = {'class': 'bulk_moveto'})
else:
html.hidden_field("host", host)
uri = html.makeuri([("host", host), ("_transid",
html.current_transid() )])