Пример #1
0
def jqm_page_navfooter(items, current, page_id):
    html.close_div()  # close content
    html.open_div(**{"data-role": "footer", "data-position": "fixed"})
    html.open_div(**{"data-role": "navbar"})
    html.open_ul()

    for href, title, icon, custom_css in items:
        href = html.makeuri([("page", href), ("search", "Search")])
        if custom_css is False:
            custom_css = ""
        if current == href:
            custom_css += ' ui-state-persist ui-btn-active'
        else:
            html.open_li()
            html.open_a(href=href,
                        class_=custom_css,
                        **{
                            "data-transition": "slide",
                            "data-icon": icon,
                            "data-iconpos": "bottom"
                        })
            html.write(title)
            html.close_a()
            html.close_li()
    html.close_ul()
    html.close_div()
    html.close_div()
    html.close_div()  # close page-div
Пример #2
0
 def _show_add_snapin_button(self) -> None:
     html.open_div(id_="add_snapin")
     html.open_a(href=makeuri_contextless(request, [], filename="sidebar_add_snapin.py"),
                 target="main")
     html.icon("add", title=_("Add snapins to your sidebar"))
     html.close_a()
     html.close_div()
Пример #3
0
 def _show_link(self, url: str, onclick: Optional[str],
                target: Optional[str], icon_name: Optional[str],
                title: str) -> None:
     html.open_a(href=url, onclick=onclick, target=target)
     html.icon(title=None, icon=icon_name or "trans")
     html.span(title)
     html.close_a()
Пример #4
0
def jqm_page_navfooter(items: NavigationBar, current: str,
                       page_id: str) -> None:
    html.close_div()  # close content
    html.open_div(
        **{
            "data-role": "footer",
            "data-position": "fixed",
            "data-tap-toggle": "false",
            "data-hide-during-focus": "",
        })
    html.open_div(**{"data-role": "navbar"})
    html.open_ul()

    for href, title, icon, custom_css in items:
        href = makeuri(request, [("page", href), ("search", "Search")])
        if current == href:
            custom_css += ' ui-state-persist ui-btn-active'
        else:
            html.open_li()
            html.open_a(href=href,
                        class_=custom_css,
                        **{
                            "data-transition": "slide",
                            "data-icon": icon,
                            "data-iconpos": "bottom",
                        })
            html.write(title)
            html.close_a()
            html.close_li()
    html.close_ul()
    html.close_div()
    html.close_div()
    html.close_div()  # close page-div
Пример #5
0
    def _sidebar_head(self):
        html.open_div(id_="side_header")
        html.div('', id_="side_fold")
        html.open_a(href=config.user.get_attribute("start_url")
                    or config.start_url,
                    target="main",
                    title=_("Go to main overview"))
        html.div("", id_="side_bg")

        if config.sidebar_show_version_in_sidebar:
            html.open_div(id_="side_version")
            html.open_a(href="version.py",
                        target="main",
                        title=_("Open release notes"))
            html.write(self._get_check_mk_edition_title())
            html.br()
            html.write(cmk_version.__version__)

            if werks.may_acknowledge():
                num_unacknowledged_werks = werks.num_unacknowledged_incompatible_werks(
                )
                if num_unacknowledged_werks:
                    html.span(num_unacknowledged_werks,
                              class_="unack_werks",
                              title=_("%d unacknowledged incompatible werks") %
                              num_unacknowledged_werks)

        html.close_a()
        html.close_div()
        html.close_a()
        html.close_div()
Пример #6
0
    def page(self) -> None:
        assert user.id is not None

        html.set_render_headfoot(False)
        html.add_body_css_class("login")
        html.add_body_css_class("two_factor")
        html.header(_("Two-factor authentication"), Breadcrumb(), javascripts=[])

        html.open_div(id_="login")

        html.open_div(id_="login_window")

        html.open_a(href="https://checkmk.com")
        html.img(
            src=theme.detect_icon_path(icon_name="logo", prefix="mk-"),
            id_="logo",
            class_="custom" if theme.has_custom_logo() else None,
        )
        html.close_a()

        if not is_two_factor_login_enabled(user.id):
            raise MKGeneralException(_("Two-factor authentication not enabled"))

        html.begin_form(
            "two_factor_login", method="POST", add_transid=False, action="user_login_two_factor.py"
        )
        html.prevent_password_auto_completion()
        html.hidden_field(
            "_origtarget", origtarget := request.get_url_input("_origtarget", "index.py")
        )

        if backup_code := request.get_ascii_input("_backup_code"):
            if is_two_factor_backup_code_valid(user.id, backup_code):
                set_two_factor_completed()
                raise HTTPRedirect(origtarget)
