def page_login(): title = _("Check_MK Mobile") mobile_html_head(title) jqm_page_header(title, id_="login") html.div(_("Welcome to Check_MK Mobile."), id_="loginhead") html.begin_form("login", method='POST', add_transid=False) # Keep information about original target URL origtarget = html.request.var('_origtarget', '') if not origtarget and not html.myfile == 'login': origtarget = html.request.requested_url html.hidden_field('_origtarget', html.attrencode(origtarget)) html.text_input("_username", label=_("Username:"******"_password", size=None, label=_("Password:"******"_login", _('Login')) html.set_focus("_username") html.end_form() html.open_div(id_="loginfoot") html.img("themes/classic/images/logo_cmk_small.png", class_="logomk") html.div(HTML( _("© <a target=\"_blank\" href=\"https://checkmk.com\">tribe29 GmbH</a>" )), class_="copyright") jqm_page_footer() mobile_html_foot()
def render(self, what): html.open_div(class_="group") html.text_input("_ack_comment", id_="ack_comment", size=60, submit="_acknowledge", label=_("Comment"), required=True) html.close_div() html.open_div(class_="group") html.checkbox("_ack_sticky", config.view_action_defaults["ack_sticky"], label=_("sticky")) html.checkbox("_ack_notify", config.view_action_defaults["ack_notify"], label=_("send notification")) html.checkbox("_ack_persistent", config.view_action_defaults["ack_persistent"], label=_('persistent comment')) html.close_div() html.open_div(class_="group") self._vs_expire().render_input("_ack_expire", config.view_action_defaults.get("ack_expire", 0)) html.help( _("Note: Expiration of acknowledgements only works when using the Checkmk Micro Core.")) html.close_div() html.open_div(class_="group") html.button("_acknowledge", _("Acknowledge"), cssclass="hot") html.button("_remove_ack", _("Remove acknowledgement"), formnovalidate=True) html.close_div()
def inpage_search_form(mode: Optional[str] = None, default_value: str = "") -> None: form_name = "inpage_search_form" reset_button_id = "%s_reset" % form_name was_submitted = request.get_ascii_input("filled_in") == form_name html.begin_form(form_name, add_transid=False) html.text_input( "search", size=32, default_value=default_value, placeholder=_("Filter"), required=True, title="", ) html.hidden_fields() if mode: html.hidden_field("mode", mode, add_var=True) reset_url = request.get_ascii_input_mandatory( "reset_url", requested_file_with_query(request)) html.hidden_field("reset_url", reset_url, add_var=True) html.button("submit", "", cssclass="submit", help_=_("Apply")) html.buttonlink(reset_url, "", obj_id=reset_button_id, title=_("Reset")) html.end_form() html.javascript("cmk.page_menu.inpage_search_init(%s, %s)" % (json.dumps(reset_button_id), json.dumps(was_submitted)))
def page_login() -> None: title = _("Check_MK Mobile") mobile_html_head(title) jqm_page_header(title, id_="login") html.div(_("Welcome to Check_MK Mobile."), id_="loginhead") html.begin_form("login", method='POST', add_transid=False) # Keep information about original target URL default_origtarget = "index.py" if html.myfile in ["login", "logout" ] else html.makeuri([]) origtarget = html.get_url_input("_origtarget", default_origtarget) html.hidden_field('_origtarget', escaping.escape_attribute(origtarget)) html.text_input("_username", label=_("Username:"******"username") html.password_input("_password", size=None, label=_("Password:"******"current-password") html.br() html.button("_login", _('Login')) html.set_focus("_username") html.end_form() html.open_div(id_="loginfoot") html.img("themes/classic/images/logo_cmk_small.png", class_="logomk") html.div(HTML( _("© <a target=\"_blank\" href=\"https://checkmk.com\">tribe29 GmbH</a>" )), class_="copyright") html.close_div() # close content-div html.close_div() html.close_div() # close page-div mobile_html_foot()
def display(self): # type: () -> None html.write_text(_("Min. Version:")) html.text_input(self.htmlvars[0], size=7) html.write_text(" ") html.write_text(_("Max. Version:")) html.text_input(self.htmlvars[1], size=7)
def page(self): html.help( _( "The renaming of hosts is a complex operation since a host's name is being " "used as a unique key in various places. It also involves stopping and starting " "of the monitoring core. You cannot rename a host while you have pending changes." ) ) html.begin_form("rename_host", method="POST") html.add_confirm_on_submit( "rename_host", _( "Are you sure you want to rename the host <b>%s</b>? " "This involves a restart of the monitoring core!" ) % (self._host.name()), ) forms.header(_("Rename host %s") % self._host.name()) forms.section(_("Current name")) html.write_text(self._host.name()) forms.section(_("New name")) html.text_input("newname", "") forms.end() html.set_focus("newname") html.hidden_fields() html.end_form()
def page(self): # type: () -> None html.begin_form("group") forms.header(_("Properties")) forms.section(_("Name"), simple=not self._new) html.help( _("The name of the group is used as an internal key. It cannot be " "changed later. It is also visible in the status GUI.")) if self._new: html.text_input("name") html.set_focus("name") else: html.write_text(self._name) html.set_focus("alias") forms.section(_("Alias")) html.help(_("An Alias or description of this group.")) html.text_input("alias", self.group["alias"]) self._show_extra_page_elements() forms.end() html.button("save", _("Save")) html.hidden_fields() html.end_form()
def render(self, what): html.write_text(_('Downtime Comment') + ": ") html.text_input("_down_comment", "", size=60, submit="") html.hr() html.button("_down_from_now", _("From now for")) html.nbsp() html.number_input("_down_minutes", 60, size=4, submit="_down_from_now") html.write_text(" " + _("minutes")) html.hr() for time_range in config.user_downtime_timeranges: html.button("_downrange__%s" % time_range['end'], _u(time_range['title'])) if what != "aggr" and config.user.may("action.remove_all_downtimes"): html.write_text(" - ") html.button("_down_remove", _("Remove all")) html.hr() if config.adhoc_downtime and config.adhoc_downtime.get("duration"): adhoc_duration = config.adhoc_downtime.get("duration") adhoc_comment = config.adhoc_downtime.get("comment", "") html.button("_down_adhoc", _("Adhoc for %d minutes") % adhoc_duration) html.nbsp() html.write_text(_('with comment') + ": ") html.write(adhoc_comment) html.hr() html.button("_down_custom", _("Custom time range")) html.datetime_input("_down_from", time.time(), submit="_down_custom") html.write_text(" " + _('to') + " ") html.datetime_input("_down_to", time.time() + 7200, submit="_down_custom") html.hr() html.checkbox("_down_flexible", False, label="%s " % _('flexible with max. duration')) html.time_input("_down_duration", 2, 0) html.write_text(" " + _('(HH:MM)')) if what == "host": html.hr() html.checkbox("_include_childs", False, label=_('Also set downtime on child hosts')) html.write_text(" ") html.checkbox("_include_childs_recurse", False, label=_('Do this recursively')) elif what == "service": html.hr() html.checkbox("_on_hosts", False, label=_('Schedule downtimes on the affected ' '<b>hosts</b> instead of on the individual ' 'services')) if self._has_recurring_downtimes(): html.hr() html.checkbox("_down_do_recur", False, label=_("Repeat this downtime on a regular basis every")) html.write_text(" ") from cmk.gui.cee.plugins.wato.cmc import recurring_downtimes_types # pylint: disable=no-name-in-module recurring_selections = [ (str(k), v) for (k, v) in sorted(recurring_downtimes_types().items()) ] html.dropdown("_down_recurring", recurring_selections, deflt="3") html.write_text(_("(This only works when using CMC)"))
def display(self, value: FilterHTTPVariables) -> None: current_value = value.get(self.query_filter.request_vars[0], "") html.text_input( self.htmlvars[0], current_value, self.query_filter.negateable and "neg" or "" ) if self.query_filter.negateable: checkbox_component(self.query_filter.request_vars[1], value, _("negate"))
def render(self, what): html.write_text(_('Comment') + ": ") html.text_input("_cusnot_comment", "TEST", size=20, submit="_customnotification") html.write_text(" ") html.checkbox("_cusnot_forced", False, label=_("forced")) html.checkbox("_cusnot_broadcast", False, label=_("broadcast")) html.write_text(" ") html.button("_customnotification", _('Send'))
def render(self, what): html.button("_resched_checks", _("Reschedule")) html.write_text(" " + _("and spread over") + " ") html.text_input("_resched_spread", default_value="0", size=3, cssclass="number") html.write_text(" " + _("minutes") + " ")
def render(self, what): html.open_div(class_="group") html.write_text(_("Spread over") + " ") html.text_input("_resched_spread", default_value="0", size=3, cssclass="number") html.write_text(" " + _("minutes")) html.close_div() html.div(html.render_button("_resched_checks", _("Reschedule"), cssclass="hot"), class_="group")
def display(self, value: FilterHTTPVariables) -> None: html.write_text(_("Min. Version:")) html.text_input(self.htmlvars[0], default_value=value.get(self.htmlvars[0], ""), size=7) html.write_text(" ") html.write_text(_("Max. Version:")) html.text_input(self.htmlvars[1], default_value=value.get(self.htmlvars[1], ""), size=7)
def render(self, what): html.open_div(class_="group") html.write_text(_('Comment') + ": ") html.text_input("_comment", size=33, submit="_add_comment") html.close_div() html.div(html.render_button("_add_comment", _("Add comment"), cssclass="hot"), class_="group")
def page(self): # TODO: remove subclass specific things specifict things (everything with _type == 'user') html.begin_form("attr") forms.header(_("Properties")) forms.section(_("Name"), simple=not self._new) html.help( _("The name of the attribute is used as an internal key. It cannot be " "changed later.")) if self._new: html.text_input("name", self._attr.get('name', '')) html.set_focus("name") else: html.write_text(self._name) html.set_focus("title") forms.section(_("Title") + "<sup>*</sup>") html.help(_("The title is used to label this attribute.")) html.text_input("title", self._attr.get('title', '')) forms.section(_('Topic')) html.help( _('The attribute is added to this section in the edit dialog.')) html.dropdown('topic', self._topics, deflt=self._attr.get('topic', self._default_topic)) forms.section(_('Help Text') + "<sup>*</sup>") html.help( _('You might want to add some helpful description for the attribute.' )) html.text_area('help', self._attr.get('help', '')) forms.section(_('Data type')) html.help(_('The type of information to be stored in this attribute.')) if self._new: html.dropdown('type', custom_attr_types(), deflt=self._attr.get('type', '')) else: html.write(dict(custom_attr_types())[self._attr.get('type')]) self._add_extra_form_sections() self._show_in_table_option() forms.section(_('Add to monitoring configuration')) html.help(self._macro_help) html.checkbox('add_custom_macro', self._attr.get('add_custom_macro', False), label=self._macro_label) forms.end() html.show_localization_hint() html.button("save", _("Save")) html.hidden_fields() html.end_form()
def display(self, value: FilterHTTPVariables) -> None: html.write_text(_("from:") + " ") html.text_input(self.ident + "_from", default_value=value.get(self.ident + "_from", ""), size=8, cssclass="number") html.write_text(" %s: " % _("to")) html.text_input(self.ident + "_to", default_value=value.get(self.ident + "_to", ""), size=8, cssclass="number")
def search_form(title=None, mode=None, default_value=""): html.begin_form("search", add_transid=False) if title: html.write_text(title + ' ') html.text_input("search", size=32, default_value=default_value) html.hidden_fields() if mode: html.hidden_field("mode", mode, add_var=True) html.set_focus("search") html.write_text(" ") html.button("_do_seach", _("Search")) html.end_form()
def render(self, what): html.open_div(class_="group") html.text_input("_comment", id_="comment", size=60, submit="_add_comment", label=_("Comment"), required=True) html.close_div() html.div(html.render_button("_add_comment", _("Add comment"), cssclass="hot"), class_="group")
def display(self, value: FilterHTTPVariables) -> None: html.write_text(_("From: ")) htmlvar = self.htmlvars[0] current_value = value.get(htmlvar, "") html.text_input(htmlvar, default_value=current_value, size=8, cssclass="number") if self._unit: html.write_text(" %s" % self._unit) html.write_text(" " + _("To: ")) htmlvar = self.htmlvars[1] current_value = value.get(htmlvar, "") html.text_input(htmlvar, default_value=current_value, size=8, cssclass="number") if self._unit: html.write_text(" %s" % self._unit)
def test_text_input(request_context): with output_funnel.plugged(): html.text_input("tralala") written_text = "".join(output_funnel.drain()) assert compare_html( written_text, '<input style="" name="tralala" type="text" class="text" value=\'\' />' ) with output_funnel.plugged(): html.text_input("blabla", cssclass="blubb") written_text = "".join(output_funnel.drain()) assert compare_html( written_text, '<input style="" name="tralala" type="text" class="blubb" value=\'\' />' ) with output_funnel.plugged(): html.text_input("blabla", autocomplete="yep") written_text = "".join(output_funnel.drain()) assert compare_html( written_text, '<input style="" name="blabla" autocomplete="yep" type="text" class="text" value=\'\' />', ) with output_funnel.plugged(): html.text_input("blabla", placeholder="placido", data_world="welt", data_max_labels=42) written_text = "".join(output_funnel.drain()) assert compare_html( written_text, '<input style="" name="tralala" type="text" class="text" value=\'\' />' )
def display(self) -> None: html.write_text(_("From: ")) htmlvar = self.htmlvars[0] current_value = request.var(htmlvar, "") html.text_input(htmlvar, default_value=str(current_value), size=8, cssclass="number") if self._unit: html.write_text(" %s" % self._unit) html.write_text(" " + _("To: ")) htmlvar = self.htmlvars[1] current_value = request.var(htmlvar, "") html.text_input(htmlvar, default_value=str(current_value), size=8, cssclass="number") if self._unit: html.write_text(" %s" % self._unit)
def test_text_input(register_builtin_html): with html.plugged(): html.text_input('tralala') written_text = "".join(html.drain()) assert compare_html( written_text, '<input style="" name="tralala" type="text" class="text" value=\'\' />' ) with html.plugged(): html.text_input('blabla', cssclass='blubb') written_text = "".join(html.drain()) assert compare_html( written_text, '<input style="" name="tralala" type="text" class="blubb" value=\'\' />' ) with html.plugged(): html.text_input('blabla', autocomplete='yep') written_text = "".join(html.drain()) assert compare_html( written_text, '<input style="" name="blabla" autocomplete="yep" type="text" class="text" value=\'\' />' ) with html.plugged(): html.text_input('blabla', placeholder='placido', data_world='welt', data_max_labels=42) written_text = "".join(html.drain()) assert compare_html( written_text, '<input style="" name="tralala" type="text" class="text" value=\'\' />' )
def display(self, value: FilterHTTPVariables) -> None: html.write_text(_("From:") + " ") html.text_input( self.htmlvars[0], default_value=value.get(self.htmlvars[0], ""), style="width: 80px;" ) if self.unit: html.write_text(" %s " % self.unit) html.write_text(" " + _("To:") + " ") html.text_input( self.htmlvars[1], default_value=value.get(self.htmlvars[1], ""), style="width: 80px;" ) if self.unit: html.write_text(" %s " % self.unit)
def display(self, value: FilterHTTPVariables): html.open_table(class_="filtertime") for what, whatname in [("from", _("From")), ("until", _("Until"))]: varprefix = self.ident + "_" + what html.open_tr() html.td("%s:" % whatname) html.open_td() html.text_input(varprefix) html.close_td() html.open_td() html.dropdown(varprefix + "_range", legacy_filters.time_filter_options(), deflt="3600") html.close_td() html.close_tr() html.close_table()
def display(self, value: FilterHTTPVariables): choices: Choices = [(str(sec), title + " " + _("ago")) for sec, title in self.ranges] choices += [("abs", _("Date (YYYY-MM-DD)")), ("unix", _("UNIX timestamp"))] html.open_table(class_="filtertime") for what, whatname in [("from", _("From")), ("until", _("Until"))]: varprefix = self.ident + "_" + what html.open_tr() html.td("%s:" % whatname) html.open_td() html.text_input(varprefix) html.close_td() html.open_td() html.dropdown(varprefix + "_range", choices, deflt="3600") html.close_td() html.close_tr() html.close_table()
def _bulk_actions(self, table, at_least_one_imported, top, withsearch, colspan, show_checkboxes): table.row(collect_headers=False, fixed=True) table.cell(css="bulksearch", colspan=3) if not show_checkboxes: onclick_uri = html.makeuri([('show_checkboxes', '1'), ('selection', weblib.selection_id())]) checkbox_title = _('Show Checkboxes and bulk actions') else: onclick_uri = html.makeuri([('show_checkboxes', '0')]) checkbox_title = _('Hide Checkboxes and bulk actions') html.toggle_button("checkbox_on", show_checkboxes, "checkbox", title=checkbox_title, onclick="location.href=\'%s\'" % onclick_uri, is_context_button=False) if withsearch: html.text_input("search") html.button("_search", _("Search")) html.set_focus("search") table.cell(css="bulkactions", colspan=colspan - 3) html.write_text(' ' + _("Selected hosts:\n")) if not self._folder.locked_hosts(): if config.user.may("wato.manage_hosts"): html.button("_bulk_delete", _("Delete")) if config.user.may("wato.edit_hosts"): html.button("_bulk_edit", _("Edit")) html.button("_bulk_cleanup", _("Cleanup")) if config.user.may("wato.services"): html.button("_bulk_inventory", _("Discovery")) if not self._folder.locked_hosts(): if config.user.may("wato.parentscan"): html.button("_parentscan", _("Parentscan")) if config.user.may("wato.edit_hosts") and config.user.may( "wato.move_hosts"): self._host_bulk_move_to_folder_combo(top) if at_least_one_imported: html.button("_bulk_movetotarget", _("Move to Target Folders"))
def render(self, what): html.open_div(class_="group") html.text_input("_cusnot_comment", "TEST", id_="cusnot_comment", size=60, submit="_customnotification", label=_("Comment")) html.close_div() html.open_div(class_="group") html.checkbox("_cusnot_forced", False, label=_("forced")) html.checkbox("_cusnot_broadcast", False, label=_("broadcast")) html.close_div() html.div(html.render_button("_customnotification", _('Send'), cssclass="hot"), class_="group")
def page(self): new = self._folder.name() is None watolib.Folder.current().show_breadcrump() watolib.Folder.current().need_permission("read") if new and watolib.Folder.current().locked(): watolib.Folder.current().show_locking_information() html.begin_form("edit_host", method="POST") # title forms.header(_("Title")) forms.section(_("Title")) TextUnicode().render_input("title", self._folder.title()) html.set_focus("title") # folder name (omit this for root folder) if new or not watolib.Folder.current().is_root(): if not config.wato_hide_filenames: forms.section(_("Internal directory name")) if new: html.text_input("name") else: html.write_text(self._folder.name()) html.help( _("This is the name of subdirectory where the files and " "other folders will be created. You cannot change this later." )) # Attributes inherited to hosts if new: parent = watolib.Folder.current() myself = None else: parent = watolib.Folder.current().parent() myself = watolib.Folder.current() configure_attributes(new, {"folder": myself}, "folder", parent, myself) forms.end() if new or not watolib.Folder.current().locked(): html.button("save", _("Save & Finish"), "submit") html.hidden_fields() html.end_form()
def _show_try_form(self): html.begin_form('try') forms.header(_('Try Pattern Match')) forms.section(_('Hostname')) self._vs_host().render_input("host", self._hostname) forms.section(_('Logfile')) html.text_input('file') forms.section(_('Text to match')) html.help( _('You can insert some text (e.g. a line of the logfile) to test the patterns defined ' 'for this logfile. All patterns for this logfile are listed below. Matching patterns ' 'will be highlighted after clicking the "Try out" button.')) html.text_input('match', cssclass='match', size=100) forms.end() html.button('_try', _('Try out')) html.request.del_var('folder') # Never hand over the folder here html.hidden_fields() html.end_form()
def _show_try_form(self): html.begin_form("try") forms.header(_("Try Pattern Match")) forms.section(_("Hostname")) self._vs_host().render_input("host", self._hostname) forms.section(_("Logfile")) html.help(_("Here you need to insert the original file or pathname")) html.text_input("file", size=80) forms.section(_("Text to match")) html.help( _("You can insert some text (e.g. a line of the logfile) to test the patterns defined " "for this logfile. All patterns for this logfile are listed below. Matching patterns " 'will be highlighted after clicking the "Try out" button.')) html.text_input("match", cssclass="match", size=100) forms.end() html.button("_try", _("Try out")) request.del_var("folder") # Never hand over the folder here html.hidden_fields() html.end_form()