def _confirm(html_title, message): if not html.request.has_var("_do_confirm") and not html.request.has_var( "_do_actions"): # TODO: get the breadcrumb from all call sites wato_html_head(title=html_title, breadcrumb=Breadcrumb()) confirm_options = [(_("Confirm"), "_do_confirm")] return confirm_with_preview(message, confirm_options)
def do_commands(what: str, rows: Rows) -> bool: confirm_options, title, executor = views.core_command( what, rows[0], 0, len(rows), )[1:4] # just get confirm_options, title and executor confirm_title = _("Do you really want to %s") % title r = confirm_with_preview(confirm_title, confirm_options) if r is not True: return r is None # Show commands on negative answer count = 0 already_executed: Set[str] = set() for nr, row in enumerate(rows): nagios_commands, _confirm_options, title, executor = views.core_command( what, row, nr, len(rows), ) for command in nagios_commands: if command not in already_executed: executor(command, row["site"]) already_executed.add(command) count += 1 if count > 0: html.show_message(_("Successfully sent %d commands.") % count) return True # Show commands again
def do_commands(what: str, rows: Rows) -> bool: title, executor = views.core_command(what, rows[0], 0, len(rows))[1:3] # just get the title title_what = _("hosts") if what == "host" else _("services") r = confirm_with_preview( _("Do you really want to %(title)s the %(count)d %(what)s?") % { "title": title, "count": len(rows), "what": title_what, }) if r is not True: return r is None # Show commands on negative answer count = 0 already_executed: Set[str] = set() for nr, row in enumerate(rows): nagios_commands, title, executor = views.core_command( what, row, nr, len(rows)) for command in nagios_commands: if command not in already_executed: executor(command, row["site"]) already_executed.add(command) count += 1 if count > 0: html.show_message(_("Successfully sent %d commands.") % count) return True # Show commands again