def _show_view_as_dashlet(self, view_spec: ViewSpec): html.add_body_css_class("view") html.open_div(id_="dashlet_content_wrapper") is_reload = html.request.has_var("_reload") view_display_options = "SIXLW" if not is_reload: view_display_options += "HR" html.request.set_var('display_options', view_display_options) html.request.set_var('_display_options', view_display_options) html.add_body_css_class('dashlet') # Need to be loaded before processing the painter_options below. # TODO: Make this dependency explicit display_options.load_from_html(html) painter_options = PainterOptions.get_instance() painter_options.load(self._dashlet_spec["name"]) view = views.View(self._dashlet_spec["name"], view_spec, self.context) view.row_limit = views.get_limit() view.only_sites = visuals.get_only_sites_from_context(self.context) view.user_sorters = views.get_user_sorters() views.process_view(views.GUIViewRenderer(view, show_buttons=False)) html.close_div()
def page_handler() -> None: initialize_wato_html_head() if not config.wato_enabled: raise MKGeneralException( _("WATO is disabled. Please set <tt>wato_enabled = True</tt>" " in your <tt>multisite.mk</tt> if you want to use WATO.")) # config.current_customer can not be checked with CRE repos if cmk_version.is_managed_edition() and not managed.is_provider( config.current_customer): # type: ignore[attr-defined] raise MKGeneralException( _("Check_MK can only be configured on " "the managers central site.")) current_mode = html.request.var("mode") or "main" mode_permissions, mode_class = _get_mode_permission_and_class(current_mode) display_options.load_from_html(html) if display_options.disabled(display_options.N): html.add_body_css_class("inline") # If we do an action, we aquire an exclusive lock on the complete WATO. if html.is_transaction(): with store.lock_checkmk_configuration(): _wato_page_handler(current_mode, mode_permissions, mode_class) else: _wato_page_handler(current_mode, mode_permissions, mode_class)
def _show_view_as_dashlet(self, view_spec: ViewSpec): html.add_body_css_class("view") html.open_div(id_="dashlet_content_wrapper") is_reload = request.has_var("_reload") view_display_options = "SIXLW" if not is_reload: view_display_options += "HR" request.set_var("display_options", view_display_options) request.set_var("_display_options", view_display_options) html.add_body_css_class("dashlet") # Need to be loaded before processing the painter_options below. # TODO: Make this dependency explicit display_options.load_from_html(request, html) painter_options = PainterOptions.get_instance() painter_options.load(self._dashlet_spec["name"]) # Here the linked view default context has the highest priority # linkedview default>dashlet>url active filter, dashboard context = visuals.get_merged_context(self.context, view_spec["context"]) view = views.View(self._dashlet_spec["name"], view_spec, context) view.row_limit = views.get_limit() view.only_sites = visuals.get_only_sites_from_context(context) view.user_sorters = views.get_user_sorters() views.process_view(views.GUIViewRenderer(view, show_buttons=False)) html.close_div()
def _show_view_as_dashlet(self, view_spec: ViewSpec): html.add_body_css_class("view") html.open_div(id_="dashlet_content_wrapper") is_reload = request.has_var("_reload") view_display_options = "SIXLW" if not is_reload: view_display_options += "HR" request.set_var("display_options", view_display_options) request.set_var("_display_options", view_display_options) html.add_body_css_class("dashlet") # Need to be loaded before processing the painter_options below. # TODO: Make this dependency explicit display_options.load_from_html(request, html) painter_options = PainterOptions.get_instance() painter_options.load(self._dashlet_spec["name"]) # Here the linked view default context has the highest priority # linkedview default>dashlet>url active filter> dashboard. However views # have the "show_filters" default to prefill the filtermenu with empty # valued filters(UX). Those need to be cleared out. Otherwise those # empty filters are the highest priority filters and the user can never # filter the view. view_context = { filtername: filtervalues for filtername, filtervalues in view_spec["context"].items() if { var: value for var, value in filtervalues.items() # These are the filters request variables. Keep set values # For the TriStateFilters unset == ignore == "-1" # all other cases unset is an empty string if (var.startswith("is_") and value != "-1" ) # TriState filters except ignore or (not var.startswith("is_") and value ) # Rest of filters with some value } } context = visuals.get_merged_context(self.context, view_context) view = views.View(self._dashlet_spec["name"], view_spec, context) view.row_limit = views.get_limit() view.only_sites = visuals.get_only_sites_from_context(context) view.user_sorters = views.get_user_sorters() views.process_view(views.GUIViewRenderer(view, show_buttons=False)) html.close_div()
def page_view() -> None: view_name = html.request.var("view_name") if not view_name: return page_index() view_spec = views.get_permitted_views().get(view_name) if not view_spec: raise MKUserError("view_name", "No view defined with the name '%s'." % view_name) datasource = data_source_registry[view_spec["datasource"]]() context = visuals.get_merged_context( visuals.get_context_from_uri_vars( datasource.infos, single_infos=view_spec["single_infos"]), view_spec["context"], ) view = views.View(view_name, view_spec, context) view.row_limit = views.get_limit() view.only_sites = visuals.get_only_sites_from_context(context) view.user_sorters = views.get_user_sorters() view.want_checkboxes = views.get_want_checkboxes() title = views.view_title(view.spec, view.context) mobile_html_head(title) # Need to be loaded before processing the painter_options below. # TODO: Make this dependency explicit display_options.load_from_html(html) painter_options = PainterOptions.get_instance() painter_options.load(view_name) try: views.process_view(MobileViewRenderer(view)) except Exception as e: logger.exception("error showing mobile view") if config.debug: raise html.write("ERROR showing view: %s" % escaping.escape_attribute(str(e))) mobile_html_foot()