예제 #1
0
def render_wato(mini):
    if not config.wato_enabled:
        html.write_text(_("WATO is disabled."))
        return False
    elif not config.user.may("wato.use"):
        html.write_text(
            _("You are not allowed to use Check_MK's web configuration GUI."))
        return False

    if mini:
        html.icon_button("wato.py", _("Main Menu"), "home", target="main")
    else:
        iconlink(_("Main Menu"), "wato.py", "home")

    for module in wato.get_modules():
        if not module.may_see():
            continue

        url = module.get_url()
        if mini:
            html.icon_button(url, module.title, module.icon, target="main")
        else:
            iconlink(module.title, url, module.icon)

    pending_info = watolib.get_pending_changes_info()
    if pending_info:
        footnotelinks([(pending_info, "wato.py?mode=changelog")])
        html.div('', class_="clear")
예제 #2
0
def render_wato(mini):
    if not config.wato_enabled:
        html.write_text(_("WATO is disabled."))
        return False
    if not config.user.may("wato.use"):
        html.write_text(
            _("You are not allowed to use Check_MK's web configuration GUI."))
        return False

    menu = get_wato_menu_items()

    if mini:
        for topic in menu:
            for item in topic.items:
                html.icon_button(url=item.url,
                                 title=item.title,
                                 icon=item.icon_name or "wato",
                                 target="main")
    else:
        show_topic_menu(treename="wato", menu=menu, show_item_icons=True)

    pending_info = watolib.get_pending_changes_info()
    if pending_info:
        footnotelinks([(pending_info, "wato.py?mode=changelog")])
        html.div('', class_="clear")
예제 #3
0
def render_wato(mini):
    if not config.wato_enabled:
        html.write_text(_("Setup is disabled."))
        return False
    if not user.may("wato.use"):
        html.write_text(_("You are not allowed to use the setup."))
        return False

    menu = get_wato_menu_items()

    if mini:
        for topic in menu:
            for item in topic.items:
                html.icon_button(
                    url=item.url,
                    class_="show_more_mode" if item.is_show_more else None,
                    title=item.title,
                    icon=item.icon or "wato",
                    target="main",
                )
    else:
        show_topic_menu(treename="wato", menu=menu, show_item_icons=True)

    pending_info = watolib.get_pending_changes_info()
    if pending_info:
        footnotelinks([(pending_info, "wato.py?mode=changelog")])
        html.div("", class_="clear")
예제 #4
0
파일: views.py 프로젝트: selten/checkmk
    def show(self):
        show_topic_menu(treename="views", menu=get_view_menu_items())

        links = []
        if config.user.may("general.edit_views"):
            if config.debug:
                links.append((_("Export"), "export_views.py"))
            links.append((_("Edit"), "edit_views.py"))
            footnotelinks(links)
예제 #5
0
    def show(self):
        show_topic_menu(treename="dashboards",
                        menu=self._get_dashboard_menu_items())

        links = []
        if user.may("general.edit_dashboards"):
            if config.debug:
                links.append((_("Export"), "export_dashboards.py"))
            links.append((_("Edit"), "edit_dashboards.py"))
            footnotelinks(links)
예제 #6
0
파일: views.py 프로젝트: rabbitt/checkmk
    def show(self):
        for topic, entries in get_view_menu_items().items():
            if entries:
                self._render_topic(topic, entries)

        links = []
        if config.user.may("general.edit_views"):
            if config.debug:
                links.append((_("Export"), "export_views.py"))
            links.append((_("Edit"), "edit_views.py"))
            footnotelinks(links)
예제 #7
0
파일: dashboards.py 프로젝트: stmps/checkmk
    def show(self):
        dashboard.load_dashboards()

        def render_topic(topic, s, foldable=True):
            first = True
            for t, title, name, _is_view in s:
                if t == topic:
                    if first:
                        if foldable:
                            html.begin_foldable_container("dashboards",
                                                          topic,
                                                          False,
                                                          topic,
                                                          indent=True)
                        else:
                            html.open_ul()
                        first = False
                    bulletlink(
                        title,
                        'dashboard.py?name=%s' % name,
                        onclick="return cmk.sidebar.wato_views_clicked(this)")

            if not first:  # at least one item rendered
                if foldable:
                    html.end_foldable_container()
                else:
                    html.open_ul()

        by_topic = visuals_by_topic(dashboard.permitted_dashboards().items(),
                                    default_order=[_('Overview')])
        topics = [topic for topic, _entry in by_topic]

        if len(topics) < 2:
            render_topic(by_topic[0][0], by_topic[0][1], foldable=False)
        else:
            for topic, s in by_topic:
                render_topic(topic, s)

        links = []
        if config.user.may("general.edit_dashboards"):
            if config.debug:
                links.append((_("Export"), "export_dashboards.py"))
            links.append((_("Edit"), "edit_dashboards.py"))
            footnotelinks(links)
예제 #8
0
 def _show_footnote_links(self):
     edit_url = "../nagvis/"
     footnotelinks([(_("Edit"), edit_url)])
예제 #9
0
파일: views.py 프로젝트: stmps/checkmk
    def show(self):
        dashboard.load_dashboards()

        def render_topic(topic, entries):
            first = True
            for t, title, name, is_view in entries:
                if is_view and config.visible_views and name not in config.visible_views:
                    continue
                if is_view and config.hidden_views and name in config.hidden_views:
                    continue
                if t == topic:
                    if first:
                        html.begin_foldable_container("views",
                                                      topic,
                                                      False,
                                                      topic,
                                                      indent=True)
                        first = False
                    if is_view:
                        bulletlink(
                            title,
                            "view.py?view_name=%s" % name,
                            onclick=
                            "return cmk.sidebar.wato_views_clicked(this)")
                    elif "?name=" in name:
                        bulletlink(title, name)
                    else:
                        bulletlink(
                            title,
                            'dashboard.py?name=%s' % name,
                            onclick=
                            "return cmk.sidebar.wato_views_clicked(this)")

            # TODO: One day pagestypes should handle the complete snapin.
            # for page_type in pagetypes.all_page_types().values():
            #     if issubclass(page_type, pagetypes.PageRenderer):
            #         for t, title, url in page_type.sidebar_links():
            #             if t == topic:
            #                 bulletlink(title, url)

            if not first:  # at least one item rendered
                html.end_foldable_container()

        # TODO: One bright day drop this whole visuals stuff and only use page_types
        page_type_topics = {}
        for page_type in pagetypes.all_page_types().values():
            if issubclass(page_type, pagetypes.PageRenderer):
                for t, title, url in page_type.sidebar_links():
                    page_type_topics.setdefault(t, []).append(
                        (t, title, url, False))

        visuals_topics_with_entries = visuals_by_topic(
            views.get_permitted_views().items() +
            dashboard.permitted_dashboards().items())
        all_topics_with_entries = []
        for topic, entries in visuals_topics_with_entries:
            if topic in page_type_topics:
                entries = entries + page_type_topics[topic]
                del page_type_topics[topic]
            all_topics_with_entries.append((topic, entries))

        all_topics_with_entries += sorted(page_type_topics.items())

        for topic, entries in all_topics_with_entries:
            render_topic(topic, entries)

        links = []
        if config.user.may("general.edit_views"):
            if config.debug:
                links.append((_("Export"), "export_views.py"))
            links.append((_("Edit"), "edit_views.py"))
            footnotelinks(links)