Exemplo n.º 1
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.a(title,
                   href=href,
                   **{
                       "data-ajax": "false",
                       "data-transition": "flip"
                   })
            html.close_li()
    html.close_ul()
Exemplo n.º 2
0
def render_mobile_list(rows, view, group_cells, cells, num_columns,
                       show_checkboxes):
    if not html.mobile:
        html.show_error(_("This view can only be used in mobile mode."))
        return

    # Force relative timestamp always. This saves space.
    painter_options = PainterOptions.get_instance()
    painter_options.set("ts_format", "rel")

    html.open_ul(class_="mobilelist", **{"data-role": "listview"})

    # Paint data rows
    for row in rows:
        html.open_li()
        rendered_cells = [cell.render(row) for cell in cells]
        if rendered_cells:  # First cell (assumedly state) is left
            rendered_class, rendered_content = rendered_cells[0]
            html.open_p(class_=["ui-li-aside", "ui-li-desc", rendered_class])
            html.write(rendered_content)
            html.close_p()

            if len(rendered_cells) > 1:
                content = HTML(" · ").join([
                    rendered_cell[1]
                    for rendered_cell in rendered_cells[1:num_columns + 1]
                ])
                html.h3(content)

                for rendered_cell, cell in zip(
                        rendered_cells[num_columns + 1:],
                        cells[num_columns + 1:]):
                    rendered_class, rendered_content = rendered_cell
                    html.open_p(class_="ui-li-desc")
                    cell.paint_as_header()
                    html.write_text(': ')
                    html.open_span(class_=rendered_class)
                    html.write(rendered_content)
                    html.close_span()
                    html.close_p()

        html.close_li()
    html.close_ul()
    html.javascript('$("ul.mobilelist a").attr("data-ajax", "false");')
Exemplo n.º 3
0
Arquivo: bi.py Projeto: dnlldl/checkmk
    def _show_subtree(self, tree, path, show_host):
        if self._is_leaf(tree):
            self._show_leaf(tree, show_host)
            return

        html.open_span(class_="title")

        is_empty = len(tree[3]) == 0
        if is_empty:
            mc = None
        else:
            mc = self._get_mousecode(path)

        css_class = "open" if self._is_open(path) else "closed"

        with self._show_node(tree, show_host, mousecode=mc, img_class=css_class):
            if tree[2].get('icon'):
                html.write(html.render_icon(tree[2]['icon']))
                html.write(" ")

            if tree[2].get("docu_url"):
                html.icon_button(tree[2]["docu_url"],
                                 _("Context information about this rule"),
                                 "url",
                                 target="_blank")
                html.write(" ")

            html.write_text(tree[2]["title"])

        if not is_empty:
            html.open_ul(id_="%d:%s" % (self._expansion_level or 0, self._path_id(path)),
                         class_=["subtree", css_class])

            if not self._omit_content(path):
                for node in tree[3]:
                    if not node[2].get("hidden"):
                        new_path = path + [node[2]["title"]]
                        html.open_li()
                        self._show_subtree(node, new_path, show_host)
                        html.close_li()

            html.close_ul()

        html.close_span()
Exemplo n.º 4
0
 def _show_tree_nodes(self, maps, children):
     for map_name, map_cfg in maps.iteritems():
         html.open_li()
         if map_name in children:
             html.begin_foldable_container(treename="nagvis",
                                           id_=map_name,
                                           isopen=False,
                                           title=map_cfg["alias"],
                                           title_url=map_cfg["url"],
                                           title_target="main",
                                           indent=False)
             self._show_tree_nodes(children[map_name], children)
             html.end_foldable_container()
         else:
             html.a(map_cfg["alias"],
                    href=map_cfg["url"],
                    target="main",
                    class_="link")
         html.close_li()
