Ejemplo n.º 1
0
def render_metrics_table(translated_metrics, host_name, service_description):
    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 cmk_graphs_possible():
            output += "<td>"
            output += html.render_popup_trigger(
                html.render_icon("custom_graph",
                                 title=_("Add this metric to dedicated graph"),
                                 cssclass="iconbutton"),
                ident="add_metric_to_graph_" + host_name + ";" +
                service_description,
                what="add_metric_to_graph",
                url_vars=[
                    ("host", host_name),
                    ("service", service_description),
                    ("metric", metric_name),
                ])
            output += "</td>"
        output += "</tr>"
    output += "</table>"
    return output
Ejemplo n.º 2
0
def render_metrics_table(translated_metrics, host_name, service_description):
    # type: (TranslatedMetrics, str, 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("custom_graph",
                                     title=_("Add this metric to dedicated graph"),
                                     cssclass="iconbutton"),
                    ident="add_metric_to_graph_" + host_name + ";" + str(service_description),
                    what="add_metric_to_graph",
                    url_vars=[
                        ("host", host_name),
                        ("service", service_description),
                        ("metric", metric_name),
                    ]))
            output += "</td>"
        output += "</tr>"
    output += "</table>"
    return output
Ejemplo n.º 3
0
    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),
        )
Ejemplo n.º 4
0
    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),
        )
Ejemplo n.º 5
0
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