Module: check_mk
Branch: master
Commit: 17b8cd8bdf9301697436842d121af6f2b6dca0e0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=17b8cd8bdf9301…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Dec 4 10:13:58 2014 +0100
#1621 Sorting Check_MK* services always on top of services lists
---
.werks/1621 | 9 +++++++++
ChangeLog | 1 +
web/plugins/views/sorters.py | 19 ++++++++++++++++++-
3 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/.werks/1621 b/.werks/1621
new file mode 100644
index 0000000..35f6d3b
--- /dev/null
+++ b/.werks/1621
@@ -0,0 +1,9 @@
+Title: Sorting Check_MK* services always on top of services lists
+Level: 2
+Component: multisite
+Compatible: compat
+Version: 1.2.5i7
+Date: 1417684329
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index c4b23fa..b6e7d0a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -97,6 +97,7 @@
* 1500 SEC: Preventing livestatus injections in different places...
* 1530 Dashboard: Host/service statistics dashlets now deal with the context...
* 1558 Better visualize manually changed notification enable/disable
+ * 1621 Sorting Check_MK* services always on top of services lists
* 1164 FIX: Fixed links from servicegroup overviews to single servicegroups
* 1166 FIX: Also prevting stylesheet update issues during version updates (just like
for JS files)
* 1481 FIX: Fix broken layout of Host-, Service- and Contactgroup filters
diff --git a/web/plugins/views/sorters.py b/web/plugins/views/sorters.py
index 1c02cdc..1b2f75d 100644
--- a/web/plugins/views/sorters.py
+++ b/web/plugins/views/sorters.py
@@ -129,8 +129,25 @@ multisite_sorters['servicelevel'] = {
'cmp' : lambda r1, r2: cmp_custom_variable(r1, r2, 'EC_SL',
cmp_simple_number)
}
+def cmp_service_name_equiv(r):
+ if r == "Check_MK":
+ return -5
+ elif r == "Check_MK inventory":
+ return -4
+ elif r == "Check_MK HW/SW Inventory":
+ return -3
+ else:
+ return 0
+
+def cmp_service_name(column, r1, r2):
+ o = cmp(cmp_service_name_equiv(r1[column]), cmp_service_name_equiv(r2[column]))
+ if o == 0:
+ return cmp_simple_string(column, r1, r2)
+ else:
+ return o
+
# name title column
sortfunction
-declare_simple_sorter("svcdescr", _("Service
description"), "service_description", cmp_simple_string)
+declare_simple_sorter("svcdescr", _("Service
description"), "service_description", cmp_service_name)
declare_simple_sorter("svcdispname", _("Service alternative
display name"), "service_display_name", cmp_simple_string)
declare_simple_sorter("svcoutput", _("Service plugin
output"), "service_plugin_output", cmp_simple_string)
declare_simple_sorter("svc_long_plugin_output", _("Long output of check
plugin"), "service_long_plugin_output", cmp_simple_string)