Module: check_mk
Branch: master
Commit: cfdc778e1dff21c6d186b657dcb635d6fa809ed3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cfdc778e1dff21…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Sep 5 09:15:03 2017 +0200
5179 FIX Views: Fixed sorting of commands in different languages
Change-Id: If195162280a8c4c4e9272677e72bedc582838376
---
.werks/5179 | 10 ++++++++++
web/htdocs/views.py | 20 ++++++++++++++------
web/plugins/views/commands.py | 37 +++++++++++++++++++++++++++++++------
3 files changed, 55 insertions(+), 12 deletions(-)
diff --git a/.werks/5179 b/.werks/5179
new file mode 100644
index 0000000..4534c50
--- /dev/null
+++ b/.werks/5179
@@ -0,0 +1,10 @@
+Title: Views: Fixed sorting of commands in different languages
+Level: 1
+Component: multisite
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1504595683
+Class: fix
+
+
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index ab7822f..ffae17c 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -55,6 +55,7 @@ def load_plugins(force):
global multisite_builtin_views ; multisite_builtin_views = {}
global multisite_painter_options ; multisite_painter_options = {}
global multisite_commands ; multisite_commands = []
+ global multisite_command_groups ; multisite_command_groups = {}
global view_hooks ; view_hooks = {}
global inventory_displayhints ; inventory_displayhints = {}
@@ -2544,14 +2545,13 @@ def show_command_form(is_open, datasource):
# It is currently only used in custom views, not shipped with check_mk.
if command.get('only_view') and html.var('view_name') !=
command['only_view']:
continue
- group = command.get("group", _("Various Commands"))
+ group = command.get("group", "various")
by_group.setdefault(group, []).append(command)
- groups = by_group.keys()
- groups.sort()
- for group in groups:
- forms.header(group, narrow=True)
- for command in by_group[group]:
+ for group_ident, group_commands in sorted(by_group.items(),
+ key=lambda x:
multisite_command_groups[x[0]]["sort_index"]):
+ forms.header(multisite_command_groups[group_ident]["title"],
narrow=True)
+ for command in group_commands:
forms.section(command["title"])
command["render"]()
@@ -2739,6 +2739,14 @@ def get_view_by_name(view_name):
# | |
# '----------------------------------------------------------------------'
+
+def register_command_group(ident, title, sort_index):
+ multisite_command_groups[ident] = {
+ "title" : title,
+ "sort_index" : sort_index,
+ }
+
+
def register_hook(hook, func):
if not hook in view_hooks:
view_hooks[hook] = []
diff --git a/web/plugins/views/commands.py b/web/plugins/views/commands.py
index 2b19944..c8ed595 100644
--- a/web/plugins/views/commands.py
+++ b/web/plugins/views/commands.py
@@ -36,6 +36,11 @@
# - function that outputs the HTML input fields
# - function that creates the nagios command and title
+register_command_group(
+ ident = "various",
+ title = _("Various Commands"),
+ sort_index = 20,
+)
# .--Reschedule----------------------------------------------------------.
# | ____ _ _ _ |
@@ -303,11 +308,18 @@ def render_fake_form(what):
html.close_table()
+
+register_command_group(
+ ident = "fake_check",
+ title = _("Fake check results"),
+ sort_index = 15,
+)
+
multisite_commands.append({
"tables" : [ "host" ],
"permission" : "action.fakechecks",
"title" : _("Fake check results"),
- "group" : _("Fake check results"),
+ "group" : "fake_check",
"render" : lambda: render_fake_form("host"),
"action" : command_fake_checks,
})
@@ -316,7 +328,7 @@ multisite_commands.append({
"tables" : [ "service" ],
"permission" : "action.fakechecks",
"title" : _("Fake check results"),
- "group" : _("Fake check results"),
+ "group" : "fake_check",
"render" : lambda: render_fake_form("service"),
"action" : command_fake_checks,
})
@@ -442,6 +454,13 @@ def command_acknowledgement(cmdtag, spec, row):
return commands, title
+register_command_group(
+ ident = "acknowledge",
+ title = _("Acknowledge"),
+ sort_index = 5,
+)
+
+
multisite_commands.append({
"tables" : [ "host", "service", "aggr"
],
"permission" : "action.acknowledge",
@@ -463,7 +482,7 @@ multisite_commands.append({
html.write_text(_("Comment") + ": ") == \
html.text_input("_ack_comment", size=48,
submit="_acknowledge"),
"action" : command_acknowledgement,
- "group" : _("Acknowledge"),
+ "group" : "acknowledge",
})
@@ -764,13 +783,19 @@ def has_recurring_downtimes():
return False
+register_command_group(
+ ident = "downtimes",
+ title = _("Downtimes"),
+ sort_index = 10,
+)
+
multisite_commands.append({
"tables" : [ "host" ],
"permission" : "action.downtimes",
"title" : _("Schedule downtimes"),
"render" : lambda: paint_downtime_buttons("host"),
"action" : command_downtime,
- "group" : _("Downtimes"),
+ "group" : "downtimes",
})
multisite_commands.append({
@@ -779,7 +804,7 @@ multisite_commands.append({
"title" : _("Schedule downtimes"),
"render" : lambda: paint_downtime_buttons("service"),
"action" : command_downtime,
- "group" : _("Downtimes"),
+ "group" : "downtimes",
})
multisite_commands.append({
@@ -788,7 +813,7 @@ multisite_commands.append({
"title" : _("Schedule downtimes"),
"render" : lambda: paint_downtime_buttons("aggr"),
"action" : command_downtime,
- "group" : _("Downtimes"),
+ "group" : "downtimes",
})
# REMOVE DOWNTIMES (table downtimes)