def render_availability_options(what): if html.request.var("_reset"): config.user.save_file("avoptions", {}) html.request.del_vars("avo_") html.request.del_var("avoptions") avoptions = availability.get_default_avoptions() # Users of older versions might not have all keys set. The following # trick will merge their options with our default options. avoptions.update(config.user.load_file("avoptions", {})) is_open = False html.begin_form("avoptions") html.hidden_field("avoptions", "set") avoption_entries = availability.get_avoption_entries(what) if html.request.var("avoptions") == "set": for name, height, _show_in_reporting, vs in avoption_entries: try: avoptions[name] = vs.from_html_vars("avo_" + name) vs.validate_value(avoptions[name], "avo_" + name) except MKUserError as e: html.add_user_error(e.varname, e) is_open = True if html.request.var("_unset_logrow_limit") == "1": avoptions["logrow_limit"] = 0 range_vs = None for name, height, _show_in_reporting, vs in avoption_entries: if name == 'rangespec': range_vs = vs try: range_, range_title = range_vs.compute_range(avoptions["rangespec"]) avoptions["range"] = range_, range_title except MKUserError as e: html.add_user_error(e.varname, e) if html.has_user_errors(): html.show_user_errors() html.begin_floating_options("avoptions", is_open) for name, height, _show_in_reporting, vs in avoption_entries: html.render_floating_option(name, height, "avo_", vs, avoptions.get(name)) html.end_floating_options(reset_url=html.makeuri( [("_reset", "1")], remove_prefix="avo_", delvars=["apply", "filled_in"], )) html.hidden_fields() html.end_form() if html.form_submitted(): config.user.save_file("avoptions", avoptions) return avoptions
def _get_availability_timelines(self, start_time, end_time, only_sites, filter_headers): avoptions = availability.get_default_avoptions() timerange = start_time, end_time avoptions["range"] = timerange, "" # Currently we have now way to show a warning message for _has_reached_logrow_limit av_rawdata, _has_reached_logrow_limit = availability.get_availability_rawdata( what="service", context={}, filterheaders=filter_headers, only_sites=only_sites, av_object=None, include_output=True, include_long_output=False, avoptions=avoptions, ) av_data = availability.compute_availability(what="service", av_rawdata=av_rawdata, avoptions=avoptions) return av_data