def test_theme_request_context_integration(my_theme, request_context): theme.from_config("facelift") theme.set("") assert theme.get() == "facelift" theme.set("not_existing") assert theme.get() == "facelift" theme.set("my_theme") assert theme.get() == "my_theme"
def test_theme_request_context_integration(my_theme, register_builtin_html): theme.from_config("facelift", config.theme_choices()) theme.set("") assert theme.get() == "facelift" theme.set("not_existing") assert theme.get() == "facelift" theme.set("my_theme") assert theme.get() == "my_theme"
def _show_body_start(self) -> None: body_classes = ['side', "screenshotmode" if config.screenshotmode else None] if not user.may("general.see_sidebar"): html.open_body(class_=body_classes, data_theme=theme.get()) return interval = config.sidebar_notify_interval if config.sidebar_notify_interval is not None else "null" html.open_body( class_=body_classes, onload= 'cmk.sidebar.initialize_scroll_position(); cmk.sidebar.init_messages_and_werks(%s, %s); ' % (json.dumps(interval), json.dumps(bool(may_acknowledge()))), data_theme=theme.get(), )
def update(self): import cmk.gui.sidebar as sidebar # pylint: disable=import-outside-toplevel dashlet = self._dashlet_spec snapin = sidebar.snapin_registry.get(self._dashlet_spec['snapin']) if not snapin: raise MKUserError(None, _('The configured element does not exist.')) snapin_instance = snapin() html.set_browser_reload(self.refresh_interval()) html.html_head(_('Sidebar element')) html.open_body(class_="side", data_theme=theme.get()) html.open_div(id_="check_mk_sidebar") html.open_div(id_="side_content") html.open_div(id_="snapin_container_%s" % dashlet['snapin'], class_="snapin") html.open_div(id_="snapin_%s" % dashlet['snapin'], class_="content") styles = snapin_instance.styles() if styles: html.style(styles) snapin_instance.show() html.close_div() html.close_div() html.close_div() html.close_div() html.body_end()
def add_default_render_options(graph_render_options, render_unthemed=False): options = get_default_graph_render_options() options.update(graph_render_options) options.setdefault("size", user.load_file("graph_size", (70, 16))) # Users can't modify graph colors. Only defaults are allowed theme_colors = _graph_colors(theme.get() if not render_unthemed else "pdf") options.update(theme_colors) return options
def add_default_render_options(graph_render_options, render_unthemed=False): options = get_default_graph_render_options() options.update(graph_render_options) options.setdefault("size", config.user.load_file("graph_size", (70, 16))) # Update the graph colors that are set to "default" with the theme specific colors. # When rendering to PDF the theme colors must not be applied, but the regular colors # have to be used. theme_colors = _graph_colors(theme.get() if not render_unthemed else "pdf") for attr_name in ["background_color", "foreground_color", "canvas_color"]: if options[attr_name] == "default": options[attr_name] = theme_colors[attr_name] return options
def page(self) -> AjaxPageResult: themes = [theme for theme, _title in theme_choices()] current_theme = theme.get() try: theme_index = themes.index(current_theme) except ValueError: raise MKUserError(None, _("Could not determine current theme.")) if len(themes) == theme_index + 1: new_theme = themes[0] else: new_theme = themes[theme_index + 1] _set_user_attribute("ui_theme", new_theme) return {}
def _get_current_theme_titel() -> str: return [ titel for theme_id, titel in theme.theme_choices if theme_id == theme.get() ][0]
def get_themed_perfometer_bg_color() -> str: """Return the theme specific background color for perfometer rendering""" if theme.get() == "modern-dark": return "#bdbdbd" # else (classic and modern theme) return "#ffffff"