-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for showing all metrics on the reports overview page. Closes #7215
- Loading branch information
Showing
40 changed files
with
514 additions
and
426 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""Shared code to export reports overview and reports to PDF.""" | ||
|
||
import os | ||
from urllib import parse | ||
|
||
import bottle | ||
import requests | ||
|
||
from shared.utils.type import ReportId | ||
|
||
|
||
def export_as_pdf(report_uuid: ReportId | None = None): | ||
"""Export the URL as PDF.""" | ||
renderer_host = os.environ.get("RENDERER_HOST", "renderer") | ||
renderer_port = os.environ.get("RENDERER_PORT", "9000") | ||
render_url = f"http://{renderer_host}:{renderer_port}/api/render" | ||
# Tell the frontend to not display toast messages to prevent them from being included in the PDF: | ||
query_string = "?hide_toasts=true" + (f"&{bottle.request.query_string}" if bottle.request.query_string else "") | ||
path = parse.quote(f"{report_uuid or ''}{query_string}") | ||
response = requests.get(f"{render_url}?path={path}", timeout=120) | ||
response.raise_for_status() | ||
bottle.response.content_type = "application/pdf" | ||
return response.content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.