def render_availability_page(view, datasource, filterheaders, display_options, only_sites, limit): if handle_edit_annotations(): return # We make reports about hosts, services or BI aggregates if "service" in datasource["infos"]: what = "service" elif "aggr_name" in datasource["infos"]: what = "bi" else: what = "host" avoptions = get_availability_options_from_url(what) time_range, range_title = avoptions["range"] # We have two display modes: # - Show availability table (stats) "table" # - Show timeline "timeline" # --> controlled by URL variable "av_mode" av_mode = html.var("av_mode", "table") if av_mode == "timeline": title = _("Availability Timeline") else: title = _("Availability") # This is combined with the object selection # - Show all objects # - Show one specific object # --> controlled by URL variables "av_site", "av_host" and "av_service" # --> controlled by "av_aggr" in case of BI aggregate title += " - " if html.var("av_host"): av_object = (html.var("av_site"), html.var("av_host"), html.var("av_service")) title += av_object[1] if av_object[2]: title += " - " + av_object[2] elif html.var("av_aggr"): av_object = (None, None, html.var("av_aggr")) title += av_object[2] else: av_object = None title += view_title(view) # Now compute all data, we need this also for CSV export if not html.has_user_errors(): av_rawdata = availability.get_availability_rawdata( what, filterheaders, only_sites, av_object, av_mode == "timeline", avoptions) av_data = availability.compute_availability(what, av_rawdata, avoptions) # Do CSV ouput if html.output_format == "csv_export": output_availability_csv(what, av_data, avoptions) return title += " - " + range_title if 'H' in display_options: html.body_start(title, stylesheets=["pages", "views", "status"], force=True) if 'T' in display_options: html.top_heading(title) handle_delete_annotations() # Remove variables for editing annotations, otherwise they will make it into the uris html.del_all_vars("editanno_") html.del_all_vars("anno_") if html.var("filled_in") == "editanno": html.del_var("filled_in") if 'B' in 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") if config.reporting_available() and config.may("general.reporting"): html.context_button(_("Export as PDF"), html.makeuri([], filename="report_instant.py"), "report") if av_mode == "table": html.context_button( _("Export as CSV"), html.makeuri([("output_format", "csv_export")]), "download_csv") if av_mode == "timeline" or av_object: html.context_button( _("Availability"), html.makeuri([("av_mode", "availability"), ("av_host", ""), ("av_aggr", "")]), "availability") elif not av_object: html.context_button(_("Timeline"), html.makeuri([("av_mode", "timeline")]), "timeline") elif av_mode == "timeline" and what != "bi": history_url = availability.history_url_of(av_object, time_range) html.context_button(_("History"), history_url, "history") html.end_context_buttons() # Render the avoptions again to get the HTML code, because the HTML vars have changed # above (anno_ and editanno_ has been removed, which must not be part of the form avoptions = render_availability_options(what) if not html.has_user_errors(): do_render_availability(what, av_rawdata, av_data, av_mode, av_object, avoptions) if 'Z' in display_options: html.bottom_footer() if 'H' in display_options: html.body_end()
def render_availability_page(view, datasource, filterheaders, only_sites, limit): if handle_edit_annotations(): return # We make reports about hosts, services or BI aggregates if "service" in datasource["infos"]: what = "service" elif "aggr_name" in datasource["infos"]: what = "bi" else: what = "host" avoptions = get_availability_options_from_url(what) time_range, range_title = avoptions["range"] # We have two display modes: # - Show availability table (stats) "table" # - Show timeline "timeline" # --> controlled by URL variable "av_mode" av_mode = html.var("av_mode", "table") if av_mode == "timeline": title = _("Availability Timeline") else: title = _("Availability") # This is combined with the object selection # - Show all objects # - Show one specific object # --> controlled by URL variables "av_site", "av_host" and "av_service" # --> controlled by "av_aggr" in case of BI aggregate title += " - " if html.var("av_host"): av_object = (html.var("av_site"), html.var("av_host"), html.var("av_service")) title += av_object[1] if av_object[2]: title += " - " + av_object[2] elif html.var("av_aggr"): av_object = (None, None, html.var("av_aggr")) title += av_object[2] else: av_object = None title += view_title(view) # Deletion must take place before computation, since it affects the outcome html.plug() handle_delete_annotations() confirmation_html_code = html.drain() html.unplug() # Now compute all data, we need this also for CSV export if not html.has_user_errors(): av_rawdata, has_reached_logrow_limit = \ availability.get_availability_rawdata(what, filterheaders, only_sites, av_object, av_mode == "timeline", avoptions) av_data = availability.compute_availability(what, av_rawdata, avoptions) # Do CSV ouput if html.output_format == "csv_export": output_availability_csv(what, av_data, avoptions) return title += " - " + range_title if display_options.enabled(display_options.H): html.body_start(title, stylesheets=["pages", "views", "status"], force=True) if display_options.enabled(display_options.T): html.top_heading(title) html.write(confirmation_html_code) # Remove variables for editing annotations, otherwise they will make it into the uris html.del_all_vars("editanno_") html.del_all_vars("anno_") if html.var("filled_in") == "editanno": html.del_var("filled_in") if display_options.enabled(display_options.B): 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") if config.reporting_available() and config.user.may( "general.reporting"): html.context_button(_("Export as PDF"), html.makeuri([], filename="report_instant.py"), "report") if av_mode == "table": html.context_button( _("Export as CSV"), html.makeuri([("output_format", "csv_export")]), "download_csv") if av_mode == "timeline" or av_object: html.context_button( _("Availability"), html.makeuri([("av_mode", "availability"), ("av_host", ""), ("av_aggr", "")]), "availability") elif not av_object: html.context_button(_("Timeline"), html.makeuri([("av_mode", "timeline")]), "timeline") elif av_mode == "timeline" and what != "bi": history_url = availability.history_url_of(av_object, time_range) html.context_button(_("History"), history_url, "history") html.end_context_buttons() # Render the avoptions again to get the HTML code, because the HTML vars have changed # above (anno_ and editanno_ has been removed, which must not be part of the form avoptions = render_availability_options(what) if not html.has_user_errors(): # If we abolish the limit we have to fetch the data again # with changed logrow_limit = 0, which means no limit if has_reached_logrow_limit: text = _( "Your query matched more than %d log entries. " "<b>Note:</b> The number of shown rows does not necessarily reflect the " "matched entries and the result might be incomplete. " ) % avoptions["logrow_limit"] text += '<a href="%s">%s</a>' % \ (html.makeuri([("_unset_logrow_limit", "1"), ("avo_logrow_limit", 0)]), _('Repeat query without limit.')) html.show_warning(text) do_render_availability(what, av_rawdata, av_data, av_mode, av_object, avoptions) if display_options.enabled(display_options.Z): html.bottom_footer() if display_options.enabled(display_options.H): html.body_end()
def render_availability_page(view, datasource, filterheaders, only_sites, limit): if handle_edit_annotations(): return # We make reports about hosts, services or BI aggregates if "service" in datasource["infos"]: what = "service" elif "aggr_name" in datasource["infos"]: what = "bi" else: what = "host" avoptions = get_availability_options_from_url(what) time_range, range_title = avoptions["range"] # We have two display modes: # - Show availability table (stats) "table" # - Show timeline "timeline" # --> controlled by URL variable "av_mode" av_mode = html.var("av_mode", "table") if av_mode == "timeline": title = _("Availability Timeline") else: title = _("Availability") # This is combined with the object selection # - Show all objects # - Show one specific object # --> controlled by URL variables "av_site", "av_host" and "av_service" # --> controlled by "av_aggr" in case of BI aggregate title += " - " if html.var("av_host"): av_object = (html.var("av_site"), html.var("av_host"), html.var("av_service")) title += av_object[1] if av_object[2]: title += " - " + av_object[2] elif html.var("av_aggr"): av_object = (None, None, html.var("av_aggr")) title += av_object[2] else: av_object = None title += view_title(view) # Deletion must take place before computation, since it affects the outcome html.plug() handle_delete_annotations() confirmation_html_code = html.drain() html.unplug() # Now compute all data, we need this also for CSV export if not html.has_user_errors(): av_rawdata = availability.get_availability_rawdata(what, filterheaders, only_sites, av_object, av_mode == "timeline", avoptions) av_data = availability.compute_availability(what, av_rawdata, avoptions) # Do CSV ouput if html.output_format == "csv_export": output_availability_csv(what, av_data, avoptions) return title += " - " + range_title if DisplayOptions.enabled(DisplayOptions.H): html.body_start(title, stylesheets=["pages","views","status"], force=True) if DisplayOptions.enabled(DisplayOptions.T): html.top_heading(title) html.write(confirmation_html_code) # Remove variables for editing annotations, otherwise they will make it into the uris html.del_all_vars("editanno_") html.del_all_vars("anno_") if html.var("filled_in") == "editanno": html.del_var("filled_in") if DisplayOptions.enabled(DisplayOptions.B): 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") if config.reporting_available(): html.context_button(_("Export as PDF"), html.makeuri([], filename="report_instant.py"), "report") if av_mode == "table": html.context_button(_("Export as CSV"), html.makeuri([("output_format", "csv_export")]), "download_csv") if av_mode == "timeline" or av_object: html.context_button(_("Availability"), html.makeuri([("av_mode", "availability"), ("av_host", ""), ("av_aggr", "")]), "availability") elif not av_object: html.context_button(_("Timeline"), html.makeuri([("av_mode", "timeline")]), "timeline") elif av_mode == "timeline" and what != "bi": history_url = availability.history_url_of(av_object, time_range) html.context_button(_("History"), history_url, "history") html.end_context_buttons() # Render the avoptions again to get the HTML code, because the HTML vars have changed # above (anno_ and editanno_ has been removed, which must not be part of the form avoptions = render_availability_options(what) if not html.has_user_errors(): do_render_availability(what, av_rawdata, av_data, av_mode, av_object, avoptions) if DisplayOptions.enabled(DisplayOptions.Z): html.bottom_footer() if DisplayOptions.enabled(DisplayOptions.H): html.body_end()