Пример #1
0
 def _show_row_cells(self, table: Table, name: GroupName,
                     group: GroupSpec) -> None:
     super()._show_row_cells(table, name, group)
     table.cell(_("Members"))
     html.write_html(
         HTML(", ").join([
             html.render_a(
                 alias,
                 href=watolib.folder_preserving_link([("mode", "edit_user"),
                                                      ("edit", userid)]),
             ) for userid, alias in self._members.get(name, [])
         ]))
Пример #2
0
    def _show_aux_tag_row(self, table: Table,
                          aux_tag: cmk.utils.tags.AuxTag) -> None:
        table.row()

        table.cell(_("Actions"), css="buttons")
        self._show_aux_tag_icons(aux_tag)

        table.text_cell(_("Tag"), _u(aux_tag.choice_title))
        table.text_cell(_("Used by tags"))
        _show_aux_tag_used_by_tags(self._get_tags_using_aux_tag(aux_tag))

        # TODO: This check shouldn't be necessary if we get our types right.
        if aux_tag.id is None:
            raise Exception("uninitialized tag")
        operation = OperationRemoveAuxTag(aux_tag.id)
        affected_folders, affected_hosts, affected_rulesets = \
            change_host_tags_in_folders(operation, TagCleanupMode.CHECK, watolib.Folder.root_folder())

        table.cell(_("Explicitly set on folders"))
        if affected_folders:
            _show_affected_folders(affected_folders)

        table.cell(_("Explicitly set on hosts"))
        if affected_hosts:
            _show_affected_hosts(affected_hosts)

        table.cell(_("Used in rulesets"))
        if affected_rulesets:
            _show_affected_rulesets(affected_rulesets)
Пример #3
0
    def _show_tag_row(self, table: Table, tag_group: cmk.utils.tags.TagGroup,
                      tag: cmk.utils.tags.GroupedTag) -> None:
        table.row()

        table.cell(_("Actions"), css="buttons")
        self._show_tag_group_icons(tag_group)

        table.text_cell(_("Tag group"), _u(tag_group.choice_title))
        # TODO: This check shouldn't be necessary if we get our types right.
        if tag.title is None or tag.id is None or tag_group.id is None:
            raise Exception("uninitialized tag/tag group")
        table.text_cell(_("Tag"), _u(tag.title))

        operation = OperationReplaceGroupedTags(tag_group.id,
                                                remove_tag_ids=[tag.id],
                                                replace_tag_ids={})
        affected_folders, affected_hosts, affected_rulesets = \
            change_host_tags_in_folders(operation, TagCleanupMode.CHECK, watolib.Folder.root_folder())

        table.cell(_("Explicitly set on folders"))
        if affected_folders:
            _show_affected_folders(affected_folders)

        table.cell(_("Explicitly set on hosts"))
        if affected_hosts:
            _show_affected_hosts(affected_hosts)

        table.cell(_("Used in rulesets"))
        if affected_rulesets:
            _show_affected_rulesets(affected_rulesets)
Пример #4
0
    def _show_action_cell(self, table: Table, ident: str) -> None:
        table.cell(_("Actions"), css=["buttons"])

        edit_url = makeuri_contextless(
            request,
            [
                ("mode", self._mode_type.edit_mode_name()),
                ("ident", ident),
            ],
        )
        html.icon_button(edit_url,
                         _("Edit this %s") % self._mode_type.name_singular(),
                         "edit")

        clone_url = makeuri_contextless(
            request,
            [
                ("mode", self._mode_type.edit_mode_name()),
                ("clone", ident),
            ],
        )
        html.icon_button(clone_url,
                         _("Clone this %s") % self._mode_type.name_singular(),
                         "clone")

        delete_url = make_confirm_link(
            url=make_action_link([
                ("mode", self._mode_type.list_mode_name()),
                ("_action", "delete"),
                ("_delete", ident),
            ]),
            message=self._delete_confirm_message(),
        )
        html.icon_button(delete_url,
                         _("Delete this %s") % self._mode_type.name_singular(),
                         "delete")
Пример #5
0
    def cells_from_row(table: Table, group_titles: List[str], group_cells: List[str],
                       object_titles: List[str], cell_titles: List[str], row_object: AVObjectCells,
                       row_cells: AVRowCells) -> None:
        for column_title, group_title in zip(group_titles, group_cells):
            table.cell(column_title, group_title)

        for title, (name, _url) in zip(object_titles, row_object):
            table.cell(title, name)

        for title, (text, _css) in zip(cell_titles, row_cells):
            table.cell(title, text)
Пример #6
0
 def _show_entry_cells(self, table: Table, ident: str, entry: Password) -> None:
     table.cell(_("Title"), entry["title"])
     table.cell(_("Editable by"))
     if entry["owned_by"] is None:
         html.write_text(
             _("Administrators (having the permission " '"Write access to all passwords")')
         )
     else:
         html.write_text(self._contact_group_alias(entry["owned_by"]))
     table.cell(_("Shared with"))
     if not entry["shared_with"]:
         html.write_text(_("Not shared"))
     else:
         html.write_text(", ".join([self._contact_group_alias(g) for g in entry["shared_with"]]))
Пример #7
0
    def _show_row_cells(self, table: Table, name: GroupName, group: GroupSpec) -> None:
        table.cell(_("Actions"), css="buttons")
        edit_url = watolib.folder_preserving_link(
            [("mode", "edit_%s_group" % self.type_name), ("edit", name)]
        )
        delete_url = make_confirm_link(
            url=makeactionuri(request, transactions, [("_delete", name)]),
            message=_('Do you really want to delete the %s group "%s"?') % (self.type_name, name),
        )
        clone_url = watolib.folder_preserving_link(
            [("mode", "edit_%s_group" % self.type_name), ("clone", name)]
        )
        html.icon_button(edit_url, _("Properties"), "edit")
        html.icon_button(clone_url, _("Create a copy of this group"), "clone")
        html.icon_button(delete_url, _("Delete"), "delete")

        table.cell(_("Name"), name)
        table.cell(_("Alias"), group["alias"])