Ejemplo n.º 1
0
    def _show_tag_icons(self, tag_group, nr):
        # Tag groups were made builtin with ~1.4. Previously users could modify
        # these groups.  These users now have the modified tag groups in their
        # user configuration and should be able to cleanup this using the GUI
        # for the moment. Make the buttons available to the users.
        if self._builtin_config.tag_group_exists(
                tag_group.id) and not self._tag_config.tag_group_exists(
                    tag_group.id):
            html.i("(%s)" % _("builtin"))
            return

        edit_url = watolib.folder_preserving_link([("mode", "edit_tag"),
                                                   ("edit", tag_group.id)])
        html.icon_button(edit_url, _("Edit this tag group"), "edit")

        html.element_dragger_url("tr",
                                 base_url=make_action_link([("mode", "tags"),
                                                            ("_move", nr)]))

        delete_url = make_confirm_link(
            url=make_action_link([("mode", "tags"),
                                  ("_delete", tag_group.id)]),
            message=_("Do you really want to delete the tag group '%s'?") %
            tag_group.id,
        )
        html.icon_button(delete_url, _("Delete this tag group"), "delete")
Ejemplo n.º 2
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.º 3
0
    def page(self) -> None:
        html.p(
            _("Here you can add icons, for example to use them in bookmarks or "
              "in custom actions of views. Allowed are single PNG image files "
              "with a maximum size of 80x80 px. Custom actions have to be defined "
              "in the global settings and can be used in the custom icons rules "
              "of hosts and services."))

        html.begin_form("upload_form", method="POST")
        self._vs_upload().render_input("_upload_icon", None)
        html.hidden_fields()
        html.end_form()

        icons = sorted(self._load_custom_icons().items())
        with table_element("icons", _("Custom Icons")) as table:
            for icon_name, category_name in icons:
                table.row()

                table.cell(_("Actions"), css="buttons")
                delete_url = make_confirm_link(
                    url=make_action_link([("mode", "icons"),
                                          ("_delete", icon_name)]),
                    message=_(
                        "Do you really want to delete the icon <b>%s</b>?") %
                    icon_name,
                )
                html.icon_button(delete_url, _("Delete this Icon"), "delete")

                table.cell(_("Icon"),
                           html.render_icon(icon_name),
                           css="buttons")
                table.cell(_("Name"), icon_name)
                table.cell(_("Category"),
                           IconSelector.category_alias(category_name))
Ejemplo n.º 4
0
    def _action_buttons(self, name):
        edit_url = watolib.folder_preserving_link(
            [
                ("mode", "edit_timeperiod"),
                ("edit", name),
            ]
        )
        clone_url = watolib.folder_preserving_link(
            [
                ("mode", "edit_timeperiod"),
                ("clone", name),
            ]
        )
        delete_url = make_confirm_link(
            url=make_action_link(
                [
                    ("mode", "timeperiods"),
                    ("_delete", name),
                ]
            ),
            message=_("Do you really want to delete the time period '%s'?") % name,
        )

        html.icon_button(edit_url, _("Properties"), "edit")
        html.icon_button(clone_url, _("Create a copy"), "clone")
        html.icon_button(delete_url, _("Delete"), "delete")
Ejemplo n.º 5
0
    def _show_aux_tag_icons(self, aux_tag: cmk.utils.tags.AuxTag) -> None:
        if aux_tag.id in self._builtin_config.aux_tag_list.get_tag_ids():
            html.i("(%s)" % _("builtin"))
            return

        edit_url = watolib.folder_preserving_link([("mode", "edit_auxtag"), ("edit", aux_tag.id)])
        delete_url = make_confirm_link(
            url=make_action_link([("mode", "tags"), ("_del_aux", aux_tag.id)]),
            message=_("Do you really want to delete the auxiliary tag '%s'?") % aux_tag.id,
        )
        html.icon_button(edit_url, _("Edit this auxiliary tag"), "edit")
        html.icon_button(delete_url, _("Delete this auxiliary tag"), "delete")
Ejemplo n.º 6
0
    def page(self):
        with table_element("roles") as table:

            users = userdb.load_users()
            for rid, role in sorted(self._roles.items(),
                                    key=lambda a: (a[1]["alias"], a[0])):
                table.row()

                # Actions
                table.cell(_("Actions"), css="buttons")
                edit_url = watolib.folder_preserving_link([("mode",
                                                            "edit_role"),
                                                           ("edit", rid)])
                clone_url = make_action_link([("mode", "roles"),
                                              ("_clone", rid)])
                delete_url = make_confirm_link(
                    url=make_action_link([("mode", "roles"),
                                          ("_delete", rid)]),
                    message=_("Do you really want to delete the role %s?") %
                    rid,
                )
                html.icon_button(edit_url, _("Properties"), "edit")
                html.icon_button(clone_url, _("Clone"), "clone")
                if not role.get("builtin"):
                    html.icon_button(delete_url, _("Delete this role"),
                                     "delete")

                # ID
                table.cell(_("Name"), rid)

                # Alias
                table.cell(_("Alias"), role["alias"])

                # Type
                table.cell(
                    _("Type"),
                    _("builtin") if role.get("builtin") else _("custom"))

                # Modifications
                table.cell(
                    _("Modifications"),
                    html.render_span(
                        str(len(role["permissions"])),
                        title=
                        _("That many permissions do not use the factory defaults."
                          ),
                    ),
                )

                # Users
                table.cell(
                    _("Users"),
                    HTML(", ").join([
                        html.render_a(
                            user.get("alias", user_id),
                            watolib.folder_preserving_link([
                                ("mode", "edit_user"), ("edit", user_id)
                            ]),
                        ) for (user_id, user) in users.items()
                        if rid in user["roles"]
                    ]),
                )