예제 #1
0
파일: wato.py 프로젝트: ypid/check_mk
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')
예제 #2
0
파일: wato.py 프로젝트: ShMaunder/check_mk
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')
예제 #3
0
    def render_delete_event_icons(row):
        if config.user.may("mkeventd.delete"):
            urlvars = []

            # Found no cleaner way to get the view. Sorry.
            # TODO: This needs to be cleaned up with the new view implementation.
            if html.has_var("name") and html.has_var("id"):
                ident = int(html.var("id"))

                import dashboard
                dashboard.load_dashboards()
                view = dashboard.get_dashlet(html.var("name"), ident)

                # These actions are not performed within the dashlet. Assume the title url still
                # links to the source view where the action can be performed.
                title_url = view.get("title_url")
                if title_url:
                    from urlparse import urlparse, parse_qsl
                    url = urlparse(title_url)
                    filename = url.path
                    urlvars += parse_qsl(url.query)
            else:
                # Regular view
                view = permitted_views()[(html.var("view_name"))]
                target = None
                filename = None

            urlvars += [
                ("filled_in", "actions"),
                ("actions", "yes"),
                ("_do_actions", "yes"),
                ("_row_id", row_id(view, row)),
                ("_delete_event", _("Archive Event")),
                ("_show_result", "0"),
            ]
            url = html.makeactionuri(urlvars,
                                     filename=filename,
                                     delvars=["selection", "show_checkboxes"])
            return html.render_icon_button(url, _("Archive this event"),
                                           "delete")
        else:
            return ''
예제 #4
0
파일: wato.py 프로젝트: iceman1989/Check_mk
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')
예제 #5
0
    def render_delete_event_icons(row):
        if config.may("mkeventd.delete"):
            urlvars = []

            # Found no cleaner way to get the view. Sorry.
            # TODO: This needs to be cleaned up with the new view implementation.
            if html.has_var("name") and html.has_var("id"):
                ident = int(html.var("id"))

                import dashboard
                dashboard.load_dashboards()
                view = dashboard.get_dashlet(html.var("name"), ident)

                # These actions are not performed within the dashlet. Assume the title url still
                # links to the source view where the action can be performed.
                title_url = view.get("title_url")
                if title_url:
                    from urlparse import urlparse, parse_qsl
                    url = urlparse(title_url)
                    filename = url.path
                    urlvars += parse_qsl(url.query)
            else:
                # Regular view
                view = get_view_by_name(html.var("view_name"))
                target = None
                filename = None

            urlvars += [
                ("filled_in", "actions"),
                ("actions", "yes"),
                ("_do_actions", "yes"),
                ("_row_id", row_id(view, row)),
                ("_delete_event", _("Archive Event")),
                ("_show_result", "0"),
            ]
            url = html.makeactionuri(urlvars, filename=filename)
            return html.render_icon_button(url, _("Archive this event"), "delete")
        else:
            return ''
예제 #6
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')