示例#1
0
文件: tags.py 项目: inettgmbh/checkmk
def _show_affected_folders(affected_folders: List[CREFolder]) -> None:
    html.open_ul()
    for folder in affected_folders:
        html.open_li()
        html.a(folder.alias_path(), href=folder.edit_url())
        html.close_li()
    html.close_ul()
示例#2
0
文件: wato.py 项目: inettgmbh/checkmk
def render_tree_folder(tree_id, folder, js_func):
    subfolders = folder.get(".folders", {}).values()
    is_leaf = len(subfolders) == 0

    # Suppress indentation for non-emtpy root folder
    if folder['.path'] == '' and is_leaf:
        html.open_ul()  # empty root folder
    elif folder and folder['.path'] != '':
        html.open_ul(style="padding-left:0px;")

    title = html.render_a("%s (%d)" % (folder["title"], folder[".num_hosts"]),
                          href="#",
                          class_="link",
                          onclick="%s(this, \'%s\');" %
                          (js_func, folder[".path"]))

    if not is_leaf:
        html.begin_foldable_container(
            tree_id,
            "/" + folder[".path"],
            False,
            HTML(title),
            icon="foldable_sidebar",
            padding=6,
        )
        for subfolder in sorted(subfolders, key=lambda x: x["title"].lower()):
            render_tree_folder(tree_id, subfolder, js_func)
        html.end_foldable_container()
    else:
        html.li(title)

    html.close_ul()
示例#3
0
 def show(self):
     group_type = self._group_type_ident()
     html.open_ul()
     for name, alias in sites.all_groups(group_type.replace("group", "")):
         url = "view.py?view_name=%s&%s=%s" % (group_type, group_type, html.urlencode(name))
         bulletlink(alias or name, url)
     html.close_ul()