Exemplo n.º 5
0
def _show_topic(treename: str, topic: TopicMenuTopic, show_item_icons: bool) -> None:
    if not topic.items:
        return

    html.begin_foldable_container(treename=treename,
                                  id_=topic.name,
                                  isopen=False,
                                  title=topic.title,
                                  indent=True)

    for item in topic.items:
        if show_item_icons:
            html.open_li(class_="sidebar")
            iconlink(item.title, item.url, item.icon_name)
            html.close_li()
        else:
            bulletlink(item.title, item.url, onclick="return cmk.sidebar.wato_views_clicked(this)")

    html.end_foldable_container()
Exemplo n.º 6
0
    def _show_main_menu_content(self) -> None:
        html.open_li()
        html.popup_trigger(
            html.render_icon("main_search") + html.render_div(_("Search")),
            "mega_menu_search",
            method=MethodInline(self._get_search_menu_content()),
        )
        html.close_li()

        for menu_item in self._get_main_menu_items():
            html.open_li()
            html.popup_trigger(
                html.render_icon(menu_item.icon_name) +
                html.render_div(menu_item.title),
                ident="mega_menu_" + menu_item.name,
                method=MethodInline(self._get_mega_menu_content(menu_item)),
                cssclass=menu_item.name,
            )
            html.close_li()
Exemplo n.º 7
0
def _show_aux_tag_used_by_tags(tags: Set[cmk.utils.tags.GroupedTag]) -> None:
    if not tags:
        return

    html.open_ul()
    html.open_li()
    builtin_config = cmk.utils.tags.BuiltinTagConfig()
    for index, tag in enumerate(sorted(tags, key=lambda t: t.choice_title)):
        if index > 0:
            html.write_text(", ")

        # Builtin tag groups can not be edited
        if builtin_config.tag_group_exists(tag.group.id):
            html.write_text(_u(tag.choice_title))
        else:
            edit_url = watolib.folder_preserving_link([("mode", "edit_tag"),
                                                       ("edit", tag.group.id)])
            html.a(_u(tag.choice_title), href=edit_url)
    html.close_li()
    html.close_ul()
Exemplo n.º 8
0
def _show_topic(treename: str, topic: TopicMenuTopic, show_item_icons: bool) -> None:
    if not topic.items:
        return

    with foldable_container(treename=treename,
                            id_=topic.name,
                            isopen=False,
                            title=topic.title,
                            indent=True,
                            icon="foldable_sidebar"):

        for item in topic.items:
            if show_item_icons:
                html.open_li(class_=["sidebar", "show_more_mode" if item.is_show_more else None])
                iconlink(item.title, item.url, item.icon or "icon_missing")
                html.close_li()
            else:
                bulletlink(item.title,
                           item.url,
                           onclick="return cmk.sidebar.wato_views_clicked(this)")
Exemplo n.º 9
0
    def _show_items(self, topic_id: str, topic: TopicMenuTopic) -> None:
        html.open_ul()
        counter = 0
        for item in topic.items:
            if counter < 10:
                self._show_item(item)
                if not item.is_advanced:
                    counter += 1
            else:
                self._show_item(item, extended=True)
        if counter >= 10:
            html.open_li(class_="show_all_items")
            html.hr()
            html.a(content=_("Show all"),
                   href="",
                   onclick="cmk.popup_menu.mega_menu_show_all_items('%s')" %
                   topic_id)
            html.close_li()

        html.close_ul()
Exemplo n.º 10
0
def show_filter_form(show_filters):
    # Sort filters
    s = sorted([(f.sort_index, f.title, f) for f in show_filters if f.available()])

    html.begin_form("filter")
    html.open_ul(**{"data-role": "listview", "data-inset": "false"})
    for _sort_index, title, f in s:
        html.open_li(**{"data-role": "fieldcontain"})
        html.write("<legend>%s</legend>" % title)
        f.display()
        html.close_li()
    html.close_ul()
    html.hidden_fields()
    html.hidden_field("search", "Search")
    html.hidden_field("page", "data")
    html.end_form()
    html.javascript("""
      $('.results_button').live('click',function(e) {
        e.preventDefault();
        $('#form_filter').submit();
      });
    """)
