Exemple #1
0
def header(title: str,
           isopen: bool = True,
           table_id: str = "",
           narrow: bool = False,
           css: Optional[str] = None,
           show_more_toggle: bool = False,
           show_more_mode: bool = False) -> None:
    global g_header_open, g_section_open
    if g_header_open:
        end()

    id_ = ensure_str(base64.b64encode(ensure_binary(title)))
    treename = html.form_name or "nform"
    isopen = html.foldable_container_is_open(treename, id_, isopen)

    html.open_table(id_=table_id if table_id else None,
                    class_=[
                        "nform",
                        "narrow" if narrow else None,
                        css if css else None,
                        "open" if isopen else "closed",
                        "more" if show_more_mode else None,
                    ])

    _begin_foldable_nform_container(
        treename=treename,
        id_=id_,
        isopen=isopen,
        title=title,
        show_more_toggle=show_more_toggle,
    )
    html.tr(html.render_td('', colspan=2))
    g_header_open = True
    g_section_open = False
Exemple #2
0
def _begin_foldable_nform_container(
    treename: str,
    id_: str,
    isopen: bool,
    title: str,
    show_more_toggle: bool,
) -> bool:
    isopen = html.foldable_container_is_open(treename, id_, isopen)
    onclick = html.foldable_container_onclick(treename, id_, fetch_url=None)
    img_id = html.foldable_container_img_id(treename, id_)
    container_id = html.foldable_container_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="themes/%s/images/tree_closed.png" % (html.get_theme()),
             align="absbottom")
    html.write_text(title)
    if show_more_toggle:
        html.more_button("foldable_" + id_, dom_levels_up=4)
    html.close_td()
    html.close_tr()
    html.close_thead()
    html.open_tbody(id_=container_id, class_=["open" if isopen else "closed"])

    return isopen
Exemple #3
0
def get_show_more_setting(more_id: str) -> bool:
    if config.user.get_attribute("show_mode") == "enforce_show_more":
        return True

    return html.foldable_container_is_open(
        treename="more_buttons",
        id_=more_id,
        isopen=config.user.get_attribute("show_mode") == "default_show_more")
Exemple #4
0
    def _show_dropdown_area(self, dropdown: PageMenuDropdown) -> None:
        id_ = "menu_%s" % dropdown.name
        show_more = html.foldable_container_is_open("more_buttons", id_, isopen=False)
        html.open_div(class_=["menu", ("more" if show_more else "less")], id_=id_)

        if dropdown.any_advanced_entries:
            html.open_div(class_=["more_container"])
            html.more_button(id_, dom_levels_up=2)
            html.close_div()

        for topic in dropdown.topics:
            if not topic.entries:
                continue  # Do not display empty topics

            self._show_topic(topic)

        html.close_div()
Exemple #5
0
def grouped_row_title(index, group_spec, num_rows, trclass, num_cells):
    is_open = html.foldable_container_is_open("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(html.theme_url("images/tree_closed.png"),
             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