Ejemplo n.º 1
0
                                       lazy=True)
    elif treetype == "bottom-up":
        return paint_aggr_tree_ltr(row, False)
    elif treetype == "top-down":
        return paint_aggr_tree_ltr(row, True)


multisite_painters["aggr_treestate"] = {
    "title": _("Aggregation: complete tree"),
    "short": _("Tree"),
    "columns": ["aggr_treestate", "aggr_hosts"],
    "options":
    ["aggr_expand", "aggr_onlyproblems", "aggr_treetype", "aggr_wrap"],
    "paint": paint_aggregated_tree_state,
}

multisite_painters["aggr_treestate_boxed"] = {
    "title":
    _("Aggregation: simplistic boxed layout"),
    "short":
    _("Tree"),
    "columns": ["aggr_treestate", "aggr_hosts"],
    "paint":
    lambda row: bi.render_tree_foldable(row,
                                        boxes=True,
                                        omit_root=True,
                                        expansion_level=bi.load_ex_level(),
                                        only_problems=False,
                                        lazy=True),
}
Ejemplo n.º 2
0
    expansion_level = int(painter_options.get("aggr_expand"))
    only_problems   = painter_options.get("aggr_onlyproblems") == "1"

    if treetype == "foldable":
        return bi.render_tree_foldable(row,  False,  False, expansion_level, only_problems, lazy=True)
    elif treetype == "boxes":
        return bi.render_tree_foldable(row,  True, False, expansion_level, only_problems, lazy=True)
    elif treetype == "boxes-omit-root":
        return bi.render_tree_foldable(row,  True, True, expansion_level, only_problems, lazy=True)
    elif treetype == "bottom-up":
        return paint_aggr_tree_ltr(row, False)
    elif treetype == "top-down":
        return paint_aggr_tree_ltr(row, True)


multisite_painters["aggr_treestate"] = {
    "title"   : _("Aggregation: complete tree"),
    "short"   : _("Tree"),
    "columns" : [ "aggr_treestate", "aggr_hosts" ],
    "options" : [ "aggr_expand", "aggr_onlyproblems", "aggr_treetype", "aggr_wrap" ],
    "paint"   : paint_aggregated_tree_state,
}

multisite_painters["aggr_treestate_boxed"] = {
    "title"   : _("Aggregation: simplistic boxed layout"),
    "short"   : _("Tree"),
    "columns" : [ "aggr_treestate", "aggr_hosts" ],
    "paint"   : lambda row: bi.render_tree_foldable(row, boxes=True, omit_root=True,
                expansion_level=bi.load_ex_level(), only_problems=False, lazy=True),
}
Ejemplo n.º 3
0
def paint_aggr_tree_foldable(row, boxes, omit_root=True):
    saved_expansion_level = bi.load_ex_level()
    treestate = weblib.get_tree_states('bi')
    expansion_level = int(get_painter_option("aggr_expand"))
    if expansion_level != saved_expansion_level:
        treestate = {}
        weblib.set_tree_states('bi', treestate)
        weblib.save_tree_states()

    mousecode = \
       'onmouseover="this.style.cursor=\'pointer\';" ' \
       'onmouseout="this.style.cursor=\'auto\';" ' \
       'onclick="bi_toggle_%s(this);" ' % (boxes and "box" or "subtree")

    def render_subtree(tree, path, show_host):
        is_leaf = len(tree) == 3
        path_id = "/".join(path)
        is_open = treestate.get(path_id)
        if is_open == None:
            is_open = len(path) <= expansion_level

        h = ""
        
        state = tree[0]

        # Variant: BI-Boxes
        if boxes:
            if is_leaf:
                leaf = "leaf"
                mc = ""
            else:
                leaf = "noleaf"
                mc = mousecode

            omit = omit_root and len(path) == 1
            if not omit:
                h += '<span id="%d:%s" %s class="bibox_box %s %s state%s">' % (
                        expansion_level, path_id, mc, leaf, is_open and "open" or "closed", state["state"])
                if is_leaf:
                    h += aggr_render_leaf(tree, show_host, bare = True) # .replace(" ", "&nbsp;")
                else:
                    h += tree[2]["title"].replace(" ", "&nbsp;")
                h += '</span> '

            if not is_leaf:
                h += '<span class="bibox" style="%s">' % ((not is_open and not omit) and "display: none;" or "")
                parts = []
                for node in tree[3]:
                    new_path = path + [node[2]["title"]]
                    h += render_subtree(node, new_path, show_host)
                h += '</span>'
            return h

        # Variant: foldable trees
        else:
            if is_leaf: # leaf
                return aggr_render_leaf(tree, show_host, bare = boxes)

            h += '<span class=title>'
            is_empty = len(tree[3]) == 0
            if is_empty:
                style = ''
                mc = ''
            elif is_open:
                style = ''
                mc = mousecode + 'src="images/tree_black_90.png" '
            else:
                style = 'style="display: none" '
                mc = mousecode + 'src="images/tree_black_00.png" '

            h += aggr_render_node(tree, tree[2]["title"], mc, show_host)
            if not is_empty:
                h += '<ul id="%d:%s" %sclass="subtree">' % (expansion_level, path_id, style)

                for node in tree[3]:
                    estate = node[1] != None and node[1] or node[0]

                    if not node[2].get("hidden"):
                        new_path = path + [node[2]["title"]]
                        h += '<li>' + render_subtree(node, new_path, show_host) + '</li>\n'
                h += '</ul>'
            return h + '</span>\n'

    tree = row["aggr_treestate"]
    if get_painter_option("aggr_onlyproblems") == "1":
        tree = filter_tree_only_problems(tree)

    affected_hosts = row["aggr_hosts"]
    htmlcode = render_subtree(tree, [tree[2]["title"]], len(affected_hosts) > 1)
    return "aggrtree" + (boxes and "_box" or ""), htmlcode
