Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(alerts&reports): Alerts & Reports will use values from WEBDRIVER_WINDOW option #13157

Merged
merged 6 commits into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions superset/reports/commands/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,19 @@ def _get_screenshot(self) -> ScreenshotData:
screenshot: Optional[BaseScreenshot] = None
if self._report_schedule.chart:
url = self._get_url(standalone="true")
screenshot = ChartScreenshot(url, self._report_schedule.chart.digest)
screenshot = ChartScreenshot(
url,
self._report_schedule.chart.digest,
window_size=app.config["WEBDRIVER_WINDOW"]["slice"],
iercan marked this conversation as resolved.
Show resolved Hide resolved
thumb_size=app.config["WEBDRIVER_WINDOW"]["slice"],
)
else:
url = self._get_url()
screenshot = DashboardScreenshot(
url, self._report_schedule.dashboard.digest
url,
self._report_schedule.dashboard.digest,
window_size=app.config["WEBDRIVER_WINDOW"]["dashboard"],
thumb_size=app.config["WEBDRIVER_WINDOW"]["dashboard"],
)
image_url = self._get_url(user_friendly=True)
user = self._get_screenshot_user()
Expand Down
4 changes: 2 additions & 2 deletions superset/tasks/thumbnails.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def cache_chart_thumbnail(
logger.warning("No cache set, refusing to compute")
return None
logger.info("Caching chart: %s", url)
screenshot = ChartScreenshot(url, digest)
screenshot = ChartScreenshot(url, digest, (800, 600), (800, 600))
with session_scope(nullpool=True) as session:
user = security_manager.get_user_by_username(
current_app.config["THUMBNAIL_SELENIUM_USER"], session=session
Expand All @@ -68,7 +68,7 @@ def cache_dashboard_thumbnail(
logging.warning("No cache set, refusing to compute")
return
logger.info("Caching dashboard: %s", url)
screenshot = DashboardScreenshot(url, digest)
screenshot = DashboardScreenshot(url, digest, (1600, 1200), (800, 600))
with session_scope(nullpool=True) as session:
user = security_manager.get_user_by_username(
current_app.config["THUMBNAIL_SELENIUM_USER"], session=session
Expand Down
30 changes: 26 additions & 4 deletions superset/utils/screenshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,34 @@ def resize_image(
class ChartScreenshot(BaseScreenshot):
thumbnail_type: str = "chart"
element: str = "chart-container"
window_size: WindowSize = (800, 600)
thumb_size: WindowSize = (800, 600)

def __init__(
self,
url: str,
digest: str,
window_size: Optional[WindowSize] = None,
thumb_size: Optional[WindowSize] = None,
):
super().__init__(url, digest)
self.window_size = (
window_size or current_app.config["WEBDRIVER_WINDOW"]["slice"]
)
self.thumb_size = thumb_size or (800, 600)
iercan marked this conversation as resolved.
Show resolved Hide resolved


class DashboardScreenshot(BaseScreenshot):
thumbnail_type: str = "dashboard"
element: str = "grid-container"
window_size: WindowSize = (1600, int(1600 * 0.75))
thumb_size: WindowSize = (800, int(800 * 0.75))

def __init__(
self,
url: str,
digest: str,
window_size: Optional[WindowSize] = None,
thumb_size: Optional[WindowSize] = None,
):
super().__init__(url, digest)
self.window_size = (
window_size or current_app.config["WEBDRIVER_WINDOW"]["dashboard"]
)
self.thumb_size = thumb_size or (800, 600)