fix: Fix long dashboards screenshot emails (#15954)
* create serialize json function * create new setting for reports * cleanup * address comments * up the attributes
This commit is contained in:
parent
41e8190575
commit
4cb79e5017
|
|
@ -382,7 +382,7 @@ max-statements=50
|
||||||
max-parents=7
|
max-parents=7
|
||||||
|
|
||||||
# Maximum number of attributes for a class (see R0902).
|
# Maximum number of attributes for a class (see R0902).
|
||||||
max-attributes=7
|
max-attributes=8
|
||||||
|
|
||||||
# Minimum number of public methods for a class (see R0903).
|
# Minimum number of public methods for a class (see R0903).
|
||||||
min-public-methods=2
|
min-public-methods=2
|
||||||
|
|
|
||||||
|
|
@ -181,9 +181,10 @@ const DashboardBuilder: FC<DashboardBuilderProps> = () => {
|
||||||
rootChildId !== DASHBOARD_GRID_ID
|
rootChildId !== DASHBOARD_GRID_ID
|
||||||
? dashboardLayout[rootChildId]
|
? dashboardLayout[rootChildId]
|
||||||
: undefined;
|
: undefined;
|
||||||
const isStandalone = getUrlParam(URL_PARAMS.standalone);
|
const StandaloneMode = getUrlParam(URL_PARAMS.standalone);
|
||||||
|
const isReport = StandaloneMode === DashboardStandaloneMode.REPORT;
|
||||||
const hideDashboardHeader =
|
const hideDashboardHeader =
|
||||||
isStandalone === DashboardStandaloneMode.HIDE_NAV_AND_TITLE;
|
StandaloneMode === DashboardStandaloneMode.HIDE_NAV_AND_TITLE || isReport;
|
||||||
|
|
||||||
const barTopOffset =
|
const barTopOffset =
|
||||||
(hideDashboardHeader ? 0 : HEADER_HEIGHT) +
|
(hideDashboardHeader ? 0 : HEADER_HEIGHT) +
|
||||||
|
|
@ -210,7 +211,7 @@ const DashboardBuilder: FC<DashboardBuilderProps> = () => {
|
||||||
|
|
||||||
const offset =
|
const offset =
|
||||||
FILTER_BAR_HEADER_HEIGHT +
|
FILTER_BAR_HEADER_HEIGHT +
|
||||||
(isSticky || isStandalone ? 0 : MAIN_HEADER_HEIGHT) +
|
(isSticky || StandaloneMode ? 0 : MAIN_HEADER_HEIGHT) +
|
||||||
(filterSetEnabled ? FILTER_BAR_TABS_HEIGHT : 0);
|
(filterSetEnabled ? FILTER_BAR_TABS_HEIGHT : 0);
|
||||||
|
|
||||||
const filterBarHeight = `calc(100vh - ${offset}px)`;
|
const filterBarHeight = `calc(100vh - ${offset}px)`;
|
||||||
|
|
@ -255,7 +256,7 @@ const DashboardBuilder: FC<DashboardBuilderProps> = () => {
|
||||||
<div>
|
<div>
|
||||||
{!hideDashboardHeader && <DashboardHeader />}
|
{!hideDashboardHeader && <DashboardHeader />}
|
||||||
{dropIndicatorProps && <div {...dropIndicatorProps} />}
|
{dropIndicatorProps && <div {...dropIndicatorProps} />}
|
||||||
{topLevelTabs && (
|
{!isReport && topLevelTabs && (
|
||||||
<WithPopoverMenu
|
<WithPopoverMenu
|
||||||
shouldFocus={shouldFocusTabs}
|
shouldFocus={shouldFocusTabs}
|
||||||
menuItems={[
|
menuItems={[
|
||||||
|
|
|
||||||
|
|
@ -73,4 +73,5 @@ export const ALL_FILTERS_ROOT = 'ALL_FILTERS_ROOT';
|
||||||
export enum DashboardStandaloneMode {
|
export enum DashboardStandaloneMode {
|
||||||
HIDE_NAV = 1,
|
HIDE_NAV = 1,
|
||||||
HIDE_NAV_AND_TITLE = 2,
|
HIDE_NAV_AND_TITLE = 2,
|
||||||
|
REPORT = 3,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
from enum import Enum
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from typing import Any, Dict, Optional, Tuple, TYPE_CHECKING
|
from typing import Any, Dict, Optional, Tuple, TYPE_CHECKING
|
||||||
|
|
||||||
|
|
@ -42,6 +43,12 @@ if TYPE_CHECKING:
|
||||||
from flask_appbuilder.security.sqla.models import User
|
from flask_appbuilder.security.sqla.models import User
|
||||||
|
|
||||||
|
|
||||||
|
class DashboardStandaloneMode(Enum):
|
||||||
|
HIDE_NAV = 1
|
||||||
|
HIDE_NAV_AND_TITLE = 2
|
||||||
|
REPORT = 3
|
||||||
|
|
||||||
|
|
||||||
class WebDriverProxy:
|
class WebDriverProxy:
|
||||||
def __init__(
|
def __init__(
|
||||||
self, driver_type: str, window: Optional[WindowSize] = None,
|
self, driver_type: str, window: Optional[WindowSize] = None,
|
||||||
|
|
@ -97,6 +104,13 @@ class WebDriverProxy:
|
||||||
self, url: str, element_name: str, user: "User",
|
self, url: str, element_name: str, user: "User",
|
||||||
) -> Optional[bytes]:
|
) -> Optional[bytes]:
|
||||||
|
|
||||||
|
from requests.models import PreparedRequest
|
||||||
|
|
||||||
|
params = {"standalone": DashboardStandaloneMode.REPORT.value}
|
||||||
|
req = PreparedRequest()
|
||||||
|
req.prepare_url(url, params)
|
||||||
|
url = req.url or ""
|
||||||
|
|
||||||
driver = self.auth(user)
|
driver = self.auth(user)
|
||||||
driver.set_window_size(*self._window)
|
driver.set_window_size(*self._window)
|
||||||
driver.get(url)
|
driver.get(url)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue