Module: check_mk
Branch: master
Commit: a5010632542c555290841a7715c9fd38086d68ce
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a5010632542c55…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Sun Mar 3 19:50:58 2019 +0100
Removed datasource argument from ViewRenderer.render()
Change-Id: I84019043a88adb0f2eea091c6cd0fdc30a65f123
---
cmk/gui/mobile.py | 10 +++++-----
cmk/gui/views.py | 35 ++++++++++++++++++-----------------
2 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/cmk/gui/mobile.py b/cmk/gui/mobile.py
index 6dd48b1..6ee9323 100644
--- a/cmk/gui/mobile.py
+++ b/cmk/gui/mobile.py
@@ -301,8 +301,8 @@ def page_view():
class MobileViewRenderer(views.ViewRenderer):
- def render(self, rows, datasource, group_cells, cells, show_heading, show_buttons,
- show_checkboxes, layout, num_columns, show_filters, show_footer,
browser_reload):
+ def render(self, rows, group_cells, cells, show_heading, show_buttons,
show_checkboxes, layout,
+ num_columns, show_filters, show_footer, browser_reload):
view_spec = self.view.spec
home = ("mobile.py", "Home", "home")
@@ -338,13 +338,13 @@ class MobileViewRenderer(views.ViewRenderer):
show_commands = True
if html.request.has_var("_do_actions"):
try:
- show_commands = do_commands(view_spec,
datasource["infos"][0], rows)
+ show_commands = do_commands(view_spec,
self.view.datasource.infos[0], rows)
except MKUserError as e:
html.show_error(e)
html.add_user_error(e.varname, e)
show_commands = True
if show_commands:
- show_command_form(view_spec, datasource, rows)
+ show_command_form(view_spec, self.view.datasource, rows)
jqm_page_navfooter(navbar, 'commands', page_id)
elif page == "data":
@@ -401,7 +401,7 @@ def show_filter_form(show_filters):
def show_command_form(view, datasource, rows):
- what = datasource["infos"][0]
+ what = datasource.infos[0]
html.javascript("""
$(document).ready(function() {
$('.command_group').has('x').trigger('expand');
diff --git a/cmk/gui/views.py b/cmk/gui/views.py
index 114d8d3..d66274f 100644
--- a/cmk/gui/views.py
+++ b/cmk/gui/views.py
@@ -235,14 +235,14 @@ class ViewRenderer(object):
self.view = view
@abc.abstractmethod
- def render(self, rows, datasource, group_cells, cells, show_heading, show_buttons,
- show_checkboxes, layout, num_columns, show_filters, show_footer,
browser_reload):
+ def render(self, rows, group_cells, cells, show_heading, show_buttons,
show_checkboxes, layout,
+ num_columns, show_filters, show_footer, browser_reload):
raise NotImplementedError()
class GUIViewRenderer(ViewRenderer):
- def render(self, rows, datasource, group_cells, cells, show_heading, show_buttons,
- show_checkboxes, layout, num_columns, show_filters, show_footer,
browser_reload):
+ def render(self, rows, group_cells, cells, show_heading, show_buttons,
show_checkboxes, layout,
+ num_columns, show_filters, show_footer, browser_reload):
view_spec = self.view.spec
if html.transaction_valid() and html.do_actions():
@@ -263,16 +263,16 @@ class GUIViewRenderer(ViewRenderer):
# This is a general flag which makes the command form render when the current
# view might be able to handle commands. When no commands are possible due
missing
# permissions or datasources without commands, the form is not rendered
- command_form = should_show_command_form(datasource)
+ command_form = should_show_command_form(self.view.datasource)
if command_form:
weblib.init_selection()
if show_buttons:
show_combined_graphs_button = \
- ("host" in datasource.infos or "service" in
datasource.infos) and \
- (isinstance(datasource.table, str)) and \
- ("host" in datasource.table or "service" in
datasource.table)
+ ("host" in self.view.datasource.infos or "service" in
self.view.datasource.infos) and \
+ (isinstance(self.view.datasource.table, str)) and \
+ ("host" in self.view.datasource.table or "service" in
self.view.datasource.table)
_show_context_links(
view_spec,
show_filters,
@@ -282,7 +282,8 @@ class GUIViewRenderer(ViewRenderer):
layout.can_display_checkboxes and not
view_spec.get("force_checkboxes"),
show_checkboxes,
# Show link to availability
- datasource.table in ["hosts", "services"] or
"aggr" in datasource.infos,
+ self.view.datasource.table in ["hosts", "services"]
or
+ "aggr" in self.view.datasource.infos,
# Show link to combined graphs
show_combined_graphs_button,
)
@@ -311,16 +312,17 @@ class GUIViewRenderer(ViewRenderer):
try:
# Create URI with all actions variables removed
backurl = html.makeuri([], delvars=['filled_in',
'actions'])
- has_done_actions = do_actions(view_spec, datasource.infos[0], rows,
backurl)
+ has_done_actions = do_actions(view_spec,
self.view.datasource.infos[0], rows,
+ backurl)
except MKUserError as e:
html.show_error(e)
html.add_user_error(e.varname, e)
if display_options.enabled(display_options.C):
- show_command_form(True, datasource)
+ show_command_form(True, self.view.datasource)
elif display_options.enabled(
display_options.C): # (*not* display open, if checkboxes are
currently shown)
- show_command_form(False, datasource)
+ show_command_form(False, self.view.datasource)
# Also execute commands in cases without command form (needed for Python-
# web service e.g. for NagStaMon)
@@ -333,7 +335,7 @@ class GUIViewRenderer(ViewRenderer):
rows = filter_by_row_id(view_spec, rows)
try:
- do_actions(view_spec, datasource.infos[0], rows, '')
+ do_actions(view_spec, self.view.datasource.infos[0], rows, '')
except:
pass # currently no feed back on webservice
@@ -364,7 +366,7 @@ class GUIViewRenderer(ViewRenderer):
update_context_links(
# don't take display_options into account here ('c'
is set during reload)
row_count > 0 and
- should_show_command_form(datasource,
ignore_display_option=True),
+ should_show_command_form(self.view.datasource,
ignore_display_option=True),
# and not html.do_actions(),
layout.can_display_checkboxes)
@@ -1355,9 +1357,8 @@ def show_view(view,
# Until now no single byte of HTML code has been output.
# Now let's render the view
- view_renderer.render(rows, view.datasource, group_cells, cells, show_heading,
show_buttons,
- show_checkboxes, layout, num_columns, show_filters,
show_footer,
- browser_reload)
+ view_renderer.render(rows, group_cells, cells, show_heading, show_buttons,
show_checkboxes,
+ layout, num_columns, show_filters, show_footer, browser_reload)
SorterEntry = namedtuple("SorterEntry", ["sorter",
"negate", "join_key"])