def page(self) -> cmk.gui.pages.PageResult: breadcrumb = make_simple_page_breadcrumb( mega_menu_registry["help_links"], _("Info")) make_header( html, self._title(), breadcrumb=breadcrumb, ) html.open_div(id_="info_title") html.h1(_("Your monitoring machine")) html.a( HTMLWriter.render_img(theme.url("images/tribe29.svg")), "https://tribe29.com", target="_blank", ) html.close_div() html.div(None, id_="info_underline") html.open_div(id_="info_intro_text") html.span(_("Open. Effective. Awesome.")) html.span( _("May we present? Monitoring as it's supposed to be: " "incredibly quick to install, infinetely scalable, highly customizable and " "designed for admins.")) html.span( _("Visit our %s to learn more about Checkmk and about the %s.") % ( HTMLWriter.render_a( _("website"), "https://checkmk.com", target="_blank"), HTMLWriter.render_a( _("latest version"), "https://checkmk.com/product/latest-version", target="_blank", ), )) html.close_div() version_major_minor = re.sub(r".\d+$", "", Version(__version__).version_base) if version_major_minor: current_version_link = "https://checkmk.com/product/checkmk-%s" % version_major_minor else: current_version_link = "https://checkmk.com/product/latest-version" html.open_div(id="info_image") html.open_a(href=current_version_link, target="_blank") html.img(theme.url("images/monitoring-machine.png")) html.close_a() html.close_div() html.close_div() html.open_div(id_="info_footer") html.span( _("© %s tribe29 GmbH. All Rights Reserved.") % time.strftime("%Y")) html.a(_("License agreement"), href="https://checkmk.com/legal.html", target="_blank") html.close_div()
def _table_head( treename: str, id_: str, isopen: bool, title: str, show_more_toggle: bool, help_text: Union[str, HTML, None] = None, ) -> None: onclick = foldable_container_onclick(treename, id_, fetch_url=None) img_id = foldable_container_img_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=theme.url("images/tree_closed.svg"), align="absbottom", ) html.write_text(title) html.help(help_text) if show_more_toggle: html.more_button("foldable_" + id_, dom_levels_up=4, with_text=True) html.close_td() html.close_tr() html.close_thead()
def _head(self, title: str, javascripts: Optional[Sequence[str]] = None) -> None: javascripts = javascripts if javascripts else [] self.open_head() self.default_html_headers() self.title(title) # If the variable _link_target is set, then all links in this page # should be targetted to the HTML frame named by _link_target. This # is e.g. useful in the dash-board if self.link_target: self.base(target=self.link_target) fname = HTMLGenerator._css_filename_for_browser(theme.url("theme")) if fname is not None: self.stylesheet(fname) self._add_custom_style_sheet() # Load all scripts for js in self._default_javascripts + list(javascripts): filename_for_browser = HTMLGenerator.javascript_filename_for_browser(js) if filename_for_browser: self.javascript_file(filename_for_browser) self._set_js_csrf_token() if self.browser_reload != 0.0: self.javascript("cmk.utils.set_reload(%s)" % (self.browser_reload)) self.close_head()
def show(self): html.open_div(class_="speedometer") html.img(theme.url("images/speedometer.svg"), id_="speedometerbg") html.canvas("", width=str(snapin_width), height="146", id_="speedometer") html.close_div() html.javascript("cmk.sidebar.speedometer_show_speed(0, 0, 0);")
def default_html_headers(self) -> None: self.meta(httpequiv="Content-Type", content="text/html; charset=utf-8") self.write_html( render_start_tag( "link", rel="shortcut icon", href=theme.url("images/favicon.ico"), type_="image/ico", close_tag=True, ) )
def _validate_icon(self, value, varprefix): file_name = value[0] browser_url = theme.url("images/icon_%s" % file_name) if os.path.exists( "%s/share/check_mk/web/htdocs/%s" % (cmk.utils.paths.omd_root, browser_url)) or os.path.exists( "%s/share/check_mk/web/htdocs/images/icons/%s" % (cmk.utils.paths.omd_root, file_name)): raise MKUserError( varprefix, _("Your icon conflicts with a Check_MK builtin icon. Please " "choose another name for your icon."), )
def icon_dropdown( self, varname: str, choices: Sequence[tuple[str, str, str]], deflt: str = "" ) -> None: current = self.request.var(varname, deflt) if varname: self.form_vars.append(varname) self.open_select(class_="icon", name=varname, id_=varname, size="1") for value, text, icon in choices: # if both the default in choices and current was '' then selected depended on the order in choices selected = (value == current) or (not value and not current) self.option( text, value=value if value else "", selected="" if selected else None, style="background-image:url(%s);" % theme.url(f"images/icon_{icon}.png"), ) self.close_select()
def show(self): html.open_table(class_="dashlet_overview") html.open_tr() html.open_td(valign="top") html.open_a(href="https://checkmk.com/") html.img(theme.url("images/check_mk.trans.120.png"), style="margin-right: 30px;") html.close_a() html.close_td() html.open_td() html.h2("CheckMK") html.write_text( _("Welcome to Checkmk. If you want to learn more about Checkmk, please visit " 'our <a href="https://checkmk.com/" target="_blank">user manual</a>.' )) html.close_td() html.close_tr() html.close_table()
def grouped_row_title(index, group_spec, num_rows, trclass, num_cells): is_open = user.get_tree_state("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( theme.url("images/tree_closed.svg"), 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
def foldable_container( *, treename: str, id_: str, isopen: bool, title: HTMLContent, indent: Union[str, None, bool] = True, icon: Optional[str] = None, fetch_url: Optional[str] = None, title_url: Optional[str] = None, title_target: Optional[str] = None, padding: int = 15, save_state: bool = True, ) -> Iterator[bool]: isopen = user.get_tree_state(treename, id_, isopen) onclick = foldable_container_onclick(treename, id_, fetch_url, save_state) img_id = foldable_container_img_id(treename, id_) container_id = foldable_container_id(treename, id_) html.open_div(class_=["foldable", "open" if isopen else "closed"]) html.open_div(class_="foldable_header", onclick=None if title_url else onclick) if isinstance(title, HTML): # custom HTML code html.write_text(title) else: html.open_b(class_=["treeangle", "title"]) if title_url: html.a(title, href=title_url, target=title_target) else: html.write_text(title) html.close_b() if icon: html.img( id_=img_id, # Although foldable_sidebar is given via the argument icon it should not be displayed as big as an icon. class_=(["treeangle", "title"] + (["icon"] if icon != "foldable_sidebar" else []) + ["open" if isopen else "closed"]), src=theme.detect_icon_path(icon, "icon_"), onclick=onclick if title_url else None, ) else: html.img( id_=img_id, class_=["treeangle", "open" if isopen else "closed"], src=theme.url("images/tree_closed.svg"), onclick=onclick if title_url else None, ) html.close_div() indent_style = "padding-left: %dpx; " % (padding if indent else 0) if indent == "form": html.close_td() html.close_tr() html.close_table() indent_style += "margin: 0; " html.open_ul(id_=container_id, class_=["treeangle", "open" if isopen else "closed"], style=indent_style) yield isopen html.close_ul() html.close_div()
def show(self): html.open_a(href="https://checkmk.com/", target="_blank") html.img(theme.url("images/check_mk.trans.120.png"), style="margin-right: 30px;") html.close_a()
def _show_node(self, tree, show_host, mousecode=None, img_class=None): # Check if we have an assumed state: comparing assumed state (tree[1]) with state (tree[0]) if tree[1] and tree[0] != tree[1]: addclass = ["assumed"] effective_state = tree[1] else: addclass = [] effective_state = tree[0] class_ = [ "content", "state", "state%d" % (effective_state["state"] if effective_state["state"] is not None else -1), ] + addclass html.open_span(class_=class_) html.write_text(self._render_bi_state(effective_state["state"])) html.close_span() if mousecode: if img_class: html.img( src=theme.url("images/tree_closed.svg"), class_=["treeangle", img_class], onclick=mousecode, ) html.open_span(class_=["content", "name"]) icon_name, icon_title = None, None if tree[0]["in_downtime"] == 2: icon_name = "downtime" icon_title = _( "This element is currently in a scheduled downtime.") elif tree[0]["in_downtime"] == 1: # only display host downtime if the service has no own downtime icon_name = "derived_downtime" icon_title = _( "One of the subelements is in a scheduled downtime.") if tree[0]["acknowledged"]: icon_name = "ack" icon_title = _("This problem has been acknowledged.") if not tree[0]["in_service_period"]: icon_name = "outof_serviceperiod" icon_title = _( "This element is currently not in its service period.") if icon_name and icon_title: html.icon(icon_name, title=icon_title, class_=["icon", "bi"]) yield if mousecode: if str(effective_state["state"]) in tree[2].get( "state_messages", {}): html.b(HTML("♦"), class_="bullet") html.write_text(tree[2]["state_messages"][str( effective_state["state"])]) html.close_span() output: HTML = cmk.gui.view_utils.format_plugin_output( effective_state["output"], shall_escape=active_config.escape_plugin_output) if output: output = HTMLWriter.render_b(HTML("♦"), class_="bullet") + output else: output = HTML() html.span(output, class_=["content", "output"])