示例#4
0
def page_index():
    title = _("Check_MK 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"):
            view = views.View(view_name, view_spec)
            view.row_limit = views.get_limit()
            view.only_sites = views.get_only_sites()
            view.user_sorters = views.get_user_sorters()

            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)
                view_renderer = MobileViewRenderer(view)
                count = views.show_view(view, view_renderer, only_count=True)
                count = '<span class="ui-li-count">%d</span>' % count
            items.append(
                (view_spec.get("topic"), url, '%s %s' %
                 (view_spec.get("linktitle", view_spec["title"]), count)))
    jqm_page_index(_("Check_MK 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()
示例#5
0
文件: bi.py 项目: WennySoft/checkmk
 def show(self) -> None:
     html.open_ul()
     for _ident, group in bi.aggregation_group_choices():
         bulletlink(
             group, "view.py?view_name=aggr_group&aggr_group=%s" %
             urlencode(group))
     html.close_ul()
示例#6
0
文件: bi.py 项目: WennySoft/checkmk
    def _render_tree(self, tree):
        for group, attrs in tree.items():
            aggr_group_tree = "/".join(attrs["__path__"])
            fetch_url = makeuri_contextless(
                request,
                [
                    ("view_name", "aggr_all"),
                    ("aggr_group_tree", aggr_group_tree),
                ],
                filename="view.py",
            )

            if attrs.get("__children__"):
                with foldable_container(
                        treename="bi_aggregation_group_trees",
                        id_=aggr_group_tree,
                        isopen=False,
                        title=HTML(
                            html.render_a(
                                group,
                                href=fetch_url,
                                target="main",
                            )),
                        icon="foldable_sidebar",
                ):
                    self._render_tree(attrs["__children__"])
            else:
                html.open_ul()
                bulletlink(group, fetch_url)
                html.close_ul()
示例#7
0
    def _show_entry_cells(self, table, ident, entry):
        table.cell(_("Title"), html.render_text(entry["title"]))

        table.cell(_("Conditions"))
        html.open_ul(class_="conditions")
        html.open_li()
        html.write(
            "%s: %s" %
            (_("Folder"), Folder.folder(
                entry["conditions"]["host_folder"]).alias_path()))
        html.close_li()
        html.close_ul()
        html.write(vs_conditions().value_to_text(entry["conditions"]))

        table.cell(_("Editable by"))
        if entry["owned_by"] is None:
            html.write_text(
                _("Administrators (having the permission "
                  "\"Write access to all predefined conditions\")"))
        else:
            html.write_text(self._contact_group_alias(entry["owned_by"]))

        table.cell(_("Shared with"))
        if not entry["shared_with"]:
            html.write_text(_("Not shared"))
        else:
            html.write_text(", ".join(
                [self._contact_group_alias(g) for g in entry["shared_with"]]))
示例#8
0
    def _render_tree(self, tree):
        for group, attrs in tree.items():
            fetch_url = makeuri_contextless(
                request,
                [
                    ("view_name", "aggr_all"),
                    ("aggr_group_tree", "/".join(attrs["__path__"])),
                ],
                filename="view.py",
            )

            if attrs.get('__children__'):
                html.begin_foldable_container(
                    "bi_aggregation_group_trees",
                    group,
                    False,
                    HTML(html.render_a(
                        group,
                        href=fetch_url,
                        target="main",
                    )),
                    icon="foldable_sidebar",
                )
                self._render_tree(attrs['__children__'])
                html.end_foldable_container()
            else:
                html.open_ul()
                bulletlink(group, fetch_url)
                html.close_ul()
示例#9
0
 def show(self) -> None:
     html.open_ul()
     for group in bi.get_aggregation_group_trees():
         bulletlink(
             group, "view.py?view_name=aggr_group&aggr_group=%s" %
             html.urlencode(group))
     html.close_ul()
示例#10
0
def jqm_page_navfooter(items, current, page_id):
    # type: (NavigationBar, str, str) -> None
    html.close_div()  # close content
    html.open_div(
        **{
            "data-role": "footer",
            "data-position": "fixed",
            "data-tap-toggle": "false",
            "data-hide-during-focus": "",
        })
    html.open_div(**{"data-role": "navbar"})
    html.open_ul()

    for href, title, icon, custom_css in items:
        href = html.makeuri([("page", href), ("search", "Search")])
        if current == href:
            custom_css += ' ui-state-persist ui-btn-active'
        else:
            html.open_li()
            html.open_a(href=href,
                        class_=custom_css,
                        **{
                            "data-transition": "slide",
                            "data-icon": icon,
                            "data-iconpos": "bottom",
                        })
            html.write(title)
            html.close_a()
            html.close_li()
    html.close_ul()
    html.close_div()
    html.close_div()
    html.close_div()  # close page-div
示例#11
0
 def render(self, query: str) -> str:
     results = self._generate_results(query)
     with html.plugged():
         for topic, search_results in results.items():
             html.open_div(id_=topic, class_="topic")
             self._render_topic(topic)
             html.open_ul()
             for count, result in enumerate(list(search_results)):
                 self._render_result(
                     result,
                     hidden=count >= self._max_num_displayed_results)
             # TODO: Remove this as soon as the index search does limit its search results
             if len(list(
                     search_results)) >= self._max_num_displayed_results:
                 html.input(
                     name="show_all_results",
                     value=_("Show all results"),
                     type_="button",
                     onclick=
                     f"cmk.search.on_click_show_all_results('{topic}');")
             html.close_ul()
             html.close_div()
         html.div(None, class_=["topic", "sentinel"])
         html_text = html.drain()
     return html_text
示例#12
0
def page_index():
    # type: () -> None
    title = _("Check_MK 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),
                view_spec["context"],
            )

            view = views.View(view_name, view_spec, context)
            view.row_limit = views.get_limit()
            view.only_sites = views.get_only_sites()
            view.user_sorters = views.get_user_sorters()

            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)
                view_renderer = MobileViewRenderer(view)
                # TODO: Horrible API ahead!
                count_num = views.show_view(view, view_renderer, only_count=True)
                count = '<span class="ui-li-count">%d</span>' % count_num

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

    jqm_page_index(_("Check_MK 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()
示例#13
0
文件: tags.py 项目: petrows/checkmk
def _show_affected_rulesets(affected_rulesets: List[Ruleset]) -> None:
    html.open_ul()
    for ruleset in affected_rulesets:
        html.open_li()
        html.a(ruleset.title(),
               href=watolib.folder_preserving_link([("mode", "edit_ruleset"),
                                                    ("varname", ruleset.name)]))
        html.close_li()
    html.close_ul()
示例#14
0
 def show(self):
     html.open_ul()
     bulletlink(_("Homepage"), "https://checkmk.com", target="_blank")
     bulletlink(_("Documentation"),
                "https://docs.checkmk.com/master",
                target="_blank")
     bulletlink(_("Download"),
                "https://checkmk.com/download",
                target="_blank")
     html.close_ul()
示例#15
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),
                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 = PagetypeTopics.get_topic(view_spec.get("topic", ""))
            items.append((topic.title(), url, "%s %s" % (view_spec["title"], count)))

    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()
示例#16
0
 def _show_items(self, topic_id: str, topic: TopicMenuTopic) -> None:
     html.open_ul()
     for item in topic.items:
         self._show_item(item)
     html.open_li(class_="show_all_items")
     html.open_a(href="", onclick="cmk.popup_menu.mega_menu_show_all_items('%s')" % topic_id)
     if config.user.get_attribute("icons_per_item"):
         html.icon("trans")
     html.write_text(_("Show all"))
     html.close_a()
     html.close_li()
     html.close_ul()
示例#17
0
 def show(self):
     html.open_ul()
     bulletlink(_("Homepage"),
                "https://checkmk.com/check_mk.html",
                target="_blank")
     bulletlink(_("Documentation"),
                "https://checkmk.com/cms.html",
                target="_blank")
     bulletlink(_("Download"),
                "https://checkmk.com/download.php",
                target="_blank")
     html.close_ul()
示例#18
0
 def _show_items(self, topic_id: str, topic: TopicMenuTopic) -> None:
     html.open_ul()
     for item in topic.items:
         self._show_item(item)
     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()
示例#19
0
 def page(self):
     query = html.request.get_unicode_input_mandatory("q")
     try:
         return MenuSearchResultsRenderer("setup").render(query)
     except IndexNotFoundException:
         with html.plugged():
             html.open_div(class_="topic")
             html.open_ul()
             html.write_text(_("Currently indexing, please try again shortly."))
             html.close_ul()
             html.close_div()
             return html.drain()
示例#20
0
    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(html.render_icon(tree[2]["icon"]))
                html.write_text("&nbsp;")

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

            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()
示例#21
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()
示例#22
0
文件: tags.py 项目: petrows/checkmk
def _show_affected_hosts(affected_hosts: List[CREHost]) -> None:
    html.open_ul()
    html.open_li()
    for nr, host in enumerate(affected_hosts):
        if nr > 20:
            html.write_text(_("... (%d more)") % (len(affected_hosts) - 20))
            break

        if nr > 0:
            html.write_text(", ")

        html.a(host.name(), href=host.edit_url())
    html.close_li()
    html.close_ul()
示例#23
0
文件: werks.py 项目: m3rlinux/checkmk
def render_werk_description(werk) -> HTML:
    with output_funnel.plugged():
        html.open_p()
        in_list = False
        in_code = False
        for line in werk["body"]:
            if line.startswith("LI:"):
                if not in_list:
                    html.open_ul()
                    in_list = True
                html.li(line[3:])
            else:
                if in_list:
                    html.close_ul()
                    in_list = False

                if line.startswith("H2:"):
                    html.h3(line[3:])
                elif line.startswith("C+:"):
                    html.open_pre(class_="code")
                    in_code = True
                elif line.startswith("F+:"):
                    file_name = line[3:]
                    if file_name:
                        html.div(file_name, class_="filename")
                    html.open_pre(class_="file")
                    in_code = True
                elif line.startswith("C-:") or line.startswith("F-:"):
                    html.close_pre()
                    in_code = False
                elif line.startswith("OM:"):
                    html.write_text("OMD[mysite]:~$ ")
                    html.b(line[3:])
                elif line.startswith("RP:"):
                    html.write_text("root@myhost:~# ")
                    html.b(line[3:])
                elif not line.strip() and not in_code:
                    html.p("")
                else:
                    html.write_text(line + "\n")

        if in_list:
            html.close_ul()

        html.close_p()
        return HTML(output_funnel.drain())
示例#24
0
 def render(self, query: str) -> str:
     results = self._generate_results(query)
     with html.plugged():
         for topic, search_results in results.items():
             html.open_div(id_=topic, class_="topic")
             self._render_topic(topic)
             html.open_ul()
             for result in list(search_results)[:self._max_num_displayed_results]:
                 self._render_result(result)
             # TODO: Remove this as soon as the index search does limit its search results
             if len(list(search_results)) >= self._max_num_displayed_results:
                 html.div(
                     content=_(f"Showing only first {self._max_num_displayed_results} results."))
             html.close_ul()
             html.close_div()
         html.div(None, class_=["topic", "sentinel"])
         html_text = html.drain()
     return html_text
示例#25
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(" &middot; ").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");')
示例#26
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()
示例#27
0
文件: tags.py 项目: petrows/checkmk
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()
示例#28
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();
      });
    """)
示例#29
0
        def render_topic(topic, s, foldable=True):
            first = True
            for t, title, name, _is_view in s:
                if t == topic:
                    if first:
                        if foldable:
                            html.begin_foldable_container("dashboards",
                                                          topic,
                                                          False,
                                                          topic,
                                                          indent=True)
                        else:
                            html.open_ul()
                        first = False
                    bulletlink(title,
                               'dashboard.py?name=%s' % name,
                               onclick="return cmk.sidebar.wato_views_clicked(this)")

            if not first:  # at least one item rendered
                if foldable:
                    html.end_foldable_container()
                else:
                    html.open_ul()
示例#30
0
 def _show_tree(self, api_request):
     html.open_ul()
     self._show_tree_nodes(api_request["maps"]["maps"],
                           api_request["maps"]["childs"])
     html.close_ul()