items=quick_items, ), TopicMenuTopic( name="user", title=_("User profile"), icon="topic_profile", items=items, ), ] mega_menu_registry.register( MegaMenu( name="user", title=_l("User"), icon="main_user", sort_index=20, topics=_user_menu_topics, info_line=lambda: f"{user.id} ({user.baserole_id})", )) @page_registry.register_page("ajax_ui_theme") class ModeAjaxCycleThemes(AjaxPage): """AJAX handler for quick access option 'Interface theme" in user menu""" 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."))
# Sort the items of all topics for topic in by_topic.values(): topic.items.sort(key=lambda i: (i.sort_index, i.title)) # Return the sorted topics return [ v for k, v in sorted(by_topic.items(), key=lambda e: (e[0].sort_index, e[0].title)) ] mega_menu_registry.register( MegaMenu( name="setup", title=_l("Setup"), icon="main_setup", sort_index=15, topics=get_wato_menu_items, search=search.SetupSearch("setup_search"), )) class MatchItemGeneratorSetupMenu(ABCMatchItemGenerator): def __init__( self, name: str, topic_generator: Callable[[], Iterable[TopicMenuTopic]], ) -> None: super().__init__(name) self._topic_generator = topic_generator def generate_match_items(self) -> MatchItems:
title=_("Change log (Werks)"), url="change_log.py", sort_index=20, icon="tribe29", ), ], ), ] mega_menu_registry.register( MegaMenu( name="help_links", title=_l("Help"), icon="main_help", sort_index=18, topics=_help_menu_topics, info_line=lambda: f"{edition().title} {__version__}{free_edition_status()}", )) def free_edition_status() -> str: if not is_free_edition(): return "" passed_time = get_age_trial() # Hardcoded 30 days of trial. For dynamic trial time change the 30 days remaining_time = timedelta(seconds=30 * 24 * 60 * 60 - passed_time) if is_expired_trial() or remaining_time.days < 0:
# Sort the items of all topics for topic in by_topic.values(): topic.items.sort(key=lambda i: (i.sort_index, i.title)) # Return the sorted topics return [ v for k, v in sorted(by_topic.items(), key=lambda e: (e[0].sort_index, e[0].title)) ] mega_menu_registry.register( MegaMenu( name="setup", title=_l("Setup"), icon_name="main_setup", sort_index=15, topics=get_wato_menu_items, )) @snapin_registry.register class SidebarSnapinWATO(SidebarSnapin): @staticmethod def type_name(): return "admin" @classmethod def title(cls): return _("WATO - Configuration")
items=quick_items, ), TopicMenuTopic( name="user", title=_("Profile"), icon="topic_profile", items=items, ) ] mega_menu_registry.register( MegaMenu( name="user", title=_l("User"), icon="main_user", sort_index=20, topics=_user_menu_topics, )) @page_registry.register_page("ajax_ui_theme") class ModeAjaxCycleThemes(AjaxPage): """AJAX handler for quick access option 'Interface theme" in user menu""" def page(self): themes = [theme for theme, _title in cmk.gui.config.theme_choices()] current_theme = html.get_theme() try: theme_index = themes.index(current_theme) except ValueError: raise MKUserError(None, _("Could not determine current theme."))
not config.hidden_views or name not in config.hidden_views) ] network_topology_visual_spec = ParentChildTopologyPage.visual_spec() pages_to_show = [(network_topology_visual_spec["name"], network_topology_visual_spec)] visuals_to_show = [("views", e) for e in views_to_show] visuals_to_show += [("dashboards", e) for e in dashboard.get_permitted_dashboards().items()] visuals_to_show += [("pages", e) for e in pages_to_show] visuals_to_show += page_type_items if reporting: reporting.load_reports() visuals_to_show += [("reports", e) for e in reporting.permitted_reports().items()] return make_topic_menu(visuals_to_show) mega_menu_registry.register( MegaMenu( name="monitoring", title=_l("Monitor"), icon="main_monitoring", sort_index=5, topics=get_view_menu_items, search=search.MonitoringSearch("monitoring_search"), ))
or name not in active_config.hidden_views) ] network_topology_visual_spec = ParentChildTopologyPage.visual_spec() pages_to_show = [(network_topology_visual_spec["name"], network_topology_visual_spec)] visuals_to_show = [("views", e) for e in views_to_show] visuals_to_show += [("dashboards", e) for e in dashboard.get_permitted_dashboards().items()] visuals_to_show += [("pages", e) for e in pages_to_show] visuals_to_show += page_type_items if reporting and include_reports: reporting.load_reports() visuals_to_show += [("reports", e) for e in reporting.permitted_reports().items()] return make_topic_menu(visuals_to_show) mega_menu_registry.register( MegaMenu( name="monitoring", title=_l("Monitor"), icon="main_monitoring", sort_index=5, topics=lambda: get_view_menu_items(include_reports=True), search=search.MonitoringSearch("monitoring_search"), ))
), TopicMenuItem( name="rest_api_swagger_ui", title=_("REST-API Interactive GUI"), url="api/v0/ui/", target="_blank", sort_index=30, icon=None, # TODO(CMK-5773): add an icon ), TopicMenuItem( name="youtube_channel", title=_("Youtube"), url="https://www.youtube.com/checkmk-channel", target="_blank", sort_index=30, icon=None, # TODO(CMK-5773): add an icon ), ], ), ] mega_menu_registry.register( MegaMenu( name="help_links", title=_l("Help"), icon="main_help", sort_index=18, topics=_help_menu_topics, ))
icon=None, # TODO(CMK-5773): add an icon items=[ TopicMenuItem( name="manual", title=_("Manual"), url="https://checkmk.com/cms.html", target="_blank", sort_index=30, icon=None, # TODO(CMK-5773): add an icon ), TopicMenuItem( name="youtube_channel", title=_("YouTube"), url="https://www.youtube.com/checkmk-channel", target="_blank", sort_index=30, icon=None, # TODO(CMK-5773): add an icon ), ], ), ] mega_menu_registry.register( MegaMenu(name="help_links", title=_l("Help"), icon="main_help", sort_index=18, topics=_help_menu_topics, info_line=lambda: f"{__version__} ({edition_title()})"))
"hidden"] = False # Is currently to configurable for pagetypes visual[ "icon"] = None # Is currently to configurable for pagetypes page_type_items.append( (page_type.type_name(), (page.name(), visual))) # Apply some view specific filters views_to_show = [ (name, view) for name, view in views.get_permitted_views().items() if (not config.visible_views or name in config.visible_views) and ( not config.hidden_views or name not in config.hidden_views) ] visuals_to_show = [("views", e) for e in views_to_show] visuals_to_show += [("dashboards", e) for e in dashboard.get_permitted_dashboards().items()] visuals_to_show += page_type_items return make_topic_menu(visuals_to_show) mega_menu_registry.register( MegaMenu( name="monitoring", title=_l("Monitor"), icon_name="main_monitoring", sort_index=5, topics=get_view_menu_items, ))