Module: check_mk
Branch: master
Commit: 62f41504b208a73c89efeb0add70688c6aa9ab04
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=62f41504b208a7…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Oct 8 16:57:26 2014 +0200
Integrate buttons for PDF export
---
web/htdocs/views.py | 7 +++++++
web/htdocs/visuals.py | 14 ++++++++++++++
web/plugins/views/availability.py | 20 ++++++++++++++------
3 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 573c211..e7deaa4 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -1444,6 +1444,13 @@ def show_context_links(thisview, show_filters, display_options,
html.context_button(_("WATO"), url, "wato",
id="wato",
bestof = config.context_buttons_to_show)
+ try:
+ # FIXME: Berechtigung prüfen
+ config.reporting_available
+ html.context_button(_("Export as PDF"), html.makeuri([],
filename="report_instant.py"), "pdf")
+ except:
+ pass
+
links = visuals.collect_context_links(thisview)
for linktitle, uri, icon, buttonid in links:
html.context_button(linktitle, url=uri, icon=icon, id=buttonid,
bestof=config.context_buttons_to_show)
diff --git a/web/htdocs/visuals.py b/web/htdocs/visuals.py
index ce9f581..9252a2a 100644
--- a/web/htdocs/visuals.py
+++ b/web/htdocs/visuals.py
@@ -911,6 +911,20 @@ def add_context_to_uri_vars(visual, only_infos=None,
only_count=False):
for uri_varname, value in filter_vars.items():
html.set_var(uri_varname, value)
+# Vice versa: find all filters that belong to the current URI variables
+# and create a context dictionary from that.
+def get_context_from_uri_vars(only_infos=None):
+ context = {}
+ for filter_name, filter_object in multisite_filters.items():
+ if only_infos == None or filter_object.info in only_infos:
+ this_filter_vars = {}
+ for varname in filter_object.htmlvars:
+ if html.has_var(varname):
+ this_filter_vars[varname] = html.var(varname)
+ if this_filter_vars:
+ context[filter_name] = this_filter_vars
+ return context
+
# Compute Livestatus-Filters based on a given context. Returns
# the only_sites list and a string with the filter headers
diff --git a/web/plugins/views/availability.py b/web/plugins/views/availability.py
index 2741203..920809c 100644
--- a/web/plugins/views/availability.py
+++ b/web/plugins/views/availability.py
@@ -93,13 +93,8 @@ def render_availability(view, datasource, filterheaders,
display_options,
if handle_edit_annotations():
return
- # We need the availability options now, but cannot display the
- # form code for that yet. Ignore the HTML code.
- html.plug()
- avoptions = render_availability_options()
+ avoptions = get_availability_options_from_url()
range, range_title = avoptions["range"]
- html.drain()
- html.unplug()
timeline = not not html.var("timeline")
if timeline:
@@ -146,6 +141,11 @@ def render_availability(view, datasource, filterheaders,
display_options,
html.begin_context_buttons()
togglebutton("avoptions", html.has_user_errors(),
"painteroptions", _("Configure details of the report"))
html.context_button(_("Status View"), html.makeuri([("mode",
"status")]), "status")
+ try:
+ config.reporting_available
+ html.context_button(_("Export as PDF"), html.makeuri([],
filename="report_instant.py"), "pdf")
+ except:
+ pass
if timeline:
html.context_button(_("Availability"),
html.makeuri([("timeline", "")]), "availability")
history_url = history_url_of(tl_site, tl_host, tl_service, range[0],
range[1])
@@ -506,6 +506,14 @@ avoption_entries = [
)
]
+# Get availability options without rendering the valuespecs
+def get_availability_options_from_url():
+ html.plug()
+ avoptions = render_availability_options()
+ html.drain()
+ html.unplug()
+ return avoptions
+
def render_availability_options():
if html.var("_reset") and html.check_transaction():