Module: check_mk
Branch: master
Commit: dfc928abb2de3af153964d756157be8646c9c2f3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dfc928abb2de3a…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed May 9 10:24:55 2018 +0200
5808 FIX Quicksearch: Searching for groups did not always return full results
Choosing a specific value from the dropdown menu in the quicksearch snapin, also applied
a site filter for the chosen group. The group results were hereby incorrectly restricted
to a specific site.
Change-Id: Ie07f0429e70f190c14989a581b1ffa681e1df84b
---
.werks/5808 | 12 ++++++++++++
web/htdocs/sidebar.py | 11 +++++++++--
web/plugins/sidebar/search.py | 12 +++++++++++-
3 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/.werks/5808 b/.werks/5808
new file mode 100644
index 0000000..6f2f89d
--- /dev/null
+++ b/.werks/5808
@@ -0,0 +1,12 @@
+Title: Quicksearch: Searching for groups did not always return full results
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1525853954
+
+Choosing a specific value from the dropdown menu in the quicksearch snapin, also applied
+a site filter for the chosen group. The group results were hereby incorrectly restricted
to a specific site.
diff --git a/web/htdocs/sidebar.py b/web/htdocs/sidebar.py
index 0e5b85d..c72306e 100644
--- a/web/htdocs/sidebar.py
+++ b/web/htdocs/sidebar.py
@@ -890,9 +890,13 @@ class LivestatusSearchConductor(LivestatusSearchBase):
for row in self._rows:
entry = {"text_tokens": []}
url_params = []
+ skip_site = False
for filter_shortname in self._used_filters:
plugin = self._get_plugin_with_shortname(filter_shortname)
+ if plugin.is_group_match():
+ skip_site = True
+
match_info = plugin.get_matches(target_view, row, self._livestatus_table,
self._used_filters)
if not match_info:
continue
@@ -900,8 +904,11 @@ class LivestatusSearchConductor(LivestatusSearchBase):
url_params.extend(url_filters)
entry["text_tokens"].append((plugin.get_filter_shortname(),
text))
- entry["url"] = self._build_url([("view_name",
target_view),
- ("site",
row.get("site"))] + url_params, restore_regex = True)
+ url_tokens = [("view_name", target_view)] + url_params
+ if not skip_site:
+ url_tokens.append(("site", row.get("site")))
+ entry["url"] = self._build_url(url_tokens, restore_regex = True)
+
entry["raw_data"] = row
self._elements.append(entry)
diff --git a/web/plugins/sidebar/search.py b/web/plugins/sidebar/search.py
index 3e2dcb71..0f29935 100644
--- a/web/plugins/sidebar/search.py
+++ b/web/plugins/sidebar/search.py
@@ -191,6 +191,10 @@ class QuicksearchMatchPlugin(object):
raise NotImplementedError()
+ def is_group_match(self):
+ return False
+
+
def _matches_regex(self, pattern, value):
return re.match(pattern, value)
@@ -212,6 +216,10 @@ class GroupMatchPlugin(QuicksearchMatchPlugin):
self._group_type = group_type
+ def is_group_match(self):
+ return True
+
+
def get_match_topic(self):
if self._group_type == "host":
return _("Hostgroup")
@@ -400,7 +408,9 @@ class HosttagMatchPlugin(QuicksearchMatchPlugin):
def _get_hosttag_dict(self):
lookup_dict = {}
- for group, text, values in config.host_tag_groups():
+ for entry in config.host_tag_groups():
+ group, text, values = entry[:3]
+
for value in values:
lookup_dict[value[0]] = group
return lookup_dict