Пример #7
0
 def _render_result(self, result):
     html.open_li()
     html.open_a(href=result.url,
                 target="main",
                 onclick="cmk.popup_menu.close_popup()")
     html.write_text(result.title)
     html.close_a()
     html.close_li()
Пример #8
0
 def _iconlink(self, text, url, icon):
     html.open_a(class_=["iconlink", "link"], target="main", href=url)
     html.icon(icon="/webconf/images/icon_%s.png" % icon,
               title=None,
               cssclass="inline")
     html.write(text)
     html.close_a()
     html.br()
Пример #9
0
 def _show_link(self, entry: PageMenuEntry, item: ABCPageMenuItem, url: Optional[str],
                onclick: Optional[str]) -> None:
     html.open_a(href=url,
                 onclick=onclick,
                 id_=("menu_suggestion_%s" % entry.name if entry.name else None))
     html.icon(entry.icon_name or "trans")
     html.write_text(entry.shortcut_title or entry.title)
     html.close_a()
Пример #10
0
    def page(self) -> cmk.gui.pages.PageResult:
        breadcrumb = make_simple_page_breadcrumb(
            mega_menu_registry["help_links"], _("Info"))
        html.header(
            self._title(),
            breadcrumb=breadcrumb,
        )

        html.open_div(id_="info_title")
        html.h1(_("Your monitoring machine"))
        html.a(html.render_img(theme.url("images/tribe29.svg")),
               "https://tribe29.com",
               target="_blank")
        html.close_div()

        html.div(None, id_="info_underline")

        html.open_div(id_="info_intro_text")
        html.span(_("Open. Effective. Awesome."))
        html.span(
            _("May we present? Monitoring as it's supposed to be: "
              "incredibly quick to install, infinetely scalable, highly customizable and "
              "designed for admins."))
        html.span(
            _("Visit our %s to learn more about Checkmk and about the %s.") % (
                html.render_a(
                    _("website"), "https://checkmk.com", target="_blank"),
                html.render_a(
                    _("latest version"),
                    "https://checkmk.com/product/latest-version",
                    target="_blank",
                ),
            ))
        html.close_div()

        version_major_minor = re.sub(r".\d+$", "",
                                     Version(__version__).version_base)
        if version_major_minor:
            current_version_link = "https://checkmk.com/product/checkmk-%s" % version_major_minor
        else:
            current_version_link = "https://checkmk.com/product/latest-version"

        html.open_div(id="info_image")
        html.open_a(href=current_version_link, target="_blank")
        html.img(theme.url("images/monitoring-machine.png"))
        html.close_a()
        html.close_div()

        html.close_div()

        html.open_div(id_="info_footer")
        html.span(
            _("© %s tribe29 GmbH. All Rights Reserved.") % time.strftime("%Y"))
        html.a(_("License agreement"),
               href="https://checkmk.com/legal.html",
               target="_blank")
        html.close_div()
Пример #11
0
 def _render_result(self, result, hidden=False):
     html.open_li()
     html.open_a(href=result.url,
                 target="main",
                 onclick="cmk.popup_menu.close_popup()",
                 class_="hidden" if hidden else "")
     html.write_text(result.title)
     html.close_a()
     html.close_li()
Пример #12
0
 def show(self, page_state: PageState) -> None:
     html.open_div(class_=self._get_css_classes(page_state), title=page_state.tooltip_text)
     if page_state.url:
         html.open_a(page_state.url)
         self._show_content(page_state)
         html.close_a()
     else:
         self._show_content(page_state)
     html.close_div()
