Ejemplo n.º 1
0
    def page(self):
        with table_element() as table:
            for index, connection in enumerate(load_connection_config()):
                table.row()

                table.cell(_("Actions"), css="buttons")
                edit_url = watolib.folder_preserving_link([
                    ("mode", "edit_ldap_connection"), ("id", connection["id"])
                ])
                delete_url = make_confirm_link(
                    url=make_action_link([("mode", "ldap_config"),
                                          ("_delete", index)]),
                    message=
                    _("Do you really want to delete the LDAP connection <b>%s</b>?"
                      ) % connection["id"],
                )
                drag_url = make_action_link([("mode", "ldap_config"),
                                             ("_move", index)])
                clone_url = watolib.folder_preserving_link([
                    ("mode", "edit_ldap_connection"),
                    ("clone", connection["id"])
                ])

                html.icon_button(edit_url, _("Edit this LDAP connection"),
                                 "edit")
                html.icon_button(clone_url,
                                 _("Create a copy of this LDAP connection"),
                                 "clone")
                html.element_dragger_url("tr", base_url=drag_url)
                html.icon_button(delete_url, _("Delete this LDAP connection"),
                                 "delete")

                table.cell("", css="narrow")
                if connection.get("disabled"):
                    html.icon(
                        "disabled",
                        _("This connection is currently not being used for synchronization."
                          ),
                    )
                else:
                    html.empty_icon_button()

                table.cell(_("ID"), connection["id"])

                if cmk_version.is_managed_edition():
                    table.cell(_("Customer"),
                               managed.get_customer_name(connection))

                table.cell(_("Description"))
                url = connection.get("docu_url")
                if url:
                    html.icon_button(
                        url,
                        _("Context information about this connection"),
                        "url",
                        target="_blank")
                    html.write_text("&nbsp;")
                html.write_text(connection["description"])
Ejemplo n.º 2
0
    def _display_page_controls(self, start_time, end_time, previous_log_time, next_log_time):
        html.open_div(class_="paged_controls")

        def time_url_args(t):
            return [
                ("options_p_start_1_day", time.strftime("%d", time.localtime(t))),
                ("options_p_start_1_month", time.strftime("%m", time.localtime(t))),
                ("options_p_start_1_year", time.strftime("%Y", time.localtime(t))),
                ("options_p_start_sel", "1"),
            ]

        if next_log_time is not None:
            html.icon_button(html.makeactionuri([
                ("options_p_start_sel", "0"),
            ]), _("Most recent events"), "start")

            html.icon_button(html.makeactionuri(time_url_args(next_log_time)),
                             "%s: %s" % (_("Newer events"), render.date(next_log_time)), "back")
        else:
            html.empty_icon_button()
            html.empty_icon_button()

        if previous_log_time is not None:
            html.icon_button(html.makeactionuri(time_url_args(previous_log_time)),
                             "%s: %s" % (_("Older events"), render.date(previous_log_time)),
                             "forth")
        else:
            html.empty_icon_button()

        html.close_div()