Esempio n. 1
0
    def _major_page(self) -> None:
        html.header(
            self._title(),
            breadcrumb=_release_notes_breadcrumb(),
            page_state=_release_switch(major=True),
        )

        html.open_div(id_="release_title")
        html.h1(escape_html(_("Everything")) + html.render_br() + escape_html(_("monitored")))
        html.img(theme.url("images/tribe29.svg"))
        html.close_div()

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

        html.open_div(id_="release_content")
        for icon, headline, subline in [
            ("release_deploy", _("Deploy in minutes"), _("From 0 to Monitoring in <10min")),
            ("release_scale", _("With unlimited scale"), _("Hundred thousands of hosts")),
            ("release_automated", _("Highly automated"), _("Let Checkmk do the work for you")),
        ]:
            html.open_div(class_="container")
            html.img(theme.url(f"images/{icon}.svg"))
            html.div(headline)
            html.div(subline)
            html.close_div()
        html.close_div()

        html.open_div(id_="release_footer")
        html.span(_("© 2020 tribe29 GmbH. All Rights Reserved."))
        html.a(_("License aggreement"), href="https://checkmk.com/legal.html", target="_blank")
        html.a(_("Imprint"), href="https://checkmk.com/impressum.html", target="_blank")
        html.close_div()
Esempio n. 2
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()
Esempio n. 3
0
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()
Esempio n. 4
0
def _show_graph_html_content(graph_artwork, graph_data_range,
                             graph_render_options) -> None:
    """Render the HTML code of a graph without its container

    That is a canvas object for drawing the actual graph and also legend, buttons, resize handle,
    etc.
    """
    graph_render_options = artwork.add_default_render_options(
        graph_render_options)

    html.open_div(
        class_=[
            "graph", "preview" if graph_render_options["preview"] else None
        ],
        style="font-size: %.1fpt;%s" %
        (graph_render_options["font_size"],
         _graph_padding_styles(graph_render_options)),
    )

    if graph_render_options["show_controls"]:
        _show_graph_add_to_icon_for_popup(graph_artwork, graph_data_range,
                                          graph_render_options)

    v_axis_label = graph_artwork["vertical_axis"]["axis_label"]
    if v_axis_label:
        html.div(v_axis_label, class_="v_axis_label")

    # Add the floating elements
    if graph_render_options[
            "show_graph_time"] and not graph_render_options["preview"]:
        html.div(
            graph_artwork["time_axis"]["title"] or "",
            css=[
                "time", "inline"
                if graph_render_options["show_title"] == "inline" else None
            ],
        )

    if graph_render_options["show_controls"] and graph_render_options[
            "resizable"]:
        html.img(src=theme.url("images/resize_graph.png"), class_="resize")

    _show_html_graph_title(graph_artwork, graph_render_options)
    _show_graph_canvas(graph_render_options)

    # Note: due to "omit_zero_metrics" the graph might not have any curves
    if _graph_legend_enabled(graph_render_options, graph_artwork):
        _show_graph_legend(graph_artwork, graph_render_options)

    model_params_repr = graph_artwork["definition"].get("model_params_repr")
    model_params_display = (graph_artwork["definition"].get(
        "model_params", {}).get("display_model_parametrization"))
    if model_params_repr and model_params_display:
        html.open_div(align="center")
        html.h2(_("Forecast Parametrization"))
        html.write_html(model_params_repr)
        html.close_div()

    html.close_div()
Esempio n. 5
0
 def _validate_icon(self, value, varprefix):
     file_name = value[0]
     browser_url = theme.url("images/icon_%s" % file_name)
     if os.path.exists("%s/share/check_mk/web/htdocs/%s" % (cmk.utils.paths.omd_root, browser_url)) \
        or os.path.exists("%s/share/check_mk/web/htdocs/images/icons/%s" % (cmk.utils.paths.omd_root, file_name)):
         raise MKUserError(
             varprefix,
             _('Your icon conflicts with a Check_MK builtin icon. Please '
               'choose another name for your icon.'))
Esempio n. 6
0
    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);")
Esempio n. 7
0
def render_graph_html_content(graph_artwork, graph_data_range,
                              graph_render_options):
    graph_render_options = artwork.add_default_render_options(
        graph_render_options)

    css = " preview" if graph_render_options["preview"] else ""
    output: RenderOutput = '<div class="graph%s" style="font-size: %.1fpt;%s">' % (
        css, graph_render_options["font_size"],
        _graph_padding_styles(graph_render_options))

    if graph_render_options["show_controls"]:
        output += render_graph_add_to_icon_for_popup(graph_artwork,
                                                     graph_data_range,
                                                     graph_render_options)

    v_axis_label = graph_artwork["vertical_axis"]["axis_label"]
    if v_axis_label:
        output += '<div class=v_axis_label>%s</div>' % v_axis_label

    # Add the floating elements
    if graph_render_options[
            "show_graph_time"] and not graph_render_options["preview"]:
        output += html.render_div(
            graph_artwork["time_axis"]["title"] or "",
            css=[
                "time", "inline"
                if graph_render_options["show_title"] == "inline" else None
            ])

    if graph_render_options["show_controls"] and graph_render_options[
            "resizable"]:
        output += '<img class=resize src="%s">' % theme.url(
            "images/resize_graph.png")

    output += render_html_graph_title(graph_artwork, graph_render_options)
    output += render_graph_canvas(graph_render_options)

    # Note: due to "omit_zero_metrics" the graph might not have any curves
    if show_graph_legend(graph_render_options, graph_artwork):
        output += render_graph_legend(graph_artwork, graph_render_options)

    model_params_repr = graph_artwork["definition"].get("model_params_repr")
    model_params_display = graph_artwork["definition"].get(
        'model_params', {}).get("display_model_parametrization")
    if model_params_repr and model_params_display:
        output += "<div align='center'><h2>Forecast Parametrization</h2>%s</div>" % model_params_repr

    output += '</div>'
    return output
Esempio n. 8
0
    def _show_sidebar_head(self):
        html.open_div(id_="side_header")
        html.open_a(
            href=config.user.start_url or config.start_url,
            target="main",
            title=_("Go to main page"),
        )
        if config.user.get_attribute("nav_hide_icons_title"):
            html.img(theme.url('images/tribe29_icon_min.svg'))
        else:
            html.img(theme.url('images/tribe29_icon.svg'))
        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 config.user.get_attribute("nav_hide_icons_title"):
            html.div(_("Sidebar"))
        html.close_div()
Esempio n. 9
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()
Esempio n. 10
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
Esempio n. 11
0
def foldable_container(
    *,
    treename: str,
    id_: str,
    isopen: bool,
    title: HTMLContent,
    indent: Union[str, None, bool] = True,
    first: bool = False,
    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,
            class_=[
                "treeangle",
                "title",
                # Although foldable_sidebar is given via the argument icon it should not be
                # displayed as big as an icon.
                "icon" if icon != "foldable_sidebar" else None,
                "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()
Esempio n. 12
0
 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()
Esempio n. 13
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: Optional[str] = "assumed"
            effective_state = tree[1]
        else:
            addclass = None
            effective_state = tree[0]

        class_: List[Optional[str]] = [
            "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=config.escape_plugin_output
        )
        if output:
            output = html.render_b(HTML("&diams;"), class_="bullet") + output
        else:
            output = HTML()

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