def render(self, what, row, tags, custom_vars): url_vars = [ ('host', row['host_name']), ] if row.get('site'): url_vars.append(('site', row['site'])) if what == 'service': url_vars.append(('service', row['service_description'])) if html.request.has_var('display_options'): url_vars.append( ('display_options', html.request.var('display_options'))) if html.request.has_var('_display_options'): url_vars.append( ('_display_options', html.request.var('_display_options'))) url_vars.append(('_back_url', makeuri(request, []))) return html.render_popup_trigger( html.render_icon('menu', _('Open the action menu'), cssclass="iconbutton"), 'action_menu', MethodAjax(endpoint='action_menu', url_vars=url_vars), )
def render_metrics_table(translated_metrics: TranslatedMetrics, host_name: str, service_description: str) -> str: # TODO: Don't paste together strings by hand, use our HTML utilities. output = "<table class=metricstable>" for metric_name, metric in sorted(translated_metrics.items(), key=lambda x: x[1]["title"]): output += "<tr>" output += "<td class=color>%s</td>" % render_color_icon(metric["color"]) output += "<td>%s:</td>" % metric["title"] output += "<td class=value>%s</td>" % metric["unit"]["render"](metric["value"]) if not cmk_version.is_raw_edition(): output += "<td>" output += str( html.render_popup_trigger( html.render_icon("menu", title=_("Add this metric to dedicated graph"), cssclass="iconbutton"), ident="add_metric_to_graph_" + host_name + ";" + str(service_description), method=MethodAjax(endpoint="add_metric_to_graph", url_vars=[ ("host", host_name), ("service", service_description), ("metric", metric_name), ]))) output += "</td>" output += "</tr>" output += "</table>" return output
def render(self, what, row, tags, custom_vars): url_vars = [ ("host", row["host_name"]), ] if row.get("site"): url_vars.append(("site", row["site"])) if what == "service": url_vars.append(("service", row["service_description"])) if request.has_var("display_options"): url_vars.append( ("display_options", request.var("display_options"))) if request.has_var("_display_options"): url_vars.append( ("_display_options", request.var("_display_options"))) url_vars.append(("_back_url", makeuri(request, []))) return html.render_popup_trigger( html.render_icon("menu", _("Open the action menu"), cssclass="iconbutton"), "action_menu", MethodAjax(endpoint="action_menu", url_vars=url_vars), )
def _show_move_to_folder_action(self, obj): if isinstance(obj, watolib.Host): what = "host" what_title = _("host") ident = obj.name() style = None else: what = "folder" what_title = _("folder") ident = obj.path() style = "display:none" html.popup_trigger( html.render_icon("move", title=_("Move this %s to another folder") % what_title, cssclass="iconbutton"), ident="move_" + obj.name(), method=MethodAjax(endpoint="move_to_folder", url_vars=[ ("what", what), ("ident", ident), ("back_url", html.makeactionuri([])), ]), style=style, )
def render_graph_add_to_icon_for_popup(graph_artwork, graph_data_range, graph_render_options): icon_html = html.render_icon('menu', _('Add this graph to...')) element_type_name = "pnpgraph" # Data will be transferred via URL and Javascript magic eventually # to our function popup_add_element (htdocs/reporting.py) # argument report_name --> provided by popup system # further arguments: return html.render_popup_trigger( content=icon_html, ident='add_visual', method=MethodAjax(endpoint='add_visual', url_vars=[("add_type", "pnpgraph")]), data=[ element_type_name, None, graph_ajax_context(graph_artwork, graph_data_range, graph_render_options) ], style="z-index:2") # Ensures that graph canvas does not cover it