Skip to content

Commit

Permalink
fix(alerts&reports): Alerts & Reports will use values from WEBDRIVER_…
Browse files Browse the repository at this point in the history
…WINDOW option (apache#13157)

* fix: thumbnails and reports will be use WEBDRIVER_WINDOW option

* changes reformatted

* config change reverted. thumbnails sizes changed to original

* typo fix

* bugfix

defining defaults in thumbnails.py caused thumbnail caches invalidated.
they moved to init.

Co-authored-by: Ibrahim Ercan <ibrahim.ercan@vlmedia.com.tr>
  • Loading branch information
2 people authored and betodealmeida committed Mar 12, 2021
1 parent e98151d commit c9f5e1c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
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"],
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
26 changes: 22 additions & 4 deletions superset/utils/screenshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,30 @@ 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 (800, 600)
self.thumb_size = thumb_size or (800, 600)


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 (1600, 1200)
self.thumb_size = thumb_size or (800, 600)

0 comments on commit c9f5e1c

Please sign in to comment.