Module: check_mk
Branch: master
Commit: 18079c8614fac92574fdc3dbd472789d9c321323
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=18079c8614fac9…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Nov 20 11:12:31 2014 +0100
#1528 FIX Fixed actions in mobile GUI
It was not possible to perform any actions using the mobile GUI. This has been fixed now.
---
.werks/1528 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/htmllib.py | 13 +++++++++----
web/htdocs/mobile.py | 26 +++++++++++++++-----------
4 files changed, 35 insertions(+), 15 deletions(-)
diff --git a/.werks/1528 b/.werks/1528
new file mode 100644
index 0000000..1cd1129
--- /dev/null
+++ b/.werks/1528
@@ -0,0 +1,10 @@
+Title: Fixed actions in mobile GUI
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.5i7
+Date: 1416478312
+
+It was not possible to perform any actions using the mobile GUI. This has been fixed
now.
diff --git a/ChangeLog b/ChangeLog
index 37877bf..1552b86 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -59,6 +59,7 @@
* 1501 FIX: Legacy view formats created with 2014-09 snapshots are now converted...
* 1506 FIX: Fixed randomly hidden dashboard title...
* 1527 FIX: Fixed views missing values of some filters (serviceregex, hostgroup
filters, ...)...
+ * 1528 FIX: Fixed actions in mobile GUI...
* 1529 FIX: Mobile-GUI: Fixed "all host problems" view not showing all
problems...
WATO:
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 75ec7f6..d2f20ad 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -1130,12 +1130,16 @@ class html:
def confirm(self, msg, method="POST", action=None):
if self.var("_do_actions") == _("No"):
- return # user has pressed "No" # None -->
"No"
+ # User has pressed "No", now invalidate the unused transid
+ self.check_transaction()
+ return # None --> "No"
if not self.has_var("_do_confirm"):
if self.mobile:
self.write('<center>')
self.write("<div class=really>%s" % msg)
- self.begin_form("confirm", method=method, action=action)
+ # The confirm dialog is never a dialog which need to be protected
+ # by a transid itselfs. It is only a intermediate step to the real action
+ self.begin_form("confirm", method=method, action=action,
add_transid=False)
self.hidden_fields(add_action_vars = True)
self.button("_do_confirm", _("Yes!"),
"really")
self.button("_do_actions", _("No"), "")
@@ -1143,9 +1147,10 @@ class html:
self.write("</div>")
if self.mobile:
self.write('</center>')
- return False # False --> "Dialog
shown, no answer yet"
+ return False # False --> "Dialog shown, no answer yet"
else:
- return self.check_transaction() and True or None # True: "Yes",
None --> Browser reload
+ # Now check the transaction
+ return self.check_transaction() and True or None # True: "Yes",
None --> Browser reload of "yes" page
def register_event(self, name):
self.events.add(name)
diff --git a/web/htdocs/mobile.py b/web/htdocs/mobile.py
index f9e6812..751d798 100644
--- a/web/htdocs/mobile.py
+++ b/web/htdocs/mobile.py
@@ -71,6 +71,7 @@ def mobile_html_head(title, ready_code=""):
def mobile_html_foot():
html.write("</body></html>\n")
+ html.store_new_transids()
def jqm_header_button(pos, url, title, icon=""):
html.write('<a href="%s" class="ui-btn-%s"
data-direction="reverse" data-icon="%s"
data-iconpos="notext" title="%s" ></a>' % (url, pos,
icon, title ))
@@ -221,11 +222,10 @@ def page_view():
try:
views.show_view(view, show_heading = False, show_buttons = False,
show_footer = False, render_function = render_view)
- pass
except Exception, e:
if config.debug:
raise
- html.write("ERROR showing view: %s" % e)
+ html.write("ERROR showing view: %s" % html.attrencode(e))
mobile_html_foot()
@@ -355,24 +355,28 @@ def show_command_form(view, datasource, rows):
if not one_shown:
html.write(_('No commands are possible in this view'))
+# FIXME: Reduce ducplicate code with views.py
def do_commands(view, what, rows):
command = None
- title, executor = views.core_command(what, rows[0])[1:3] # just get the title
+ title, executor = views.core_command(what, rows[0], 0, len(rows))[1:3] # just get the
title
r = html.confirm(_("Do you really want to %(title)s the %(count)d
%(what)ss?") %
{ "title" : title, "count" : len(rows), "what"
: _(what + "s"), })
if r != True:
return r == None # Show commands on negative answer
count = 0
- for row in rows:
- nagios_commands, title, executor = views.core_command(what, row)
+ already_executed = set([])
+ for nr, row in enumerate(rows):
+ nagios_commands, title, executor = views.core_command(what, row, nr, len(rows))
for command in nagios_commands:
- if type(command) == unicode:
- command = command.encode("utf-8")
- executor(command, row["site"])
- count += 1
-
- if command:
+ if command not in already_executed:
+ if type(command) == unicode:
+ command = command.encode("utf-8")
+ executor(command, row["site"])
+ already_executed.add(command)
+ count += 1
+
+ if count > 0:
html.message(_("Successfully sent %d commands.") % count)
return True # Show commands again