Ejemplo n.º 1
0
    def _show_table(self, api_request):
        html.open_table(class_="allhosts")
        html.open_tbody()

        for map_cfg in api_request["maps"]:
            html.open_tr()
            html.open_td()
            html.div(
                "",
                class_=[
                    "statebullet",
                    self._state_class(map_cfg),
                    self._sub_state_class(map_cfg),
                    self._stale_class(map_cfg),
                ],
                title=self._state_title(map_cfg),
            )
            html.a(map_cfg["alias"],
                   href=map_cfg["url"],
                   class_="link",
                   target="main")
            html.close_td()
            html.close_tr()

        html.close_tbody()
        html.close_table()
Ejemplo n.º 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
Ejemplo n.º 3
0
def header(
    title: str,
    isopen: bool = True,
    table_id: str = "",
    narrow: bool = False,
    css: Optional[str] = None,
    show_table_head: bool = True,
    show_more_toggle: bool = False,
    show_more_mode: bool = False,
    help_text: Union[str, HTML, None] = None,
) -> None:
    global g_header_open, g_section_open
    if g_header_open:
        end()

    id_ = base64.b64encode(title.encode()).decode()
    treename = html.form_name or "nform"
    isopen = user.get_tree_state(treename, id_, isopen)
    container_id = foldable_container_id(treename, id_)

    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 user.get_show_more_setting("foldable_%s" % id_)
            or show_more_mode else None,
        ],
    )

    if show_table_head:
        _table_head(
            treename=treename,
            id_=id_,
            isopen=isopen,
            title=title,
            show_more_toggle=show_more_toggle,
            help_text=help_text,
        )

    html.open_tbody(id_=container_id, class_=["open" if isopen else "closed"])
    html.tr(html.render_td("", colspan=2))
    g_header_open = True
    g_section_open = False
Ejemplo n.º 4
0
def header(title: str,
           isopen: bool = True,
           table_id: str = "",
           narrow: bool = False,
           css: Optional[str] = None,
           show_table_head: bool = True,
           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)
    container_id = html.foldable_container_id(treename, id_)

    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,
                    ])

    if show_table_head:
        _table_head(
            treename=treename,
            id_=id_,
            isopen=isopen,
            title=title,
            show_more_toggle=show_more_toggle,
        )

    html.open_tbody(id_=container_id, class_=["open" if isopen else "closed"])
    html.tr(html.render_td('', colspan=2))
    g_header_open = True
    g_section_open = False