示例#1
0
def page_index():
    title = _("Check_MK Mobile")
    mobile_html_head(title)
    jqm_page_header(title,
                    right_button=("javascript:document.location.reload();",
                                  _("Reload"), "refresh"),
                    id_="data")
    items = []
    for view_name, view_spec in views.get_permitted_views().items():
        if view_spec.get("mobile") and not view_spec.get("hidden"):
            view = views.View(view_name, view_spec)
            view.row_limit = views.get_limit()
            view.only_sites = views.get_only_sites()
            view.user_sorters = views.get_user_sorters()

            url = "mobile_view.py?view_name=%s" % view_name
            count = ""
            if not view_spec.get("mustsearch"):
                painter_options = PainterOptions.get_instance()
                painter_options.load(view_name)
                view_renderer = MobileViewRenderer(view)
                count = views.show_view(view, view_renderer, only_count=True)
                count = '<span class="ui-li-count">%d</span>' % count
            items.append(
                (view_spec.get("topic"), url, '%s %s' %
                 (view_spec.get("linktitle", view_spec["title"]), count)))
    jqm_page_index(_("Check_MK Mobile"), items)
    # Link to non-mobile GUI

    html.hr()
    html.open_ul(**{
        "data-role": "listview",
        "data-theme": "b",
        "data-inset": "true"
    })
    html.open_li()
    html.a(_("Classical web GUI"),
           href="index.py?mobile=",
           **{
               "data-ajax": "false",
               "data-transition": "fade"
           })
    html.close_li()
    html.close_ul()

    html.open_ul(**{
        "data-role": "listview",
        "data-theme": "f",
        "data-inset": "true"
    })
    html.open_li()
    html.a(_("Logout"),
           href="logout.py",
           **{
               "data-ajax": "false",
               "data-transition": "fade"
           })
    html.close_li()
    html.close_ul()
    mobile_html_foot()
示例#2
0
def page_index():
    # type: () -> None
    title = _("Check_MK Mobile")
    mobile_html_head(title)
    jqm_page_header(title,
                    right_button=("javascript:document.location.reload();", _("Reload"), "refresh"),
                    id_="data")
    items = []
    for view_name, view_spec in views.get_permitted_views().items():
        if view_spec.get("mobile") and not view_spec.get("hidden"):

            datasource = data_source_registry[view_spec["datasource"]]()
            context = visuals.get_merged_context(
                visuals.get_context_from_uri_vars(datasource.infos),
                view_spec["context"],
            )

            view = views.View(view_name, view_spec, context)
            view.row_limit = views.get_limit()
            view.only_sites = views.get_only_sites()
            view.user_sorters = views.get_user_sorters()

            url = "mobile_view.py?view_name=%s" % view_name
            count = ""
            if not view_spec.get("mustsearch"):
                painter_options = PainterOptions.get_instance()
                painter_options.load(view_name)
                view_renderer = MobileViewRenderer(view)
                # TODO: Horrible API ahead!
                count_num = views.show_view(view, view_renderer, only_count=True)
                count = '<span class="ui-li-count">%d</span>' % count_num

            topic = view_spec.get("topic")
            if topic is None:
                topic = ""
            this_title = '%s %s' % (view_spec.get("linktitle", view_spec["title"]), count)
            items.append((topic, url, this_title))

    jqm_page_index(_("Check_MK Mobile"), items)
    # Link to non-mobile GUI

    html.hr()
    html.open_ul(**{"data-role": "listview", "data-theme": "b", "data-inset": "true"})
    html.open_li()
    html.a(_("Classical web GUI"),
           href="index.py?mobile=",
           **{
               "data-ajax": "false",
               "data-transition": "fade"
           })
    html.close_li()
    html.close_ul()

    html.open_ul(**{"data-role": "listview", "data-theme": "f", "data-inset": "true"})
    html.open_li()
    html.a(_("Logout"), href="logout.py", **{"data-ajax": "false", "data-transition": "fade"})
    html.close_li()
    html.close_ul()
    mobile_html_foot()
