示例#1
0
    def show(self, menu: MegaMenu) -> None:
        more_id = "main_menu_" + menu.name

        show_more = get_show_more_setting(more_id)
        html.open_div(id_=more_id, class_=["main_menu", "more" if show_more else "less"])
        hide_entries_js = "cmk.popup_menu.mega_menu_hide_entries('%s')" % more_id

        html.open_div(class_="navigation_bar")
        html.open_div(class_="search_bar")
        if menu.search:
            menu.search.show_search_field()
        html.close_div()
        if menu.info_line:
            html.span(menu.info_line(), id_="info_line")
        topics = menu.topics()
        if any_show_more_items(topics):
            html.open_div()
            html.more_button(id_=more_id,
                             dom_levels_up=3,
                             additional_js=hide_entries_js,
                             with_text=True)
            html.close_div()
        html.close_div()
        html.open_div(class_="content inner", id="content_inner_%s" % menu.name)
        for topic in topics:
            self._show_topic(topic, menu.name)
        html.div(None, class_=["topic", "sentinel"])
        html.close_div()
        html.close_div()
        html.javascript(hide_entries_js)
        html.javascript("cmk.popup_menu.initialize_mega_menus();")
        html.open_div(class_="content inner", id="content_inner_%s_search" % menu.name)
        html.close_div()
示例#2
0
    def show(self, menu: MegaMenu) -> None:
        more_id = "main_menu_" + menu.name

        show_more = get_show_more_setting(more_id)
        html.open_div(id_=more_id,
                      class_=["main_menu", "more" if show_more else "less"])
        hide_entries_js = "cmk.popup_menu.mega_menu_hide_entries('%s')" % more_id

        topics = menu.topics()
        if any_advanced_items(topics):
            html.more_button(id_=more_id,
                             dom_levels_up=1,
                             additional_js=hide_entries_js)
        html.open_div(class_="content inner")
        for topic in topics:
            self._show_topic(topic, menu.name)
        html.close_div()
        html.close_div()
        html.javascript(hide_entries_js)
        html.javascript("cmk.popup_menu.initialize_mega_menus();")
示例#3
0
            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."))
示例#4
0
                    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:
示例#5
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="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:
示例#6
0
            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."))
示例#7
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")
示例#8
0
文件: views.py 项目: petrows/checkmk
            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"),
    ))
示例#9
0
                                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"),
    ))
示例#10
0
                ),
                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,
    ))
示例#11
0
            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()})"))
示例#12
0
                    "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,
    ))