Module: check_mk
Branch: master
Commit: 780791473a71c6c01b4f4b6ff5df8f2b414db6a6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=780791473a71c6…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Jul 17 16:48:16 2017 +0200
4977 Improved displaying a great amount of contact groups in folder/host properties
Change-Id: Ib2d1fe129954d9ff5894e35be2d6e3d037e30d3e
---
.werks/4977 | 14 ++++++++++++++
web/htdocs/watolib.py | 21 +++++++++++++--------
2 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/.werks/4977 b/.werks/4977
new file mode 100644
index 0000000..66af248
--- /dev/null
+++ b/.werks/4977
@@ -0,0 +1,14 @@
+Title: Improved displaying a large number of contact groups in folder/host properties
+Level: 1
+Component: multisite
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1500302729
+Class: feature
+
+If a large number of contact groups are configured
+these were displayed as a long list of checkboxes
+exceeding screensize.
+Now the available and selected contact groups are
+shown as parallel lists with fixed size and scrolling bar.
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index 49150b5..b30bec0 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -3117,9 +3117,9 @@ class ContactGroupsAttribute(Attribute):
self._users = None
self._loaded_at = None
+
def paint(self, value, hostname):
value = convert_cgroups_from_tuple(value)
-
texts = []
self.load_data()
items = self._contactgroups.items()
@@ -3134,6 +3134,7 @@ class ContactGroupsAttribute(Attribute):
title=_("These contact groups are also used in the monitoring
configuration."))
return "", result
+
def render_input(self, varprefix, value):
value = convert_cgroups_from_tuple(value)
@@ -3146,12 +3147,8 @@ class ContactGroupsAttribute(Attribute):
# Only show contact groups I'm currently in and contact
# groups already listed here.
self.load_data()
- items = self._contactgroups.items()
- items.sort(cmp = lambda a,b: cmp(a[1], b[1]))
- for name, group in items:
- html.checkbox(varprefix + self._name + "_n_" + name, name in
value["groups"])
- html.a(group['alias'] if group['alias'] else name ,
href=folder_preserving_link([("mode", "edit_contact_group"),
("edit", name)]))
- html.br()
+ self._vs_contactgroups().render_input(varprefix + self._name + "_n_",
value['groups'])
+
html.hr()
if is_host:
@@ -3183,9 +3180,9 @@ class ContactGroupsAttribute(Attribute):
if self._loaded_at == id(html):
return
self._loaded_at = id(html)
-
self._contactgroups = userdb.load_group_information().get("contact",
{})
+
def from_html_vars(self, varprefix):
cgs = []
self.load_data()
@@ -3200,6 +3197,7 @@ class ContactGroupsAttribute(Attribute):
"recurse_use" : html.get_checkbox(varprefix + self._name +
"_recurse_use"),
}
+
def filter_matches(self, crit, value, hostname):
value = convert_cgroups_from_tuple(value)
# Just use the contact groups for searching
@@ -3209,6 +3207,13 @@ class ContactGroupsAttribute(Attribute):
return True
+ def _vs_contactgroups(self):
+ cg_choices = sorted([(cg_id, cg_attrs.get("alias", cg_id))
+ for cg_id, cg_attrs in self._contactgroups.items()],
+ key=lambda x: x[1])
+ return DualListChoice(choices=cg_choices, rows=40, size=100)
+
+
def initialize_host_attribute_structures():
global g_host_attributes, g_host_attribute
g_host_attributes = []