Exemplo n.º 1
0
 def _page_menu_filter_bar(self) -> PageMenuEntry:
     return PageMenuEntry(
         title=_("Filter view"),
         icon_name="filter_line",
         item=PageMenuPopup(self._render_filter_form()),
         name="filters",
     )
Exemplo n.º 2
0
    def _extend_display_dropdown(self, menu: PageMenu) -> None:
        display_dropdown = menu.get_dropdown_by_name("display", make_display_options_dropdown())

        display_dropdown.topics.insert(
            0,
            PageMenuTopic(
                title=_("Filter"),
                entries=[
                    PageMenuEntry(
                        title=_("Filter view"),
                        icon_name="filters_set" if html.form_submitted("options") else "filters",
                        item=PageMenuPopup(self._render_filter_form()),
                        name="filters",
                        is_shortcut=True,
                    ),
                ],
            ))
Exemplo n.º 3
0
def _extend_display_dropdown(menu, werk_table_options: Dict[str, Any]) -> None:
    display_dropdown = menu.get_dropdown_by_name(
        "display", make_display_options_dropdown())
    display_dropdown.topics.insert(
        0,
        PageMenuTopic(
            title=_("Filter"),
            entries=[
                PageMenuEntry(
                    title=_("Filter view"),
                    icon_name="filters",
                    item=PageMenuPopup(
                        _render_werk_options_form(werk_table_options),
                        css_classes=["side_popup"],
                    ),
                    name="filters",
                    is_shortcut=True,
                ),
            ],
        ))
Exemplo n.º 4
0
    def _page_menu_entries_selected_hosts(self) -> Iterator[PageMenuEntry]:
        if not config.user.may("wato.edit_hosts") and not config.user.may("wato.manage_hosts"):
            return

        hostnames = sorted(self._folder.hosts().keys(), key=utils.key_num_split)
        search_text = html.request.var("search")

        # Remember if that host has a target folder (i.e. was imported with
        # a folder information but not yet moved to that folder). If at least
        # one host has a target folder, then we show an additional bulk action.
        at_least_one_imported = False
        for hostname in hostnames:
            if search_text and (search_text.lower() not in hostname.lower()):
                continue

            host = self._folder.host(hostname)
            effective = host.effective_attributes()

            if effective.get("imported_folder"):
                at_least_one_imported = True

        if not self._folder.locked_hosts():
            if config.user.may("wato.manage_hosts"):
                yield PageMenuEntry(
                    title=_("Delete hosts"),
                    icon_name="delete",
                    item=make_form_submit_link(
                        form_name="hosts",
                        button_name="_bulk_delete",
                    ),
                )

            if config.user.may("wato.edit_hosts"):
                yield PageMenuEntry(
                    title=_("Edit attributes"),
                    icon_name="edit",
                    item=make_form_submit_link(
                        form_name="hosts",
                        button_name="_bulk_edit",
                    ),
                )

                yield PageMenuEntry(
                    title=_("Remove explicit attribute settings"),
                    icon_name="cleanup",
                    item=make_form_submit_link(
                        form_name="hosts",
                        button_name="_bulk_cleanup",
                    ),
                )

        if config.user.may("wato.services"):
            yield PageMenuEntry(
                title=_("Discover services"),
                icon_name="services",
                item=make_form_submit_link(
                    form_name="hosts",
                    button_name="_bulk_inventory",
                ),
            )

        if not self._folder.locked_hosts():
            if config.user.may("wato.parentscan"):
                yield PageMenuEntry(
                    title=_("Detect network parent hosts"),
                    icon_name="parentscan",
                    item=make_form_submit_link(
                        form_name="hosts",
                        button_name="_parentscan",
                    ),
                )
            if config.user.may("wato.edit_hosts") and config.user.may("wato.move_hosts"):
                yield PageMenuEntry(
                    title=_("Move to other folder"),
                    icon_name="move",
                    name="move_rules",
                    item=PageMenuPopup(self._render_bulk_move_form()),
                )

                if at_least_one_imported:
                    yield PageMenuEntry(
                        title=_("Move to target folders"),
                        icon_name="move",
                        item=make_form_submit_link(
                            form_name="hosts",
                            button_name="_bulk_movetotarget",
                        ),
                    )
Exemplo n.º 5
0
    def _page_menu_entries_selected_hosts(self) -> Iterator[PageMenuEntry]:
        if not config.user.may("wato.edit_hosts") and not config.user.may("wato.manage_hosts"):
            return

        hostnames = sorted(self._folder.hosts().keys(), key=utils.key_num_split)
        is_enabled = bool(self._folder.has_hosts())
        search_text = html.request.var("search")

        # Remember if that host has a target folder (i.e. was imported with
        # a folder information but not yet moved to that folder). If at least
        # one host has a target folder, then we show an additional bulk action.
        at_least_one_imported = False
        for hostname in hostnames:
            if search_text and (search_text.lower() not in hostname.lower()):
                continue

            host = self._folder.host(hostname)
            effective = host.effective_attributes()

            if effective.get("imported_folder"):
                at_least_one_imported = True

        if not self._folder.locked_hosts():
            if config.user.may("wato.manage_hosts"):
                yield PageMenuEntry(
                    title=_("Delete hosts"),
                    icon_name="delete",
                    item=make_confirmed_form_submit_link(
                        form_name="hosts",
                        button_name="_bulk_delete",
                        message=_("Do you really want to delete the selected hosts?"),
                    ),
                    is_enabled=is_enabled,
                )

            if config.user.may("wato.edit_hosts"):
                yield PageMenuEntry(
                    title=_("Edit attributes"),
                    icon_name="edit",
                    item=make_form_submit_link(
                        form_name="hosts",
                        button_name="_bulk_edit",
                    ),
                    is_enabled=is_enabled,
                )

                yield PageMenuEntry(
                    title=_("Remove explicit attribute settings"),
                    icon_name="cleanup",
                    item=make_form_submit_link(
                        form_name="hosts",
                        button_name="_bulk_cleanup",
                    ),
                    is_enabled=is_enabled,
                )

        if config.user.may("wato.services"):
            yield PageMenuEntry(
                title=_("Discover services"),
                icon_name="services",
                item=make_form_submit_link(
                    form_name="hosts",
                    button_name="_bulk_inventory",
                ),
                is_enabled=is_enabled,
            )

        if not self._folder.locked_hosts():
            if config.user.may("wato.parentscan"):
                yield PageMenuEntry(
                    title=_("Detect network parent hosts"),
                    icon_name="parentscan",
                    item=make_form_submit_link(
                        form_name="hosts",
                        button_name="_parentscan",
                    ),
                    is_enabled=is_enabled,
                )
            if config.user.may("wato.edit_hosts") and config.user.may("wato.move_hosts"):
                yield PageMenuEntry(
                    title=_("Move to other folder"),
                    icon_name="move",
                    name="move_rules",
                    item=PageMenuPopup(self._render_bulk_move_form()),
                    is_enabled=is_enabled,
                )

                if at_least_one_imported:
                    yield PageMenuEntry(
                        title=_("Move to target folders"),
                        icon_name="move",
                        item=make_confirmed_form_submit_link(
                            form_name="hosts",
                            button_name="_bulk_movetotarget",
                            message=_('You are going to move the selected hosts to folders '
                                      'representing their original folder location in the system '
                                      'you did the import from. Please make sure that you have '
                                      'done an <b>inventory</b> before moving the hosts.'),
                        ),
                        is_enabled=is_enabled,
                    )