Module: check_mk
Branch: master
Commit: d63fca1f8a5552a61fa0c5463c9eb92b7f5467d7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d63fca1f8a5552…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Nov 27 09:27:07 2017 +0100
5542 Table quick search: Is now using regex matching instead of substring search
The quick search feature of tables is now treating the given search term as regular
expression. A case insensitive infix search is being performed with the given string.
Change-Id: Ibc903e3d71f45670233ac80c2bcb930042d1554d
---
.werks/5542 | 11 +++++++++++
web/htdocs/table.py | 8 +++++---
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/.werks/5542 b/.werks/5542
new file mode 100644
index 0000000..e9685af
--- /dev/null
+++ b/.werks/5542
@@ -0,0 +1,11 @@
+Title: Table quick search: Is now using regex matching instead of substring search
+Level: 1
+Component: wato
+Compatible: compat
+Edition: cre
+Version: 1.5.0i2
+Date: 1511771143
+Class: feature
+
+The quick search feature of tables is now treating the given search term as regular
+expression. A case insensitive infix search is being performed with the given string.
diff --git a/web/htdocs/table.py b/web/htdocs/table.py
index 8e72274..c4139a0 100644
--- a/web/htdocs/table.py
+++ b/web/htdocs/table.py
@@ -24,9 +24,9 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-# external imports
+import re
from contextlib import contextmanager
-# internal imports
+
import config
from lib import num_split
@@ -483,13 +483,15 @@ class Table(object):
def _filter_rows(rows, search_term):
filtered_rows = []
+ match_regex = re.compile(search_term, re.IGNORECASE)
+
for row, css, state, fixed, attrs in rows:
if state == "header" or fixed:
filtered_rows.append((row, css, state, fixed, attrs))
continue # skip filtering of headers or fixed rows
for cell_content, css_classes, colspan in row:
- if search_term in cell_content.lower():
+ if match_regex.search(cell_content):
filtered_rows.append((row, css, state, fixed, attrs))
break # skip other cells when matched
return filtered_rows