Exemplo n.º 1
0
def views_by_topic():
    s = [ (view.get("topic", _("Other")), view["title"], name)
          for name, view
          in html.available_views.items()
          if not view["hidden"] and not view.get("mobile")]

    # Add all the dashboards to the views list
    s += [ (_('Dashboards'), d['title'] and d['title'] or d_name, d_name)
           for d_name, d
           in dashboard.permitted_dashboards()
    ]

    s.sort()

    # Enforce a certain order on the topics
    known_topics = [ _('Dashboards'), _("Hosts"), _("Hostgroups"), _("Services"), _("Servicegroups"),
                     _("Business Intelligence"), _("Problems"), _("Addons") ]

    result = []
    for topic in known_topics:
        result.append((topic, s))

    rest = list(set([ t for (t, _t, _v) in s if t not in known_topics ]))
    rest.sort()
    for topic in rest:
        if topic:
            result.append((topic, s))

    return result
Exemplo n.º 2
0
def render_wato_foldertree():
    is_slave_site = not wato.is_distributed() and os.path.exists(
        defaults.check_mk_configdir + "/distributed_wato.mk")
    if not is_slave_site:
        if not config.wato_enabled:
            html.write(_("WATO is disabled."))
            return False

    user_folders = compute_foldertree()

    #
    # Render link target selection
    #
    selected_topic, selected_target = config.load_user_file(
        "foldertree", (_('Hosts'), 'allhosts'))

    views.load_views()
    dashboard.load_dashboards()
    topic_views = visuals_by_topic(views.permitted_views().items() +
                                   dashboard.permitted_dashboards().items())
    topics = [(t, t) for t, s in topic_views]
    html.select("topic",
                topics,
                selected_topic,
                onchange='wato_tree_topic_changed(this)')
    html.write('<span class=left>%s</span>' % _('Topic:'))

    for topic, view_list in topic_views:
        targets = []
        for t, title, name, is_view in view_list:
            if config.visible_views and name not in config.visible_views:
                continue
            if config.hidden_views and name in config.hidden_views:
                continue
            if t == topic:
                if not is_view:
                    name = 'dashboard|' + name
                targets.append((name, title))

        attrs = {}
        if topic != selected_topic:
            attrs['style'] = 'display:none'
            default = ''
        else:
            default = selected_target

        html.select("target_%s" % topic,
                    targets,
                    default,
                    attrs=attrs,
                    onchange='wato_tree_target_changed(this)')

    html.write('<span class=left>%s</span>' % _('View:'))

    # Now render the whole tree
    if user_folders:
        render_tree_folder(user_folders.values()[0], 'wato_tree_click')
Exemplo n.º 3
0
def render_wato_foldertree():
    is_slave_site = not wato.is_distributed() and os.path.exists(defaults.check_mk_configdir + "/distributed_wato.mk")
    if not is_slave_site:
        if not config.wato_enabled:
            html.write(_("WATO is disabled."))
            return False
        elif not config.may("wato.use"):
            html.write(_("You are not allowed to use Check_MK's web configuration GUI."))
            return False

    user_folders = compute_foldertree()

    #
    # Render link target selection
    #
    selected_topic, selected_target = config.load_user_file("foldertree", (_('Hosts'), 'allhosts'))

    views.load_views()
    dashboard.load_dashboards()
    topic_views  = visuals_by_topic(views.permitted_views().items() + dashboard.permitted_dashboards().items())
    topics = [ (t, t) for t, s in topic_views ]
    html.select("topic", topics, selected_topic, onchange = 'wato_tree_topic_changed(this)')
    html.write('<span class=left>%s</span>' % _('Topic:'))

    for topic, view_list in topic_views:
        targets = []
        for t, title, name, is_view in view_list:
            if config.visible_views and name not in config.visible_views:
                continue
            if config.hidden_views and name in config.hidden_views:
                continue
            if t == topic:
                if not is_view:
                    name = 'dashboard|' + name
                targets.append((name, title))

        attrs = {}
        if topic != selected_topic:
            attrs['style'] = 'display:none'
            default = ''
        else:
            default = selected_target

        html.select("target_%s" % topic, targets, default, attrs = attrs, onchange = 'wato_tree_target_changed(this)')

    html.write('<span class=left>%s</span>' % _('View:'))

    # Now render the whole tree
    if user_folders:
        render_tree_folder(user_folders.values()[0], 'wato_tree_click')
Exemplo n.º 4
0
def render_wato_foldertree():
    user_folders = compute_foldertree()

    #
    # Render link target selection
    #
    selected_topic, selected_target = config.load_user_file("foldertree", (_('Hosts'), 'allhosts'))

    views.load_views()
    dashboard.load_dashboards()
    topic_views  = visuals_by_topic(views.permitted_views().items() + dashboard.permitted_dashboards().items())
    topics = [ (t, t) for t, s in topic_views ]
    html.select("topic", topics, selected_topic, onchange = 'wato_tree_topic_changed(this)')
    html.write('<span class=left>%s</span>' % _('Topic:'))

    for topic, view_list in topic_views:
        targets = []
        for t, title, name, is_view in view_list:
            if config.visible_views and name not in config.visible_views:
                continue
            if config.hidden_views and name in config.hidden_views:
                continue
            if t == topic:
                if not is_view:
                    name = 'dashboard|' + name
                targets.append((name, title))

        attrs = {}
        if topic != selected_topic:
            attrs['style'] = 'display:none'
            default = ''
        else:
            default = selected_target

        html.select("target_%s" % topic, targets, default, attrs = attrs, onchange = 'wato_tree_target_changed(this)')

    html.write('<span class=left>%s</span>' % _('View:'))

    # Now render the whole tree
    if user_folders:
        render_tree_folder(user_folders.values()[0], 'wato_tree_click')
Exemplo n.º 5
0
def render_wato_foldertree():
    if not wato.is_wato_slave_site():
        if not config.wato_enabled:
            html.write_text(_("WATO is disabled."))
            return False

    user_folders = compute_foldertree()

    #
    # Render link target selection
    #
    selected_topic, selected_target = config.user.load_file(
        "foldertree", (_('Hosts'), 'allhosts'))

    views.load_views()
    dashboard.load_dashboards()
    topic_views = visuals_by_topic(views.permitted_views().items() +
                                   dashboard.permitted_dashboards().items())
    topics = [(t, t) for t, s in topic_views]

    html.open_table()
    html.open_tr()
    html.td(_('Topic:'), class_="label")
    html.open_td()
    html.select("topic",
                topics,
                selected_topic,
                onchange='wato_tree_topic_changed(this)')
    html.close_td()
    html.close_tr()

    html.open_tr()
    html.td(_("View:"), class_="label")
    html.open_td()

    for topic, view_list in topic_views:
        targets = []
        for t, title, name, is_view in view_list:
            if config.visible_views and name not in config.visible_views:
                continue
            if config.hidden_views and name in config.hidden_views:
                continue
            if t == topic:
                if not is_view:
                    name = 'dashboard|' + name
                targets.append((name, title))

        attrs = {}
        if topic != selected_topic:
            attrs['style'] = 'display:none'
            default = ''
        else:
            default = selected_target

        html.select("target_%s" % topic,
                    targets,
                    default,
                    attrs=attrs,
                    onchange='wato_tree_target_changed(this)')

    html.close_td()
    html.close_tr()
    html.close_table()

    # Now render the whole tree
    if user_folders:
        render_tree_folder("wato-hosts",
                           user_folders.values()[0], 'wato_tree_click')