Пример #13
0
 def render_addto_popup_entry(cls, type_name, name, title):
     html.open_li()
     html.open_a(
         href="javascript:void(0)",
         onclick="cmk.popup_menu.pagetype_add_to_container('%s', '%s');cmk.utils.reload_sidebar();"
         % (type_name, name))
     html.render_icon(type_name)
     html.write_text(title)
     html.close_a()
     html.close_li()
Пример #14
0
def render_availability_table(group_title, availability_table, what, avoptions):
    av_table = availability.layout_availability_table(what, group_title, availability_table,
                                                      avoptions)

    # TODO: If summary line is activated, then sorting should now move that line to the
    # top. It should also stay at the bottom. This would require an extension to the
    # table.py module.
    with table_element("av_items",
                       av_table["title"],
                       css="availability",
                       searchable=False,
                       limit=None,
                       omit_headers="omit_headers" in avoptions["labelling"]) as table:

        show_urls, show_timeline = False, False
        for row in av_table["rows"]:
            table.row()

            # Column with icons
            timeline_url = None
            if row["urls"]:
                show_urls = True
                table.cell("", css="buttons")
                for image, tooltip, url in row["urls"]:
                    html.icon_button(url, tooltip, image)
                    if image == "timeline":
                        timeline_url = url

            # Column with host/service or aggregate name
            for title, (name, url) in zip(av_table["object_titles"], row["object"]):
                table.cell(title, html.render_a(name, url))

            if "timeline" in row:
                show_timeline = True
                table.cell(_("Timeline"), css="timeline")
                html.open_a(href=timeline_url)
                render_timeline_bar(row["timeline"], "inline")
                html.close_a()

            # Columns with the actual availability data
            for (title, help_txt), (text, css) in zip(av_table["cell_titles"], row["cells"]):
                table.cell(title, text, css=css, help_txt=help_txt)

        if "summary" in av_table:
            table.row(css="summary", fixed=True)
            if show_urls:
                table.cell("", "")  # Empty cell in URLs column
            table.cell("", _("Summary"), css="heading")
            for _x in xrange(1, len(av_table["object_titles"])):
                table.cell("", "")  # empty cells, of more object titles than one
            if show_timeline:
                table.cell("", "")

            for (title, help_txt), (text, css) in zip(av_table["cell_titles"], av_table["summary"]):
                table.cell(title, text, css="heading " + css, help_txt=help_txt)
Пример #15
0
 def _show_filter_bar(self, filter_bar: PageMenuEntry) -> None:
     html.open_td(class_="filter_bar")
     html.open_a(href="javascript:void(0)",
                 onclick="cmk.page_menu.toggle_popup(%s)" %
                 json.dumps("popup_%s" % filter_bar.name),
                 id_=("menu_suggestion_%s" %
                      filter_bar.name if filter_bar.name else None))
     html.h2(filter_bar.title)
     html.icon(filter_bar.icon_name)
     html.close_a()
     html.close_td()
Пример #16
0
    def _show_shortcut_bar(self) -> None:
        html.open_div(class_="shortcuts")
        for item in _shortcut_menu_items():
            if item.permission_name and not config.user.may(item.permission_name):
                continue

            html.open_a(href=item.url, target=item.target_name)
            html.icon(item.icon_name)
            html.div(item.title)
            html.close_a()
        html.close_div()
Пример #17
0
 def _show_topic_title(self, menu_id: str, topic_id: str, topic: TopicMenuTopic) -> None:
     html.open_h2()
     html.open_a(class_="show_all_topics",
                 href="",
                 onclick="cmk.popup_menu.mega_menu_show_all_topics('%s')" % topic_id)
     html.icon(icon="collapse_arrow", title=_("Show all %s topics") % menu_id)
     html.close_a()
     if not config.user.get_attribute("icons_per_item") and topic.icon:
         html.icon(topic.icon)
     html.span(topic.title)
     html.close_h2()
