Esempio 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 = 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")
Esempio n. 2
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 = folder_preserving_link([("mode", "edit_auxtag"),
                                           ("edit", aux_tag.id)])
        html.icon_button(edit_url, _("Edit this auxiliary tag"), "edit")
Esempio n. 3
0
    def _show_webauthn_credentials(
            self, webauthn_credentials: dict[str, WebAuthnCredential]) -> None:
        html.div("", id_="webauthn_message")
        forms.header(_("WebAuthn credentials"))

        forms.section(_("Registered credentials"), simple=True)
        if webauthn_credentials:
            self._show_credentials(webauthn_credentials)
        else:
            html.i(_("No credentials registered"))

        forms.end()
Esempio n. 4
0
    def _show_backup_codes(self, backup_codes: Sequence[str]) -> None:
        forms.header(_("Backup codes"))
        forms.section(_("Backup codes"), simple=True)
        if backup_codes:
            html.p(
                _("You have %d unused backup codes left.") % len(backup_codes))
            html.i(
                _("If you regenerate backup codes, you automatically invalidate old codes."
                  ))
        else:
            html.i(_("No backup codes created yet."))

        forms.end()
Esempio 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 = 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")
Esempio n. 6
0
    def _show_tag_group_icons(self,
                              tag_group: cmk.utils.tags.TagGroup) -> None:
        # 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 = folder_preserving_link([("mode", "edit_tag"),
                                           ("edit", tag_group.id)])
        html.icon_button(edit_url, _("Edit this tag group"), "edit")
Esempio n. 7
0
    def page(self):
        with table_element(
                "timeperiods",
                empty_text=_(
                    "There are no timeperiods defined yet.")) as table:
            for name, timeperiod in sorted(self._timeperiods.items()):
                table.row()

                table.cell(_("Actions"), css=["buttons"])
                if name in watolib.timeperiods.builtin_timeperiods():
                    html.i(_("(builtin)"))
                else:
                    self._action_buttons(name)

                table.cell(_("Name"), name)
                table.cell(_("Alias"), timeperiod_spec_alias(timeperiod))
Esempio n. 8
0
    def _show_labels(self, labels, object_type, label_sources):
        forms.section(_("Effective labels"))
        html.open_table(class_="setting")
        html.open_tr()

        html.open_td(class_="reason")
        html.i(_("Explicit, ruleset, discovered"))
        html.close_td()
        html.open_td(class_=["settingvalue", "used"])
        html.write_html(
            cmk.gui.view_utils.render_labels(labels,
                                             object_type,
                                             with_links=False,
                                             label_sources=label_sources))
        html.close_td()

        html.close_tr()
        html.close_table()
Esempio n. 9
0
    def _show_form(self) -> None:
        assert user.id is not None

        credentials = load_two_factor_credentials(user.id)
        webauthn_credentials = credentials["webauthn_credentials"]
        backup_codes = credentials["backup_codes"]

        html.begin_form("two_factor", method="POST")
        html.div("", id_="webauthn_message")
        forms.header(_("Credentials"))

        forms.section(_("Registered credentials"), simple=True)
        if webauthn_credentials:
            self._show_credentials(webauthn_credentials)
        else:
            html.i(_("No credentials registered"))

        forms.section(_("Backup codes"), simple=True)
        if backup_codes:
            html.p(
                _("You have %d unused backup codes left. You can use them as one-time password "
                  "if your key is not available.") % len(backup_codes))
            html.i(
                _("If you regenerate backup codes, you automatically invalidate the existing codes."
                  ))
        else:
            html.i(_("No backup codes created yet."))

        forms.end()

        html.hidden_fields()
        html.end_form()
        html.footer()