Example #1
0
def output_availability_csv(what, av_data, avoptions):
    def cells_from_row(object_titles, cell_titles, row_object, row_cells):
        for title, (name, url) in zip(object_titles, row_object):
            table.cell(title, name)
        for (title, help), (text, css) in zip(cell_titles, row_cells):
            table.cell(title, text)

    av_output_set_content_disposition(_("Check_MK-Availability"))
    availability_tables = availability.compute_availability_groups(
        what, av_data, avoptions)
    table.begin("av_items", output_format="csv")
    for group_title, availability_table in availability_tables:
        av_table = availability.layout_availability_table(
            what, group_title, availability_table, avoptions)
        pad = 0
        for row in av_table["rows"]:
            table.row()
            cells_from_row(av_table["object_titles"], av_table["cell_titles"],
                           row["object"], row["cells"])
            # presumably all rows have the same width
            pad = len(row["object"]) - 1
        table.row()
        cells_from_row(av_table["object_titles"], av_table["cell_titles"],
                       [(_("Summary"), "")] + [("", "")] * pad,
                       av_table["summary"])
    table.end()
Example #2
0
def render_availability_table(group_title, availability_table, what,
                              avoptions):

    av_table = availability.layout_availability_table(what, group_title,
                                                      availability_table,
                                                      avoptions)

    # TODO: If summary line is activated, then sorting should now move that line to the
    # top. It should also stay at the bottom. This would require an extension to the
    # table.py module.
    table.begin("av_items",
                av_table["title"],
                css="availability",
                searchable=False,
                limit=None,
                omit_headers="omit_headers" in avoptions["labelling"])

    for row in av_table["rows"]:
        table.row()

        # Column with icons
        timeline_url = None
        if row["urls"]:
            table.cell("", css="buttons")
            for image, tooltip, url in row["urls"]:
                html.icon_button(url, tooltip, image)
                if image == "timeline":
                    timeline_url = url

        # Column with host/service or aggregate name
        for title, (name, url) in zip(av_table["object_titles"],
                                      row["object"]):
            table.cell(title, '<a href="%s">%s</a>' % (url, name))

        if "timeline" in row:
            table.cell(_("Timeline"), css="timeline")
            html.open_a(href=timeline_url)
            render_timeline_bar(row["timeline"], "inline")
            html.close_a()

        # Columns with the actual availability data
        for (title, help), (text, css) in zip(av_table["cell_titles"],
                                              row["cells"]):
            table.cell(title, text, css=css, help=help)

    if "summary" in av_table:
        table.row(css="summary")
        if row["urls"]:
            table.cell("", "")  # Empty cell in URLs column
        table.cell("", _("Summary"), css="heading")
        for x in range(1, len(av_table["object_titles"])):
            table.cell("", "")  # empty cells, of more object titles than one
        if "timeline" in row:
            table.cell("", "")

        for (title, help), (text, css) in zip(av_table["cell_titles"],
                                              av_table["summary"]):
            table.cell(title, text, css="heading " + css, help=help)

    return table.end()  # returns Table data if fetch == True
Example #3
0
def output_availability_csv(what, av_data, avoptions):
    def cells_from_row(object_titles, cell_titles, row_object, row_cells):
        for title, (name, url) in zip(object_titles, row_object):
            table.cell(title, name)
        for (title, help), (text, css) in zip(cell_titles, row_cells):
            table.cell(title, text)

    av_output_set_content_disposition(_("Check_MK-Availability"))
    availability_tables = availability.compute_availability_groups(what, av_data, avoptions)
    table.begin("av_items", output_format="csv")
    for group_title, availability_table in availability_tables:
        av_table = availability.layout_availability_table(what, group_title, availability_table, avoptions)
        pad = 0
        for row in av_table["rows"]:
            table.row()
            cells_from_row(av_table["object_titles"], av_table["cell_titles"], row["object"], row["cells"])
            # presumably all rows have the same width
            pad = len(row["object"]) - 1
        table.row()
        cells_from_row(
            av_table["object_titles"],
            av_table["cell_titles"],
            [(_("Summary"), "")] + [("", "")] * pad,
            av_table["summary"],
        )
    table.end()
Example #4
0
def render_availability_table(group_title, availability_table, what, avoptions):

    av_table = availability.layout_availability_table(what, group_title, availability_table, avoptions)

    # TODO: If summary line is activated, then sorting should now move that line to the
    # top. It should also stay at the bottom. This would require an extension to the
    # table.py module.
    table.begin(
        "av_items",
        av_table["title"],
        css="availability",
        searchable=False,
        limit=None,
        omit_headers="omit_headers" in avoptions["labelling"],
    )

    for row in av_table["rows"]:
        table.row()

        # Column with icons
        timeline_url = None
        if row["urls"]:
            table.cell("", css="buttons")
            for image, tooltip, url in row["urls"]:
                html.icon_button(url, tooltip, image)
                if image == "timeline":
                    timeline_url = url

        # Column with host/service or aggregate name
        for title, (name, url) in zip(av_table["object_titles"], row["object"]):
            table.cell(title, '<a href="%s">%s</a>' % (url, name))

        if "timeline" in row:
            table.cell(_("Timeline"), css="timeline")
            html.write('<a href="%s">' % timeline_url)
            render_timeline_bar(row["timeline"], "inline")
            html.write("</a>")

        # Columns with the actual availability data
        for (title, help), (text, css) in zip(av_table["cell_titles"], row["cells"]):
            table.cell(title, text, css=css, help=help)

    if "summary" in av_table:
        table.row(css="summary")
        if row["urls"]:
            table.cell("", "")  # Empty cell in URLs column
        table.cell("", _("Summary"), css="heading")
        for x in range(1, len(av_table["object_titles"])):
            table.cell("", "")  # empty cells, of more object titles than one
        if "timeline" in row:
            table.cell("", "")

        for (title, help), (text, css) in zip(av_table["cell_titles"], av_table["summary"]):
            table.cell(title, text, css="heading " + css, help=help)

    return table.end()  # returns Table data if fetch == True
Example #5
0
def output_availability_csv(what, av_data, avoptions):
    av_output_csv_mimetype(_("Check_MK-Availability"))
    availability_tables = availability.compute_availability_groups(what, av_data, avoptions)
    table.begin("av_items", output_format = "csv")
    for group_title, availability_table in availability_tables:
        av_table = availability.layout_availability_table(what, group_title, availability_table, avoptions)
        for row in av_table["rows"]:
            table.row()
            for title, (name, url) in zip(av_table["object_titles"], row["object"]):
                table.cell(title, name)
            for (title, help), (text, css) in zip(av_table["cell_titles"], row["cells"]):
                table.cell(title, text)
    table.end()
Example #6
0
def output_availability_csv(what, av_data, avoptions):
    av_output_csv_mimetype(_("Check_MK-Availability"))
    availability_tables = availability.compute_availability_groups(what, av_data, avoptions)
    table.begin("av_items", output_format = "csv")
    for group_title, availability_table in availability_tables:
        av_table = availability.layout_availability_table(what, group_title, availability_table, avoptions)
        for row in av_table["rows"]:
            table.row()
            for title, (name, url) in zip(av_table["object_titles"], row["object"]):
                table.cell(title, name)
            for (title, help), (text, css) in zip(av_table["cell_titles"], row["cells"]):
                table.cell(title, text)
    table.end()