Пример #18
0
 def _show_items(self, topic_id: str, topic: TopicMenuTopic) -> None:
     html.open_ul()
     for item in topic.items:
         self._show_item(item)
     html.open_li(class_="show_all_items")
     html.open_a(href="", onclick="cmk.popup_menu.mega_menu_show_all_items('%s')" % topic_id)
     if config.user.get_attribute("icons_per_item"):
         html.icon("trans")
     html.write_text(_("Show all"))
     html.close_a()
     html.close_li()
     html.close_ul()
Пример #19
0
 def _show_item(self, item: TopicMenuItem) -> None:
     html.open_li(class_="show_more_mode" if item.is_show_more else None)
     html.open_a(
         href=item.url,
         target=item.target,
         onclick="cmk.popup_menu.close_popup()",
     )
     if config.user.get_attribute("icons_per_item"):
         html.icon(item.icon or "trans")
     self._show_item_title(item)
     html.close_a()
     html.close_li()
Пример #20
0
 def _show_item(self, item: TopicMenuItem) -> None:
     html.open_li(class_="advanced" if item.is_advanced else None)
     html.open_a(
         href=item.url,
         target="main",
         onclick="cmk.popup_menu.close_popup()",
     )
     if config.user.get_attribute("icons_per_item") and item.icon_name:
         html.icon(title=None, icon=item.icon_name)
     html.write_text(item.title)
     html.close_a()
     html.close_li()
Пример #21
0
 def _show_item(self, item: TopicMenuItem) -> None:
     html.open_li(class_="show_more_mode" if item.is_show_more else None)
     html.open_a(
         href=item.url,
         target="main",
         onclick="cmk.popup_menu.close_popup()",
     )
     if config.user.get_attribute("icons_per_item"):
         html.icon(item.icon_name or "trans", emblem=item.emblem)
     html.write_text(item.title)
     html.close_a()
     html.close_li()
Пример #22
0
    def show(self):
        html.open_div(class_="mainmenu")
        for item in self._items:
            if not item.may_see():
                continue

            html.open_a(href=item.get_url(), onfocus="if (this.blur) this.blur();")
            html.icon(item.icon, item.title)
            html.div(item.title, class_="title")
            html.div(item.description, class_="subtitle")
            html.close_a()

        html.close_div()
Пример #23
0
    def _show_diagnose_output(self):
        if not request.var("_try"):
            html.show_message(
                _(
                    "You can diagnose the connection to a specific host using this dialog. "
                    "You can either test whether your current configuration is still working "
                    "or investigate in which ways a host can be reached. Simply configure the "
                    "connection options you like to try on the right side of the screen and "
                    'press the "Test" button. The results will be displayed here.'
                )
            )
            return

        if user_errors:
            html.show_user_errors()
            return

        # TODO: Insert any vs_host valuespec validation
        #       These tests can be called with invalid valuespec settings...
        # TODO: Replace hard coded icon paths with dynamic ones to old or new theme
        for ident, title in ModeDiagHost.diag_host_tests():
            html.h3(title)
            html.open_table(class_=["data", "test"])
            html.open_tr(class_=["data", "odd0"])

            html.open_td(class_="icons")
            html.open_div()
            html.icon("reload", id_="%s_img" % ident)
            html.open_a(href="")
            html.icon(
                "reload", title=_("Retry this test"), cssclass="retry", id_="%s_retry" % ident
            )
            html.close_a()
            html.close_div()
            html.close_td()

            html.open_td()
            html.div("", class_="log", id="%s_log" % ident)
            html.close_td()

            html.close_tr()
            html.close_table()
            html.javascript(
                "cmk.host_diagnose.start_test(%s, %s, %s)"
                % (
                    json.dumps(ident),
                    json.dumps(self._hostname),
                    json.dumps(transactions.fresh_transid()),
                )
            )
Пример #24
0
 def _show_topic_title(self, menu_ident: str, topic_id: str,
                       topic: TopicMenuTopic) -> None:
     html.open_h2()
     html.open_a(class_="show_all_topics",
                 href="",
                 onclick="cmk.popup_menu.mega_menu_show_all_topics('%s')" %
                 topic_id)
     html.icon(title=_("Show all %s topics") % menu_ident,
               icon="collapse_arrow")
     html.close_a()
     if topic.icon_name:
         html.icon(title=None, icon=topic.icon_name)
     html.span(topic.title)
     html.close_h2()
