def _get_template_based_layout_settings(self, aggr_settings: Dict[str, Any]) -> Dict[str, Any]: template_layout_id = aggr_settings.get("layout_id", "builtin_default") layout_settings: Dict[str, Any] = {} if template_layout_id in BILayoutManagement.get_all_bi_template_layouts(): # FIXME: This feature is currently inactive layout_settings["origin_type"] = "template" layout_settings["origin_info"] = _("Template: %s") % template_layout_id layout_settings["template_id"] = template_layout_id layout_settings["config"] = BILayoutManagement.load_bi_template_layout( template_layout_id) elif template_layout_id.startswith("builtin_"): # FIXME: this mapping is currently copied from the bi configuration valuespec # BI refactoring required... builtin_mapping = { "builtin_default": _("global"), "builtin_force": _("force"), "builtin_radial": _("radial"), "builtin_hierarchy": _("hierarchy") } layout_settings["origin_type"] = "default_template" layout_settings["origin_info"] = _("Default %s template") % builtin_mapping.get( template_layout_id, _("Unknown")) if template_layout_id == "builtin_default": template_layout_id = config.default_bi_layout["node_style"] layout_settings["default_id"] = template_layout_id[8:] else: # Any Unknown/Removed layout id gets the default template layout_settings["origin_type"] = "default_template" layout_settings["origin_info"] = _("Fallback template (%s): Unknown ID %s") % ( config.default_bi_layout["node_style"][8:].title(), template_layout_id) layout_settings["default_id"] = config.default_bi_layout["node_style"][8:] return layout_settings
def page(self) -> AjaxPageResult: check_csrf_token() layout_var = request.get_str_input_mandatory("layout", "{}") layout_config = json.loads(layout_var) active_config.bi_layouts["templates"].update(layout_config) BILayoutManagement.save_layouts() return {}
def page(self) -> AjaxPageResult: aggregations_var = html.request.get_str_input_mandatory("aggregations", "[]") filter_names = json.loads(aggregations_var) forced_layout_id = html.request.var("layout_id") if forced_layout_id not in BILayoutManagement.get_all_bi_template_layouts(): forced_layout_id = None bi_aggregation_filter = BIAggregationFilter([], [], [], filter_names, [], []) results = bi.get_cached_bi_manager().computer.compute_result_for_filter( bi_aggregation_filter) aggregation_info: Dict[str, Any] = {"aggregations": {}} aggregation_layouts = BILayoutManagement.get_all_bi_aggregation_layouts() for bi_compiled_aggregation, node_result_bundles in results: for node_result_bundle in node_result_bundles: branch = node_result_bundle.instance aggr_name = branch.properties.title visual_mapper = NodeVisualizationBIDataMapper( is_single_host_aggregation=len(branch.get_required_hosts()) == 1) hierarchy = visual_mapper.consume(node_result_bundle) data: Dict[str, Any] = {} data["type"] = "bi" data["hierarchy"] = hierarchy data["groups"] = bi_compiled_aggregation.groups.names data["data_timestamp"] = int(time.time()) aggr_settings = bi_compiled_aggregation.aggregation_visualization layout: Dict[str, Any] = {"config": {}} if forced_layout_id: layout["enforced_id"] = aggr_name layout["origin_type"] = "globally_enforced" layout["origin_info"] = _("Globally enforced") layout["use_layout"] = BILayoutManagement.load_bi_template_layout( forced_layout_id) else: if aggr_name in aggregation_layouts: layout["origin_type"] = "explicit" layout["origin_info"] = _("Explicit set") layout["explicit_id"] = aggr_name layout["config"] = aggregation_layouts[aggr_name] layout["config"]["ignore_rule_styles"] = True else: layout.update(self._get_template_based_layout_settings(aggr_settings)) if "ignore_rule_styles" not in layout["config"]: layout["config"]["ignore_rule_styles"] = aggr_settings.get( "ignore_rule_styles", False) if "line_config" not in layout["config"]: layout["config"]["line_config"] = self._get_line_style_config(aggr_settings) data["layout"] = layout aggregation_info["aggregations"][aggr_name] = data html.set_output_format("json") return aggregation_info
def page(self) -> AjaxPageResult: return BILayoutManagement.get_all_bi_template_layouts()
def page(self) -> AjaxPageResult: layout_id = request.var("layout_id") return BILayoutManagement.load_bi_template_layout(layout_id)
def page(self) -> AjaxPageResult: layout_id = request.var("layout_id") config.bi_layouts["templates"].pop(layout_id) BILayoutManagement.save_layouts() return {}
def page(self) -> AjaxPageResult: aggregation_name = request.var("aggregation_name") return BILayoutManagement.load_bi_aggregation_layout(aggregation_name)
def page(self) -> AjaxPageResult: for_aggregation = request.var("aggregation_name") config.bi_layouts["aggregations"].pop(for_aggregation) BILayoutManagement.save_layouts() return {}
def page(self) -> AjaxPageResult: layout_var = request.get_str_input_mandatory("layout", "{}") layout_config = json.loads(layout_var) config.bi_layouts["aggregations"].update(layout_config) BILayoutManagement.save_layouts() return {}
def page(self) -> AjaxPageResult: check_csrf_token() layout_id = request.var("layout_id") active_config.bi_layouts["templates"].pop(layout_id) BILayoutManagement.save_layouts() return {}
def page(self) -> AjaxPageResult: check_csrf_token() for_aggregation = request.var("aggregation_name") active_config.bi_layouts["aggregations"].pop(for_aggregation) BILayoutManagement.save_layouts() return {}