コード例 #1
0
ファイル: forms.py プロジェクト: LinuxHaus/checkmk
def _table_head(
    treename: str,
    id_: str,
    isopen: bool,
    title: str,
    show_more_toggle: bool,
    help_text: Union[str, HTML, None] = None,
) -> None:
    onclick = foldable_container_onclick(treename, id_, fetch_url=None)
    img_id = foldable_container_img_id(treename, id_)

    html.open_thead()
    html.open_tr(class_="heading")
    html.open_td(id_="nform.%s.%s" % (treename, id_), onclick=onclick, colspan=2)
    html.img(
        id_=img_id,
        class_=["treeangle", "nform", "open" if isopen else "closed"],
        src=theme.url("images/tree_closed.svg"),
        align="absbottom",
    )
    html.write_text(title)
    html.help(help_text)
    if show_more_toggle:
        html.more_button("foldable_" + id_, dom_levels_up=4, with_text=True)
    html.close_td()
    html.close_tr()
    html.close_thead()
コード例 #2
0
ファイル: speedometer.py プロジェクト: LinuxHaus/checkmk
    def show(self):
        html.open_div(class_="speedometer")
        html.img(theme.url("images/speedometer.svg"), id_="speedometerbg")
        html.canvas("", width=str(snapin_width), height="146", id_="speedometer")
        html.close_div()

        html.javascript("cmk.sidebar.speedometer_show_speed(0, 0, 0);")
