Пример #1
0
    def _show_initial_iframe_container(self):
        iframe_url = self._get_iframe_url()
        if not iframe_url:
            return

        iframe_url = self._add_wato_folder_to_url(iframe_url)

        # Fix of iPad >:-P
        html.open_div(
            style="width: 100%; height: 100%; -webkit-overflow-scrolling:touch;"
        )
        html.iframe(
            '',
            src="about:blank" if self.reload_on_resize() else iframe_url,
            id_="dashlet_iframe_%d" % self._dashlet_id,
            allowTransparency="true",
            frameborder="0",
            width="100%",
            height="100%")
        html.close_div()

        if self.reload_on_resize():
            html.javascript(
                'cmk.dashboard.set_reload_on_resize(%s, %s);' %
                (json.dumps(self._dashlet_id), json.dumps(iframe_url)))
Пример #2
0
    def page(self) -> cmk.gui.pages.PageResult:
        """Renders an iframe to view the content of the RobotMK log file"""
        site_id, host_name, service_description = _get_mandatory_request_vars()

        breadcrumb: Breadcrumb = make_service_breadcrumb(
            HostName(host_name), service_description)
        title = self._title() + _(" of service %s on host %s") % (
            service_description, host_name)
        try:
            content = _get_html_from_livestatus(site_id, host_name,
                                                service_description)
        except MKLivestatusNotFoundError:
            html.header(
                title=title,
                breadcrumb=breadcrumb,
            )
            html.user_error(
                MKUserError(None,
                            _("You are not permitted to view this page")))
            return

        if not content[0]:
            html.header(
                title=title,
                breadcrumb=breadcrumb,
            )
            html.user_error(MKUserError(None, _("No logs could be found.")))
            return

        # Only render page menu with download option if content is not empty
        # and user is permitted
        html.header(
            title=title,
            breadcrumb=breadcrumb,
            page_menu=self._page_menu(breadcrumb, site_id, host_name,
                                      service_description),
        )

        iframe: str = "robotmk"
        html.iframe(
            content="",
            src=makeuri_contextless(
                request,
                [
                    ("site", site_id),
                    ("host", host_name),
                    ("service", service_description),
                ],
                filename="robotmk_report.py",
            ),
            name="robotmk_report",
            id_=iframe,
        )

        html.javascript('cmk.utils.content_scrollbar("main_page_content");')
        html.javascript(
            "cmk.utils.add_height_to_simple_bar_content_of_iframe(%s);" %
            json.dumps(iframe))