Exemplo n.º 11
0
    def _show_main_menu_content(self) -> None:
        for menu_item in self._get_main_menu_items():
            if isinstance(menu_item.icon, dict):
                active_icon: Icon = {
                    "icon": menu_item.icon["icon"] + "_active",
                    "emblem": menu_item.icon["emblem"]
                }
            else:
                active_icon = menu_item.icon + "_active"

            html.open_li()
            html.popup_trigger(
                (html.render_icon(menu_item.icon) +
                 html.render_icon(active_icon, class_="active") +
                 html.render_div(menu_item.title)),
                ident="mega_menu_" + menu_item.name,
                method=MethodInline(self._get_mega_menu_content(menu_item)),
                cssclass=menu_item.name,
                popup_group="main_menu_popup",
                hover_switch_delay=150,  # ms
                onopen=menu_item.onopen,
            )
            html.close_li()
Exemplo n.º 12
0
def page_index() -> None:
    title = _("Checkmk Mobile")
    mobile_html_head(title)
    jqm_page_header(title,
                    right_button=("javascript:document.location.reload();",
                                  _("Reload"), "refresh"),
                    id_="data")
    items = []
    for view_name, view_spec in views.get_permitted_views().items():
        if view_spec.get("mobile") and not view_spec.get("hidden"):

            datasource = data_source_registry[view_spec["datasource"]]()
            context = visuals.get_merged_context(
                visuals.get_context_from_uri_vars(
                    datasource.infos, single_infos=view_spec["single_infos"]),
                view_spec["context"],
            )

            view = views.View(view_name, view_spec, context)
            view.row_limit = views.get_limit()
            view.only_sites = visuals.get_only_sites_from_context(context)
            view.user_sorters = views.get_user_sorters()
            view.want_checkboxes = views.get_want_checkboxes()

            url = "mobile_view.py?view_name=%s" % view_name
            count = ""
            if not view_spec.get("mustsearch"):
                painter_options = PainterOptions.get_instance()
                painter_options.load(view_name)
                count = '<span class="ui-li-count">%d</span>' % views.get_row_count(
                    view)

            topic = view_spec.get("topic")
            if topic is None:
                topic = ""
            this_title = '%s %s' % (view_spec["title"], count)
            items.append((topic, url, this_title))

    jqm_page_index(_("Checkmk Mobile"), items)
    # Link to non-mobile GUI

    html.hr()
    html.open_ul(**{
        "data-role": "listview",
        "data-theme": "b",
        "data-inset": "true"
    })
    html.open_li()
    html.a(_("Classical web GUI"),
           href="index.py?mobile=",
           **{
               "data-ajax": "false",
               "data-transition": "fade"
           })
    html.close_li()
    html.close_ul()

    html.open_ul(**{
        "data-role": "listview",
        "data-theme": "f",
        "data-inset": "true"
    })
    html.open_li()
    html.a(_("Logout"),
           href="logout.py",
           **{
               "data-ajax": "false",
               "data-transition": "fade"
           })
    html.close_li()
    html.close_ul()
    mobile_html_foot()
Exemplo n.º 13
0
def bulletlink(text, url, target="main", onclick=None):
    html.open_li(class_="sidebar")
    link(text, url, target, onclick)
    html.close_li()
Exemplo n.º 14
0
def bulletlink(text: str, url: str, target: str = "main", onclick: Optional[str] = None) -> None:
    html.open_li(class_="sidebar")
    link(text, url, target, onclick)
    html.close_li()
Exemplo n.º 15
0
 def render_addto_popup_title(cls, title):
     html.open_li()
     html.open_span()
     html.write("%s:" % title)
     html.close_span()
     html.close_li()
Exemplo n.º 16
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()