示例#3
0
def page_index() -> None:
    title = _("Checkmk Mobile")
    mobile_html_head(title)
    jqm_page_header(
        title,
        right_button=("javascript:document.location.reload();", _("Reload"), "refresh"),
        id_="data",
    )
    items = []
    for view_name, view_spec in views.get_permitted_views().items():
        if view_spec.get("mobile") and not view_spec.get("hidden"):

            datasource = data_source_registry[view_spec["datasource"]]()
            context = visuals.get_merged_context(
                visuals.get_context_from_uri_vars(datasource.infos),
                view_spec["context"],
            )

            view = views.View(view_name, view_spec, context)
            view.row_limit = views.get_limit()
            view.only_sites = visuals.get_only_sites_from_context(context)
            view.user_sorters = views.get_user_sorters()
            view.want_checkboxes = views.get_want_checkboxes()

            url = "mobile_view.py?view_name=%s" % view_name
            count = ""
            if not view_spec.get("mustsearch"):
                painter_options = PainterOptions.get_instance()
                painter_options.load(view_name)
                count = '<span class="ui-li-count">%d</span>' % views.get_row_count(view)

            topic = PagetypeTopics.get_topic(view_spec.get("topic", ""))
            items.append((topic.title(), url, "%s %s" % (view_spec["title"], count)))

    jqm_page_index(_("Checkmk Mobile"), items)
    # Link to non-mobile GUI

    html.hr()
    html.open_ul(**{"data-role": "listview", "data-theme": "b", "data-inset": "true"})
    html.open_li()
    html.a(
        _("Classical web GUI"),
        href="index.py?mobile=",
        **{"data-ajax": "false", "data-transition": "fade"},
    )
    html.close_li()
    html.close_ul()

    html.open_ul(**{"data-role": "listview", "data-theme": "f", "data-inset": "true"})
    html.open_li()
    html.a(_("Logout"), href="logout.py", **{"data-ajax": "false", "data-transition": "fade"})
    html.close_li()
    html.close_ul()
    mobile_html_foot()
示例#4
0
 def _show_items(self, topic_id: str, topic: TopicMenuTopic) -> None:
     html.open_ul()
     for item in topic.items:
         self._show_item(item)
     html.open_li(class_="show_all_items")
     html.hr()
     html.a(content=_("Show all"),
            href="",
            onclick="cmk.popup_menu.mega_menu_show_all_items('%s')" %
            topic_id)
     html.close_li()
     html.close_ul()
示例#5
0
    def _show_items(self, topic_id: str, topic: TopicMenuTopic) -> None:
        html.open_ul()
        counter = 0
        for item in topic.items:
            if counter < 10:
                self._show_item(item)
                if not item.is_advanced:
                    counter += 1
            else:
                self._show_item(item, extended=True)
        if counter >= 10:
            html.open_li(class_="show_all_items")
            html.hr()
            html.a(content=_("Show all"),
                   href="",
                   onclick="cmk.popup_menu.mega_menu_show_all_items('%s')" %
                   topic_id)
            html.close_li()

        html.close_ul()
示例#6
0
    def render_input(self, varprefix, value):
        value = convert_cgroups_from_tuple(value)

        # If we're just editing a host, then some of the checkboxes will be missing.
        # This condition is not very clean, but there is no other way to savely determine
        # the context.
        is_host = bool(
            html.request.var("host")) or html.request.var("mode") == "newhost"
        is_search = varprefix == "host_search"

        # Only show contact groups I'm currently in and contact
        # groups already listed here.
        self.load_data()
        self._vs_contactgroups().render_input(varprefix + self.name(),
                                              value['groups'])

        html.hr()

        if is_host:
            html.checkbox(varprefix + self.name() + "_use",
                          value["use"],
                          label=_("Add these contact groups to the host"))

        elif not is_search:
            html.checkbox(
                varprefix + self.name() + "_recurse_perms",
                value["recurse_perms"],
                label=_(
                    "Give these groups also <b>permission on all subfolders</b>"
                ))
            html.hr()
            html.checkbox(
                varprefix + self.name() + "_use",
                value["use"],
                label=
                _("Add these groups as <b>contacts</b> to all hosts <b>in this folder</b>"
                  ))
            html.br()
            html.checkbox(
                varprefix + self.name() + "_recurse_use",
                value["recurse_use"],
                label=
                _("Add these groups as <b>contacts</b> to all hosts <b>in all subfolders of this folder</b>"
                  ))

        html.hr()
        html.help(
            _("With this option contact groups that are added to hosts are always "
              "being added to services, as well. This only makes a difference if you have "
              "assigned other contact groups to services via rules in <i>Host & Service Parameters</i>. "
              "As long as you do not have any such rule a service always inherits all contact groups "
              "from its host."))
        html.checkbox(
            varprefix + self.name() + "_use_for_services",
            value.get("use_for_services", False),
            label=_("Always add host contact groups also to its services")
            if is_host else
            _("Always add these groups as <b>contacts</b> to all services <b>in all subfolders of this folder</b>"
              ))
示例#7
0
    def render(self, what):
        html.button("_acknowledge", _("Acknowledge"))
        html.button("_remove_ack", _("Remove Acknowledgement"))
        html.hr()
        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.hr()

        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.hr()
        html.write_text(_("Comment") + ": ")
        html.text_input("_ack_comment", size=48, submit="_acknowledge")
示例#8
0
    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("&nbsp; " + _("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(" &nbsp; - &nbsp;")
            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("&nbsp; " + _('to') + " &nbsp;")
        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
            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)"))