Пример #25
0
def jqm_page_index_topic_renderer(topic: str, items: Items) -> None:
    has_items_for_topic = any(i for i in items if i[0] == topic)
    if not has_items_for_topic:
        return

    html.p(topic)
    html.open_ul(**{"data-role": "listview", "data-inset": "true"})
    for top, href, title in items:
        if top == topic:
            html.open_li()
            html.open_a(href=href, **{"data-ajax": "false", "data-transition": "flip"})
            html.write_html(HTML(title))
            html.close_a()
            html.close_li()
    html.close_ul()
Пример #26
0
    def _show_shortcut_bar(self) -> None:
        html.open_div(class_="shortcuts")
        for item in _shortcut_menu_items():
            if item.permission_name and not config.user.may(
                    item.permission_name):
                continue

            html.open_a(
                href=item.url,
                target=item.target_name,
                class_="min"
                if config.user.get_attribute("nav_hide_icons_title") else None)
            html.icon(item.icon_name)
            html.div(item.title)
            html.close_a()
        html.close_div()
Пример #27
0
    def show(self):
        html.open_table(class_="dashlet_overview")
        html.open_tr()
        html.open_td(valign="top")
        html.open_a(href="https://checkmk.com/")
        html.img(html.theme_url("images/check_mk.trans.120.png"), style="margin-right: 30px;")
        html.close_a()
        html.close_td()

        html.open_td()
        html.h2("CheckMK")
        html.write_text(
            _('Welcome to Checkmk. If you want to learn more about Checkmk, please visit '
              'our <a href="https://checkmk.com/" target="_blank">user manual</a>.'))
        html.close_td()

        html.close_tr()
        html.close_table()
Пример #28
0
    def _show_sidebar_head(self):
        html.open_div(id_="side_header")
        html.open_a(href=config.user.get_attribute("start_url") or config.start_url,
                    target="main",
                    title=_("Go to main overview"))
        html.div("", id_="side_bg")
        html.close_a()
        html.close_div()

        MainMenuRenderer().show()

        html.open_div(id_="side_fold",
                      title=_("Toggle the sidebar"),
                      onclick="cmk.sidebar.toggle_sidebar()")
        html.icon("sidebar_folded", class_="folded")
        html.icon("sidebar")
        html.div(_("Sidebar"))
        html.close_div()
Пример #29
0
    def _show_sidebar_head(self):
        html.open_div(id_="side_header")
        html.open_a(
            href=user.start_url or config.start_url,
            target="main",
            title=_("Go to main page"),
        )
        _render_header_icon()
        html.close_a()
        html.close_div()

        MainMenuRenderer().show()

        html.open_div(id_="side_fold",
                      title=_("Toggle the sidebar"),
                      onclick="cmk.sidebar.toggle_sidebar()")
        html.icon("sidebar_folded", class_="folded")
        html.icon("sidebar")
        if not user.get_attribute("nav_hide_icons_title"):
            html.div(_("Sidebar"))
        html.close_div()
Пример #30
0
    def show(self):
        html.open_table(class_="dashlet_overview")
        html.open_tr()
        html.open_td(valign="top")
        html.open_a(href="https://mathias-kettner.com/check_mk.html")
        html.img(html.theme_url("images/check_mk.trans.120.png"),
                 style="margin-right: 30px;")
        html.close_a()
        html.close_td()

        html.open_td()
        html.h2("Check_MK Multisite")
        html.write_html(
            'Welcome to Check_MK Multisite. If you want to learn more about Multisite, please visit '
            'our <a href="https://mathias-kettner.com/checkmk_multisite.html">online documentation</a>. '
            'Multisite is part of <a href="https://mathias-kettner.com/check_mk.html">Check_MK</a> - an Open Source '
            'project by <a href="https://mathias-kettner.com">Mathias Kettner</a>.'
        )
        html.close_td()

        html.close_tr()
        html.close_table()