Module: check_mk
Branch: master
Commit: 506e6d7edc1b128245b9f25f558f3868b511eb85
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=506e6d7edc1b12…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Dec 1 15:37:32 2011 +0100
Mobile: intermediate state
---
web/htdocs/htmllib.py | 2 +-
web/htdocs/mobile.py | 13 +++++++--
web/htdocs/views.py | 26 +++++++++++--------
web/plugins/views/commands.py | 54 +++++++++++++++++++++++++++++++++++++++++
web/plugins/views/mobile.py | 12 ++++----
5 files changed, 86 insertions(+), 21 deletions(-)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 38eb078..bba0f26 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -235,7 +235,7 @@ class html:
onsubmit = ' onsubmit="%s"' % onsubmit
else:
onsubmit = ''
- self.write("<form name=%s class=%s action=\"%s\"
method=%s%s%s>\n" %
+ self.write('<form name=%s class=%s action="%s"
method="%s"%s%s>\n' %
(name, name, action, method, enctype, onsubmit))
self.hidden_field("filled_in", name)
if add_transid:
diff --git a/web/htdocs/mobile.py b/web/htdocs/mobile.py
index a54872b..02210fd 100644
--- a/web/htdocs/mobile.py
+++ b/web/htdocs/mobile.py
@@ -221,7 +221,7 @@ def render_view(view, rows, datasource, group_painters, painters,
if context_links:
jqm_page_header(_("Context"), left_button=home,
id="context")
show_context_links(context_links)
- jqm_page_navfooter(navbar, '#filter', page_id)
+ jqm_page_navfooter(navbar, '#context', page_id)
def show_filter_form(show_filters):
@@ -239,10 +239,17 @@ def show_filter_form(show_filters):
f.display()
html.write('</div></fieldset></li>\n')
html.write("</ul>\n")
- html.button("search", _("Search"))
-
html.hidden_fields()
html.end_form()
+ # Make the tab 'Results' not simply switch to the results page
+ # but submit the form and fetch new data. This is done by overriding
+ # that buttons click function to submit the form. Note: We need to
+ # remove the ancor in href. Otherwise jQuery will do some magic
+ # itself and first switch to that page...
+ html.javascript(
+ "$('div#filter a[href=\"#data\"]')"
+ ".attr('href', '').live('click', function(e) "
+ "{ e.preventDefault(); $('div#filter
form[name=\"filter\"]').submit();});")
def show_context_links(context_links):
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 740e9a8..e5861f0 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -48,6 +48,7 @@ multisite_painters = {}
multisite_sorters = {}
multisite_builtin_views = {}
multisite_painter_options = {}
+multisite_commands = []
ubiquitary_filters = [] # Always show this filters
view_hooks = {}
@@ -58,11 +59,7 @@ def load_plugins():
return
loaded_with_language = current_language
- config.declare_permission_section("action", _("Commands on
Objects"))
- config.declare_permission("action.notifications",
- _("Enable/disable notifications"),
- _("Enable and disable notifications on hosts and services"),
- [ "admin" ])
+ config.declare_permission_section("action", _("Commands on host and
services"))
config.declare_permission("action.enablechecks",
_("Enable/disable checks"),
_("Enable and disable active or passive checks on hosts and
services"),
@@ -1969,6 +1966,13 @@ def show_action_form(is_open, datasource):
html.write("<div class=whiteborder>\n")
html.write("<table class=\"form\">\n")
+ for command in multisite_commands:
+ if what in command["tables"] and
config.may(command["permission"]):
+ html.write('<tr><td class=legend>%s</td>\n' %
command["title"])
+ html.write('<td class=content>\n')
+ command["render"]()
+ html.write('</td></tr>\n')
+
if what in [ "host", "service" ]:
show_host_service_actions(what)
elif what == "downtime":
@@ -1998,12 +2002,12 @@ def show_comment_actions():
def show_host_service_actions(what):
- if config.may("action.notifications"):
- html.write("<tr><td
class=legend>"+_('Notifications')+"</td>\n"
- "<td class=content>\n"
- "<input type=submit name=_enable_notifications
value=\""+_('Enable')+"\"> "
- "<input type=submit name=_disable_notifications
value=\""+_('Disable')+"\">"
- "</td></tr>\n")
+ # if config.may("action.notifications"):
+ # html.write("<tr><td
class=legend>"+_('Notifications')+"</td>\n"
+ # "<td class=content>\n"
+ # "<input type=submit name=_enable_notifications
value=\""+_('Enable')+"\"> "
+ # "<input type=submit name=_disable_notifications
value=\""+_('Disable')+"\">"
+ # "</td></tr>\n")
if config.may("action.enablechecks") or
config.may("action.reschedule"):
html.write("<tr><td class=legend>"+_('Active
checks')+"</td>\n"
diff --git a/web/plugins/views/commands.py b/web/plugins/views/commands.py
new file mode 100644
index 0000000..44cdd5a
--- /dev/null
+++ b/web/plugins/views/commands.py
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2010 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+
+# Declarations of commands on monitoring objects. This file is
+# read in with execfile by views.py.
+#
+# Each command has the following aspects:
+#
+# - permission
+# - title
+# - table ("hostservices", "downtime", "comment")
+# - function that outputs the HTML input fields
+# - function that creates the nagios command and title
+
+# config.declare_permission("action.notifications",
+# _("Enable/disable notifications"),
+# _("Enable and disable notifications on hosts and services"),
+# [ "admin" ])
+#
+# multisite_commands.append({
+# "tables" : [ "host", "service" ],
+# "permission" : "action.notifications",
+# "title" : _("Notifications"),
+# "render" : lambda: \
+# html.button("_enable_notifications", _("Enable")) == \
+# html.button("_disable_notifications", _("Disable")),
+# "action" : lambda cmdtag, spec: \
+# "ENABLE_" + cmdtag + "_NOTIFICATIONS;%s" % spec,
+# _("<b>enable notifications</b> for")
+# })
diff --git a/web/plugins/views/mobile.py b/web/plugins/views/mobile.py
index 96383b2..67d108f 100644
--- a/web/plugins/views/mobile.py
+++ b/web/plugins/views/mobile.py
@@ -308,13 +308,13 @@ multisite_builtin_views.update({
('num_services_pending', None),
],
'show_filters': [
- 'host_scheduled_downtime_depth',
- 'host_in_notification_period',
- 'hoststate',
+ # 'host_scheduled_downtime_depth',
+ # 'host_in_notification_period',
+ # 'hoststate',
'hostregex',
- 'host_notifications_enabled',
- 'opthostgroup',
- 'opthost_contactgroup',
+ # 'host_notifications_enabled',
+ # 'opthostgroup',
+ # 'opthost_contactgroup',
],
'sorters': [],
'title': _('Host search'),