Module: check_mk
Branch: master
Commit: 5504aa64d1c457ff6875db6c56139e0765d8c19a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5504aa64d1c457…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jan 13 09:08:57 2012 +0100
Made "wato folder" columns sortable
---
ChangeLog | 1 +
web/plugins/views/wato.py | 42 +++++++++++++++++++++++++++++++++---------
2 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 44bd823..e05673f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -37,6 +37,7 @@
* Added filter for log state (UP,DOWN,OK,CRIT...) to all log views
* New painter for normal and retry check interval (added to detail views)
* Site filter shows "(local)" in case of non multi-site setup
+ * Made "wato folder" columns sortable
* FIX: Fixed auth problem when following logwatch icon links while using
the form based auth
diff --git a/web/plugins/views/wato.py b/web/plugins/views/wato.py
index 2ff0116..9993b9e 100644
--- a/web/plugins/views/wato.py
+++ b/web/plugins/views/wato.py
@@ -103,48 +103,72 @@ multisite_painters["host_filename"] = {
"paint" : lambda row: ("tt", row["host_filename"]),
}
-def paint_wato_folder(row, how):
+def get_wato_folder(row, how, with_links = True):
filename = row["host_filename"]
if not filename.startswith("/wato/") or not
filename.endswith("/hosts.mk"):
- return "", ""
+ return ""
wato_path = filename[6:-9]
- title_path = wato.api.get_folder_title_path(wato_path, True)
+ title_path = wato.api.get_folder_title_path(wato_path, with_links)
if how == "plain":
return "", title_path[-1]
elif how == "abs":
- return "", " / ".join(title_path)
+ return " / ".join(title_path)
else:
# We assume that only hosts are show, that are below the
# current WATO path. If not then better output absolute
# path then wrong path.
current_path = html.var("wato_folder")
if not current_path or not wato_path.startswith(current_path):
- return "", " / ".join(title_path)
+ return " / ".join(title_path)
depth = current_path.count('/') + 1
- return "", " / ".join(title_path[depth:])
+ return " / ".join(title_path[depth:])
+def paint_wato_folder(row, how):
+ return "", get_wato_folder(row, how)
multisite_painters["wato_folder_abs"] = {
"title" : _("WATO folder - complete path"),
"short" : _("WATO folder"),
"columns" : ["host_filename"],
- "paint" : lambda row: paint_wato_folder(row, "abs")
+ "paint" : lambda row: paint_wato_folder(row, "abs"),
+ "sorter" : 'wato_folder_abs',
}
multisite_painters["wato_folder_rel"] = {
"title" : _("WATO folder - relative path"),
"short" : _("WATO folder"),
"columns" : ["host_filename"],
- "paint" : lambda row: paint_wato_folder(row, "rel")
+ "paint" : lambda row: paint_wato_folder(row, "rel"),
+ "sorter" : 'wato_folder_rel',
}
multisite_painters["wato_folder_plain"] = {
"title" : _("WATO folder - just folder name"),
"short" : _("WATO folder"),
"columns" : ["host_filename"],
- "paint" : lambda row: paint_wato_folder(row, "plain")
+ "paint" : lambda row: paint_wato_folder(row, "plain"),
+ "sorter" : 'wato_folder_plain',
+}
+
+def cmp_wato_folder(r1, r2, how):
+ return cmp(get_wato_folder(r1, how, False), get_wato_folder(r2, how, False))
+
+multisite_sorters["wato_folder_abs"] = {
+ "title" : _("WATO folder - complete path"),
+ "columns" : [ "host_filename" ],
+ "cmp" : lambda r1, r2: cmp_wato_folder(r1, r2, 'abs'),
}
+multisite_sorters["wato_folder_rel"] = {
+ "title" : _("WATO folder - relative path"),
+ "columns" : [ "host_filename" ],
+ "cmp" : lambda r1, r2: cmp_wato_folder(r1, r2, 'rel'),
+}
+multisite_sorters["wato_folder_plain"] = {
+ "title" : _("WATO folder - just folder name"),
+ "columns" : [ "host_filename" ],
+ "cmp" : lambda r1, r2: cmp_wato_folder(r1, r2, 'plain'),
+}