예제 #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
파일: view.py 프로젝트: inettgmbh/checkmk
    def _show_view_as_dashlet(self, view_spec: ViewSpec):
        html.add_body_css_class("view")
        html.open_div(id_="dashlet_content_wrapper")

        is_reload = html.request.has_var("_reload")

        view_display_options = "SIXLW"
        if not is_reload:
            view_display_options += "HR"

        html.request.set_var('display_options', view_display_options)
        html.request.set_var('_display_options', view_display_options)
        html.add_body_css_class('dashlet')

        # Need to be loaded before processing the painter_options below.
        # TODO: Make this dependency explicit
        display_options.load_from_html(html)

        painter_options = PainterOptions.get_instance()
        painter_options.load(self._dashlet_spec["name"])

        view = views.View(self._dashlet_spec["name"], view_spec, self.context)
        view.row_limit = views.get_limit()
        view.only_sites = visuals.get_only_sites_from_context(self.context)
        view.user_sorters = views.get_user_sorters()

        views.process_view(views.GUIViewRenderer(view, show_buttons=False))

        html.close_div()
예제 #3
0
def page_view():
    view_name = html.request.var("view_name")
    if not view_name:
        return page_index()

    view_spec = views.get_permitted_views().get(view_name)
    if not view_spec:
        raise MKUserError("view_name",
                          "No view defined with the name '%s'." % view_name)

    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()

    title = views.view_title(view_spec)
    mobile_html_head(title)

    painter_options = PainterOptions.get_instance()
    painter_options.load(view_name)

    try:
        view_renderer = MobileViewRenderer(view)
        views.show_view(view, view_renderer)
    except Exception as e:
        logger.exception()
        if config.debug:
            raise
        html.write("ERROR showing view: %s" % html.attrencode(e))

    mobile_html_foot()