Ejemplo n.º 4
0
def paint_aggregated_tree_state(row):
    treetype = get_painter_option("aggr_treetype")
    expansion_level = int(get_painter_option("aggr_expand"))
    only_problems = get_painter_option("aggr_onlyproblems") == "1"
    if treetype == "foldable":
        return bi.render_tree_foldable(row,  False,  False, expansion_level, only_problems, lazy=True)
    elif treetype == "boxes":
        return bi.render_tree_foldable(row,  True, False, expansion_level, only_problems, lazy=True)
    elif treetype == "boxes-omit-root":
        return bi.render_tree_foldable(row,  True, True, expansion_level, only_problems, lazy=True)
    elif treetype == "bottom-up":
        return paint_aggr_tree_ltr(row, False)
    elif treetype == "top-down":
        return paint_aggr_tree_ltr(row, True)

multisite_painters["aggr_treestate"] = {
    "title"   : _("Aggregation: complete tree"),
    "short"   : _("Tree"),
    "columns" : [ "aggr_treestate", "aggr_hosts" ],
    "options" : [ "aggr_expand", "aggr_onlyproblems", "aggr_treetype", "aggr_wrap" ],
    "paint"   : paint_aggregated_tree_state,
}

multisite_painters["aggr_treestate_boxed"] = {
    "title"   : _("Aggregation: simplistic boxed layout"),
    "short"   : _("Tree"),
    "columns" : [ "aggr_treestate", "aggr_hosts" ],
    "paint"   : lambda row: bi.render_tree_foldable(row, boxes=True, omit_root=True,
                expansion_level=bi.load_ex_level(), only_problems=False, lazy=True),
}
Ejemplo n.º 5
0
Archivo: bi.py Proyecto: dago/check_mk
def paint_aggr_tree_foldable(row, boxes, omit_root=True):
    saved_expansion_level = bi.load_ex_level()
    treestate = weblib.get_tree_states('bi')
    expansion_level = int(get_painter_option("aggr_expand"))
    if expansion_level != saved_expansion_level:
        treestate = {}
        weblib.set_tree_states('bi', treestate)
        weblib.save_tree_states()

    mousecode = \
       'onmouseover="this.style.cursor=\'pointer\';" ' \
       'onmouseout="this.style.cursor=\'auto\';" ' \
       'onclick="bi_toggle_%s(this);" ' % (boxes and "box" or "subtree")

    def render_subtree(tree, path, show_host):
        is_leaf = len(tree) == 3
        path_id = "/".join(path)
        is_open = treestate.get(path_id)
        if is_open == None:
            is_open = len(path) <= expansion_level

        h = ""
        
        state = tree[0]

        # Variant: BI-Boxes
        if boxes:
            # 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]

            if is_leaf:
                leaf = "leaf"
                mc = ""
            else:
                leaf = "noleaf"
                mc = mousecode

            omit = omit_root and len(path) == 1
            if not omit:
                h += '<span id="%d:%s" %s class="bibox_box %s %s state state%s%s">' % (
                        expansion_level, path_id, mc, leaf, is_open and "open" or "closed", effective_state["state"], addclass)
                if is_leaf:
                    h += aggr_render_leaf(tree, show_host, bare = True) # .replace(" ", "&nbsp;")
                else:
                    h += tree[2]["title"].replace(" ", "&nbsp;")
                h += '</span> '

            if not is_leaf:
                h += '<span class="bibox" style="%s">' % ((not is_open and not omit) and "display: none;" or "")
                parts = []
                for node in tree[3]:
                    new_path = path + [node[2]["title"]]
                    h += render_subtree(node, new_path, show_host)
                h += '</span>'
            return h

        # Variant: foldable trees
        else:
            if is_leaf: # leaf
                return aggr_render_leaf(tree, show_host, bare = boxes)

            h += '<span class=title>'
            is_empty = len(tree[3]) == 0
            if is_empty:
                style = ''
                mc = ''
            elif is_open:
                style = ''
                mc = mousecode + 'src="images/tree_black_90.png" '
            else:
                style = 'style="display: none" '
                mc = mousecode + 'src="images/tree_black_00.png" '

            h += aggr_render_node(tree, tree[2]["title"], mc, show_host)
            if not is_empty:
                h += '<ul id="%d:%s" %sclass="subtree">' % (expansion_level, path_id, style)

                for node in tree[3]:
                    estate = node[1] != None and node[1] or node[0]

                    if not node[2].get("hidden"):
                        new_path = path + [node[2]["title"]]
                        h += '<li>' + render_subtree(node, new_path, show_host) + '</li>\n'
                h += '</ul>'
            return h + '</span>\n'

    tree = row["aggr_treestate"]
    if get_painter_option("aggr_onlyproblems") == "1":
        tree = filter_tree_only_problems(tree)

    affected_hosts = row["aggr_hosts"]
    htmlcode = render_subtree(tree, [tree[2]["title"]], len(affected_hosts) > 1)
    return "aggrtree" + (boxes and "_box" or ""), htmlcode
Ejemplo n.º 6
0

multisite_painters["aggr_treestate"] = {
    "title": _("Aggregation: complete tree"),
    "short": _("Tree"),
    "columns": ["aggr_treestate", "aggr_hosts"],
    "options": ["aggr_expand", "aggr_onlyproblems", "aggr_treetype", "aggr_wrap"],
    "paint": paint_aggregated_tree_state,
}

multisite_painters["aggr_treestate_boxed"] = {
    "title": _("Aggregation: simplistic boxed layout"),
    "short": _("Tree"),
    "columns": ["aggr_treestate", "aggr_hosts"],
    "paint": lambda row: bi.render_tree_foldable(
        row, boxes=True, omit_root=True, expansion_level=bi.load_ex_level(), only_problems=False, lazy=True
    ),
}

#     _____ _ _ _
#    |  ___(_) | |_ ___ _ __ ___
#    | |_  | | | __/ _ \ '__/ __|
#    |  _| | | | ||  __/ |  \__ \
#    |_|   |_|_|\__\___|_|  |___/
#


class BIGroupFilter(Filter):
    def __init__(self):
        self.column = "aggr_group"
        Filter.__init__(self, self.column, _("Aggregation group"), "aggr", [self.column], [self.column])