コード例 #3
0
ファイル: werks.py プロジェクト: LinuxHaus/checkmk
    def page(self) -> cmk.gui.pages.PageResult:
        breadcrumb = make_simple_page_breadcrumb(
            mega_menu_registry["help_links"], _("Info"))
        make_header(
            html,
            self._title(),
            breadcrumb=breadcrumb,
        )

        html.open_div(id_="info_title")
        html.h1(_("Your monitoring machine"))
        html.a(
            HTMLWriter.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.") % (
                HTMLWriter.render_a(
                    _("website"), "https://checkmk.com", target="_blank"),
                HTMLWriter.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()
コード例 #4
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(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()
コード例 #5
0
    def page(self) -> None:
        assert user.id is not None

        html.render_headfoot = False
        html.add_body_css_class("login")
        html.add_body_css_class("two_factor")
        make_header(html,
                    _("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)
コード例 #6
0
ファイル: __init__.py プロジェクト: LinuxHaus/checkmk
def _render_header_icon() -> None:
    if user.get_attribute("nav_hide_icons_title"):
        if theme.has_custom_logo():
            html.img(theme.detect_icon_path(icon_name="logo", prefix="mk-"),
                     class_="custom")
        else:
            html.img(
                theme.detect_icon_path(icon_name="icon_min",
                                       prefix="tribe29_"))
    else:
        if theme.has_custom_logo():
            html.img(theme.detect_icon_path(icon_name="logo", prefix="mk-"))
        else:
            html.img(
                theme.detect_icon_path(icon_name="icon", prefix="tribe29_"))
コード例 #7
0
def grouped_row_title(index, group_spec, num_rows, trclass, num_cells):
    is_open = user.get_tree_state("grouped_rows", index, False)
    html.open_tr(class_=[
        "data", "grouped_row_header", "closed" if not is_open else "",
        "%s0" % trclass
    ])
    html.open_td(
        colspan=num_cells,
        onclick="cmk.views.toggle_grouped_rows('grouped_rows', '%s', this, %d)"
        % (index, num_rows),
    )

    html.img(
        theme.url("images/tree_closed.svg"),
        align="absbottom",
        class_=["treeangle", "nform", "open" if is_open else "closed"],
    )
    html.write_text("%s (%d)" % (group_spec["title"], num_rows))

    html.close_td()
    html.close_tr()

    return not is_open
コード例 #8
0
ファイル: mobile.py プロジェクト: LinuxHaus/checkmk
def page_login() -> None:
    title = _("Checkmk Mobile")
    mobile_html_head(title)
    jqm_page_header(title, id_="login")
    html.div(_("Welcome to Checkmk Mobile."), id_="loginhead")

    html.begin_form("login", method="POST", add_transid=False)
    # Keep information about original target URL
    default_origtarget = (
        "index.py" if requested_file_name(request) in ["login", "logout"] else makeuri(request, [])
    )
    origtarget = request.get_url_input("_origtarget", default_origtarget)
    html.hidden_field("_origtarget", escaping.escape_attribute(origtarget))

    html.text_input("_username", label=_("Username:"******"username", id_="input_user")
    html.password_input(
        "_password",
        size=None,
        label=_("Password:"******"current-password",
        id_="input_pass",
    )
    html.br()
    html.button("_login", _("Login"))
    html.set_focus("_username")
    html.end_form()
    html.open_div(id_="loginfoot")
    html.img("themes/facelift/images/logo_cmk_small.png", class_="logomk")
    html.div(
        HTML(_('&copy; <a target="_blank" href="https://checkmk.com">tribe29 GmbH</a>')),
        class_="copyright",
    )
    html.close_div()  # close content-div
    html.close_div()
    html.close_div()  # close page-div
    mobile_html_foot()
コード例 #9
0
def foldable_container(
    *,
    treename: str,
    id_: str,
    isopen: bool,
    title: HTMLContent,
    indent: Union[str, None, bool] = True,
    icon: Optional[str] = None,
    fetch_url: Optional[str] = None,
    title_url: Optional[str] = None,
    title_target: Optional[str] = None,
    padding: int = 15,
    save_state: bool = True,
) -> Iterator[bool]:
    isopen = user.get_tree_state(treename, id_, isopen)
    onclick = foldable_container_onclick(treename, id_, fetch_url, save_state)
    img_id = foldable_container_img_id(treename, id_)
    container_id = foldable_container_id(treename, id_)

    html.open_div(class_=["foldable", "open" if isopen else "closed"])
    html.open_div(class_="foldable_header",
                  onclick=None if title_url else onclick)

    if isinstance(title, HTML):  # custom HTML code
        html.write_text(title)

    else:
        html.open_b(class_=["treeangle", "title"])

        if title_url:
            html.a(title, href=title_url, target=title_target)
        else:
            html.write_text(title)
        html.close_b()

    if icon:
        html.img(
            id_=img_id,
            # Although foldable_sidebar is given via the argument icon it should not be displayed as big as an icon.
            class_=(["treeangle", "title"] +
                    (["icon"] if icon != "foldable_sidebar" else []) +
                    ["open" if isopen else "closed"]),
            src=theme.detect_icon_path(icon, "icon_"),
            onclick=onclick if title_url else None,
        )
    else:
        html.img(
            id_=img_id,
            class_=["treeangle", "open" if isopen else "closed"],
            src=theme.url("images/tree_closed.svg"),
            onclick=onclick if title_url else None,
        )

    html.close_div()

    indent_style = "padding-left: %dpx; " % (padding if indent else 0)
    if indent == "form":
        html.close_td()
        html.close_tr()
        html.close_table()
        indent_style += "margin: 0; "
    html.open_ul(id_=container_id,
                 class_=["treeangle", "open" if isopen else "closed"],
                 style=indent_style)

    yield isopen

    html.close_ul()
    html.close_div()
コード例 #10
0
ファイル: logo.py プロジェクト: LinuxHaus/checkmk
 def show(self):
     html.open_a(href="https://checkmk.com/", target="_blank")
     html.img(theme.url("images/check_mk.trans.120.png"),
              style="margin-right: 30px;")
     html.close_a()
コード例 #11
0
    def _show_node(self, tree, show_host, mousecode=None, img_class=None):
        # Check if we have an assumed state: comparing assumed state (tree[1]) with state (tree[0])
        if tree[1] and tree[0] != tree[1]:
            addclass = ["assumed"]
            effective_state = tree[1]
        else:
            addclass = []
            effective_state = tree[0]

        class_ = [
            "content",
            "state",
            "state%d" % (effective_state["state"]
                         if effective_state["state"] is not None else -1),
        ] + addclass
        html.open_span(class_=class_)
        html.write_text(self._render_bi_state(effective_state["state"]))
        html.close_span()

        if mousecode:
            if img_class:
                html.img(
                    src=theme.url("images/tree_closed.svg"),
                    class_=["treeangle", img_class],
                    onclick=mousecode,
                )

            html.open_span(class_=["content", "name"])

        icon_name, icon_title = None, None
        if tree[0]["in_downtime"] == 2:
            icon_name = "downtime"
            icon_title = _(
                "This element is currently in a scheduled downtime.")

        elif tree[0]["in_downtime"] == 1:
            # only display host downtime if the service has no own downtime
            icon_name = "derived_downtime"
            icon_title = _(
                "One of the subelements is in a scheduled downtime.")

        if tree[0]["acknowledged"]:
            icon_name = "ack"
            icon_title = _("This problem has been acknowledged.")

        if not tree[0]["in_service_period"]:
            icon_name = "outof_serviceperiod"
            icon_title = _(
                "This element is currently not in its service period.")

        if icon_name and icon_title:
            html.icon(icon_name, title=icon_title, class_=["icon", "bi"])

        yield

        if mousecode:
            if str(effective_state["state"]) in tree[2].get(
                    "state_messages", {}):
                html.b(HTML("&diams;"), class_="bullet")
                html.write_text(tree[2]["state_messages"][str(
                    effective_state["state"])])

            html.close_span()

        output: HTML = cmk.gui.view_utils.format_plugin_output(
            effective_state["output"],
            shall_escape=active_config.escape_plugin_output)
        if output:
            output = HTMLWriter.render_b(HTML("&diams;"),
                                         class_="bullet") + output
        else:
            output = HTML()

        html.span(output, class_=["content", "output"])