예제 #4
0
파일: view.py 프로젝트: gradecke/checkmk
    def _show_view_as_dashlet(self, view_spec: ViewSpec):
        html.add_body_css_class("view")
        html.open_div(id_="dashlet_content_wrapper")

        is_reload = request.has_var("_reload")

        view_display_options = "SIXLW"
        if not is_reload:
            view_display_options += "HR"

        request.set_var("display_options", view_display_options)
        request.set_var("_display_options", view_display_options)
        html.add_body_css_class("dashlet")

        # Need to be loaded before processing the painter_options below.
        # TODO: Make this dependency explicit
        display_options.load_from_html(request, html)

        painter_options = PainterOptions.get_instance()
        painter_options.load(self._dashlet_spec["name"])

        # Here the linked view default context has the highest priority
        # linkedview default>dashlet>url active filter, dashboard
        context = visuals.get_merged_context(self.context,
                                             view_spec["context"])

        view = views.View(self._dashlet_spec["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()

        views.process_view(views.GUIViewRenderer(view, show_buttons=False))

        html.close_div()
예제 #5
0
파일: view.py 프로젝트: arusa/checkmk
    def _show_view_as_dashlet(self, view_spec):
        html.add_body_css_class("view")
        html.open_div(id_="dashlet_content_wrapper")

        is_reload = html.request.has_var("_reload")

        display_options = "SIXLW"
        if not is_reload:
            display_options += "HR"

        html.request.set_var('display_options', display_options)
        html.request.set_var('_display_options', display_options)
        html.add_body_css_class('dashlet')

        painter_options = PainterOptions.get_instance()
        painter_options.load(self._dashlet_spec["name"])

        view = views.View(self._dashlet_spec["name"], view_spec, self.context)
        view.row_limit = views.get_limit()
        view.only_sites = visuals.get_only_sites_from_context(self.context)
        view.user_sorters = views.get_user_sorters()

        view_renderer = views.GUIViewRenderer(view, show_buttons=False)
        views.process_view(view, view_renderer)

        html.close_div()
예제 #6
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()
예제 #7
0
파일: mobile.py 프로젝트: m3rlinux/checkmk
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()
예제 #8
0
    def _show_view_as_dashlet(self, view_spec: ViewSpec):
        html.add_body_css_class("view")
        html.open_div(id_="dashlet_content_wrapper")

        is_reload = request.has_var("_reload")

        view_display_options = "SIXLW"
        if not is_reload:
            view_display_options += "HR"

        request.set_var("display_options", view_display_options)
        request.set_var("_display_options", view_display_options)
        html.add_body_css_class("dashlet")

        # Need to be loaded before processing the painter_options below.
        # TODO: Make this dependency explicit
        display_options.load_from_html(request, html)

        painter_options = PainterOptions.get_instance()
        painter_options.load(self._dashlet_spec["name"])

        # Here the linked view default context has the highest priority
        # linkedview default>dashlet>url active filter> dashboard. However views
        # have the "show_filters" default to prefill the filtermenu with empty
        # valued filters(UX). Those need to be cleared out. Otherwise those
        # empty filters are the highest priority filters and the user can never
        # filter the view.

        view_context = {
            filtername: filtervalues
            for filtername, filtervalues in view_spec["context"].items() if {
                var: value
                for var, value in filtervalues.items()
                # These are the filters request variables. Keep set values
                # For the TriStateFilters unset == ignore == "-1"
                # all other cases unset is an empty string
                if (var.startswith("is_") and value != "-1"
                    )  # TriState filters except ignore
                or (not var.startswith("is_") and value
                    )  # Rest of filters with some value
            }
        }
        context = visuals.get_merged_context(self.context, view_context)

        view = views.View(self._dashlet_spec["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()

        views.process_view(views.GUIViewRenderer(view, show_buttons=False))

        html.close_div()
예제 #9
0
def page_view() -> None:
    view_name = html.request.var("view_name")
    if not view_name:
        return page_index()

    view_spec = views.get_permitted_views().get(view_name)
    if not view_spec:
        raise MKUserError("view_name",
                          "No view defined with the name '%s'." % view_name)

    datasource = data_source_registry[view_spec["datasource"]]()
    context = visuals.get_merged_context(
        visuals.get_context_from_uri_vars(
            datasource.infos, single_infos=view_spec["single_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()

    title = views.view_title(view.spec, view.context)
    mobile_html_head(title)

    # Need to be loaded before processing the painter_options below.
    # TODO: Make this dependency explicit
    display_options.load_from_html(html)

    painter_options = PainterOptions.get_instance()
    painter_options.load(view_name)

    try:
        views.process_view(MobileViewRenderer(view))
    except Exception as e:
        logger.exception("error showing mobile view")
        if config.debug:
            raise
        html.write("ERROR showing view: %s" %
                   escaping.escape_attribute(str(e)))

    mobile_html_foot()
예제 #10
0
파일: view.py 프로젝트: m4c3/checkMK
    def update(self):
        is_reload = html.request.has_var("_reload")

        display_options = "SIXLW"
        if not is_reload:
            display_options += "HR"

        html.request.set_var('display_options', display_options)
        html.request.set_var('_display_options', display_options)
        html.add_body_css_class('dashlet')

        painter_options = PainterOptions.get_instance()
        painter_options.load(self._dashlet_spec["name"])

        view = views.View(self._dashlet_spec["name"], self._dashlet_spec)
        view.row_limit = views.get_limit()
        view.only_sites = views.get_only_sites()
        view.user_sorters = views.get_user_sorters()

        view_renderer = views.GUIViewRenderer(view, show_buttons=False)
        views.show_view(view, view_renderer)
예제 #11
0
def page_view() -> None:
    view_name = html.request.var("view_name")
    if not view_name:
        return page_index()

    view_spec = views.get_permitted_views().get(view_name)
    if not view_spec:
        raise MKUserError("view_name",
                          "No view defined with the name '%s'." % view_name)

    datasource = data_source_registry[view_spec["datasource"]]()
    context = visuals.get_merged_context(
        visuals.get_context_from_uri_vars(
            datasource.infos, single_infos=view_spec["single_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()

    title = views.view_title(view_spec)
    mobile_html_head(title)

    painter_options = PainterOptions.get_instance()
    painter_options.load(view_name)

    try:
        view_renderer = MobileViewRenderer(view)
        views.show_view(view, view_renderer)
    except Exception as e:
        logger.exception("error showing mobile view")
        if config.debug:
            raise
        html.write("ERROR showing view: %s" %
                   escaping.escape_attribute(str(e)))

    mobile_html_foot()