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, 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() 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 = view_spec.get("topic") if topic is None: topic = "" this_title = '%s %s' % (view_spec["title"], count) items.append((topic, url, this_title)) 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()
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()