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()
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()
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, 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)") html.end_foldable_container()
def jqm_page_navfooter(items, current, page_id): html.close_div() # close content html.open_div(**{"data-role": "footer", "data-position": "fixed"}) 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 custom_css is False: custom_css = "" 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
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( (self._get_popup_trigger_content(active_icon, menu_item)), 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.div("", id_="popup_shadow", onclick="cmk.popup_menu.close_popup()", class_="min" if config.user.get_attribute("nav_hide_icons_title") else None) html.close_li()
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()
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"]]))
def nagioscgilink(text, target): html.open_li(class_="sidebar") html.a(text, class_="link", target="main", href="%snagios/cgi-bin/%s" % (config.url_prefix(), target)) html.close_li()
def jqm_page_navfooter(items: NavigationBar, current: str, page_id: 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 = makeuri(request, [("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
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()
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()
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()
def _render_result(self, result, hidden=False): html.open_li() html.open_a(href=result.url, target="main", onclick="cmk.popup_menu.close_popup()", class_="hidden" if hidden else "") html.write_text(result.title) html.close_a() html.close_li()
def render_addto_popup_entry(cls, type_name, name, title): html.open_li() html.open_a( href="javascript:void(0)", onclick="cmk.popup_menu.pagetype_add_to_container('%s', '%s');cmk.utils.reload_sidebar();" % (type_name, name)) html.render_icon(type_name) html.write_text(title) html.close_a() html.close_li()
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()
def _show_item(self, item: TopicMenuItem) -> None: html.open_li(class_="show_more_mode" if item.is_show_more else None) html.open_a( href=item.url, target="main", onclick="cmk.popup_menu.close_popup()", ) if config.user.get_attribute("icons_per_item"): html.icon(item.icon_name or "trans", emblem=item.emblem) html.write_text(item.title) html.close_a() html.close_li()
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()
def _show_item(self, item: TopicMenuItem) -> None: html.open_li(class_="show_more_mode" if item.is_show_more else None) html.open_a( href=item.url, target=item.target, onclick="cmk.popup_menu.close_popup()", ) if config.user.get_attribute("icons_per_item"): html.icon(item.icon or "trans") self._show_item_title(item) html.close_a() html.close_li()
def _show_item(self, item: TopicMenuItem) -> None: html.open_li(class_="advanced" if item.is_advanced else None) html.open_a( href=item.url, target="main", onclick="cmk.popup_menu.close_popup()", ) if config.user.get_attribute("icons_per_item") and item.icon_name: html.icon(title=None, icon=item.icon_name) html.write_text(item.title) html.close_a() html.close_li()
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()
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(" ") if tree[2].get("docu_url"): html.icon_button( tree[2]["docu_url"], _("Context information about this rule"), "url", target="_blank", ) html.write_text(" ") 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()
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()
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()
def _show_main_menu_content(self) -> None: for menu_item in self._get_main_menu_items(): html.open_li() html.popup_trigger( (html.render_icon(menu_item.icon_name) + html.render_icon( menu_item.icon_name + "_active", 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()
def _show_item(self, item: TopicMenuItem, extended: bool = False) -> None: cls = [ "advanced" if item.is_advanced else None, "extended" if extended else None ] html.open_li(class_=cls) html.a( item.title, href=item.url, target="main", onclick="cmk.popup_menu.close_popup()", ) html.close_li()
def _show_tree_nodes(self, maps, children): for map_name, map_cfg in maps.items(): 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()
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");')
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()
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()
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()