You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2023/06/29 01:08:38 UTC
[superset] branch customize_screenshot_width updated (0c88517b1e -> 6a358f5fec)
This is an automated email from the ASF dual-hosted git repository.
beto pushed a change to branch customize_screenshot_width
in repository https://gitbox.apache.org/repos/asf/superset.git
omit 0c88517b1e Revert small change
omit 5c5f567997 Fix style
omit eb07418c78 Add affordances
omit 9193109e5a Update reports model
omit 2db835d862 Add some constants
add a846e8a58d feat(tags): move tags from navbar to settings (#24518)
add 262b769d19 fix(native-filters): Infinite load when filter with default first value is out of scope in horizontal bar (#24542)
add a90f740a81 fix: Release scripts Python version (#24544)
add cdbe4f3fa7 fix: Revert enable strong session protection by default (#24256) (#24545)
add 0986423d30 chore: Constrain selenium version (#24538)
add e402c94a9f fix: Use Celery task ETA for alert/report schedule (#24537)
add 83ff4cd86a feat: Implement currencies formatter for saved metrics (#24517)
add 71f3fcab74 fix: SQL Lab - correct setting name from DISPLAY_MAX_ROWS to DISPLAY_MAX_ROW (#24519)
add c81975eed3 fix(permalink): Incorrect component schema reference (#24482)
add 0d72e63491 fix(translations): typo mistake (translation to Spanish) (#24475)
add 1e7ee8c4ad fix(docs): Typo in filter migration. (#24541)
add f1b003f109 refactor: pkg_resources -> importlib.metadata (#24514)
add 75543af550 chore(dao): Add explicit ON DELETE CASCADE when deleting datasets (#24488)
new 785f5ff851 Add some constants
new e6d614b4b3 Update reports model
new dbe32a207b Add affordances
new 9d1516ddb8 Fix style
new 6a358f5fec Revert small change
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (0c88517b1e)
\
N -- N -- N refs/heads/customize_screenshot_width (6a358f5fec)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
RELEASING/Dockerfile.from_local_tarball | 2 +-
RELEASING/Dockerfile.from_svn_tarball | 2 +-
RELEASING/Dockerfile.make_docs | 2 +-
RELEASING/Dockerfile.make_tarball | 2 +-
RELEASING/README.md | 4 +-
RELEASING/from_tarball_entrypoint.sh | 5 +-
UPDATING.md | 2 +-
.../docs/miscellaneous/native-filter-migration.mdx | 2 +-
docs/docs/security.mdx | 21 ++-
requirements/base.txt | 4 +-
setup.py | 3 +-
superset-frontend/package-lock.json | 9 +-
.../superset-ui-chart-controls/src/fixtures.ts | 2 +
.../superset-ui-chart-controls/src/types.ts | 2 +
.../test/utils/columnChoices.test.tsx | 1 +
.../test/utils/defineSavedMetrics.test.tsx | 1 +
.../src/currency-format/CurrencyFormatter.ts | 79 +++++++++++
.../colorSchemes => currency-format}/index.ts | 4 +-
.../packages/superset-ui-core/src/index.ts | 1 +
.../superset-ui-core/src/query/types/Datasource.ts | 8 ++
.../superset-ui-core/src/query/types/Metric.ts | 1 +
.../packages/superset-ui-core/src/types/index.ts | 5 +
.../test/currency-format/CurrencyFormatter.test.ts | 158 +++++++++++++++++++++
.../src/BigNumber/BigNumberTotal/transformProps.ts | 25 +++-
.../BigNumberWithTrendline/transformProps.ts | 18 ++-
.../plugin-chart-echarts/src/BigNumber/types.ts | 4 +-
.../src/Funnel/transformProps.ts | 14 +-
.../src/Gauge/transformProps.ts | 15 +-
.../plugin-chart-echarts/src/Pie/transformProps.ts | 15 +-
.../src/Timeseries/transformProps.ts | 78 +++++++++-
.../src/Timeseries/transformers.ts | 4 +-
.../src/Treemap/transformProps.ts | 17 ++-
.../plugin-chart-echarts/src/utils/forecast.ts | 4 +-
.../plugin-chart-echarts/src/utils/series.ts | 3 +-
.../src/utils/valueFormatter.ts | 63 ++++++++
.../test/BigNumber/transformProps.test.ts | 25 ++++
.../src/PivotTableChart.tsx | 31 +++-
.../src/plugin/transformProps.ts | 3 +-
.../plugins/plugin-chart-pivot-table/src/types.ts | 2 +
.../test/plugin/buildQuery.test.ts | 1 +
.../test/plugin/transformProps.test.ts | 1 +
.../plugins/plugin-chart-table/package.json | 42 +++---
.../plugin-chart-table/src/transformProps.ts | 8 +-
.../plugins/plugin-chart-table/src/types.ts | 7 +-
.../plugin-chart-table/src/utils/formatValue.ts | 1 -
.../plugin-chart-table/src/utils/isEqualColumns.ts | 1 +
.../plugin-chart-table/test/TableChart.test.tsx | 21 +++
.../plugins/plugin-chart-table/test/testData.ts | 11 ++
.../src/SqlLab/components/ResultSet/index.tsx | 2 +-
.../src/components/Datasource/DatasourceEditor.jsx | 70 +++++++++
.../Datasource/DatasourceEditor.test.jsx | 86 ++++++++++-
.../src/components/Datasource/DatasourceModal.tsx | 32 ++++-
.../src/components/DropdownContainer/index.tsx | 7 +-
.../src/components/Popover/Popover.test.tsx | 5 +
.../BooleanCell/index.tsx => Popover/Popover.tsx} | 14 +-
superset-frontend/src/components/Popover/index.tsx | 4 +-
.../FilterBar/FilterControls/FilterControls.tsx | 1 +
superset-frontend/src/dashboard/constants.ts | 1 +
.../src/explore/actions/datasourcesActions.test.ts | 2 +
.../src/explore/actions/hydrateExplore.ts | 1 +
.../src/explore/controlUtils/controlUtils.test.tsx | 1 +
...etControlValuesCompatibleWithDatasource.test.ts | 1 +
superset-frontend/src/explore/fixtures.tsx | 2 +
superset-frontend/src/features/datasets/types.ts | 3 +
.../src/utils/getDatasourceUid.test.ts | 1 +
superset/charts/commands/warm_up_cache.py | 1 -
superset/config.py | 4 +-
superset/connectors/base/models.py | 21 +++
superset/connectors/sqla/models.py | 11 +-
superset/connectors/sqla/views.py | 1 +
superset/daos/dataset.py | 26 ++--
superset/dashboards/permalink/api.py | 2 +-
superset/dashboards/schemas.py | 1 +
superset/databases/api.py | 4 +-
superset/datasets/api.py | 2 +
superset/datasets/commands/bulk_delete.py | 30 +---
superset/datasets/commands/delete.py | 18 +--
superset/datasets/commands/warm_up_cache.py | 1 -
superset/datasets/schemas.py | 2 +
superset/db_engine_specs/__init__.py | 6 +-
superset/db_engine_specs/base.py | 1 +
superset/explore/schemas.py | 1 +
superset/initialization/__init__.py | 11 +-
...90139bf715e4_add_currency_column_to_metrics.py} | 20 +--
..._add_on_delete_cascade_for_tables_references.py | 94 ++++++++++++
superset/tasks/scheduler.py | 15 +-
superset/translations/de/LC_MESSAGES/messages.json | 4 +-
superset/translations/de/LC_MESSAGES/messages.po | 4 +-
superset/translations/en/LC_MESSAGES/messages.json | 2 +-
superset/translations/en/LC_MESSAGES/messages.po | 2 +-
superset/translations/es/LC_MESSAGES/messages.json | 4 +-
superset/translations/es/LC_MESSAGES/messages.po | 2 +-
superset/translations/fr/LC_MESSAGES/messages.json | 2 +-
superset/translations/fr/LC_MESSAGES/messages.po | 2 +-
superset/translations/it/LC_MESSAGES/messages.json | 2 +-
superset/translations/it/LC_MESSAGES/messages.po | 2 +-
superset/translations/ja/LC_MESSAGES/messages.json | 2 +-
superset/translations/ja/LC_MESSAGES/messages.po | 2 +-
superset/translations/ko/LC_MESSAGES/messages.json | 2 +-
superset/translations/ko/LC_MESSAGES/messages.po | 2 +-
superset/translations/nl/LC_MESSAGES/messages.json | 2 +-
superset/translations/nl/LC_MESSAGES/messages.po | 2 +-
superset/translations/pt/LC_MESSAGES/messages.json | 2 +-
superset/translations/pt/LC_MESSAGES/messages.po | 2 +-
.../translations/pt_BR/LC_MESSAGES/messages.json | 4 +-
.../translations/pt_BR/LC_MESSAGES/messages.po | 4 +-
superset/translations/ru/LC_MESSAGES/messages.json | 4 +-
superset/translations/ru/LC_MESSAGES/messages.po | 4 +-
superset/translations/sk/LC_MESSAGES/messages.json | 2 +-
superset/translations/sk/LC_MESSAGES/messages.po | 2 +-
superset/translations/sl/LC_MESSAGES/messages.json | 4 +-
superset/translations/sl/LC_MESSAGES/messages.po | 4 +-
superset/translations/zh/LC_MESSAGES/messages.json | 4 +-
superset/translations/zh/LC_MESSAGES/messages.po | 4 +-
superset/utils/core.py | 21 ++-
superset/views/base.py | 1 +
tests/integration_tests/charts/api_tests.py | 2 -
tests/integration_tests/charts/commands_tests.py | 1 -
tests/integration_tests/commands_test.py | 3 +-
.../integration_tests/dashboards/commands_tests.py | 1 -
tests/integration_tests/databases/api_tests.py | 2 -
tests/integration_tests/datasets/api_tests.py | 2 -
tests/integration_tests/datasets/commands_tests.py | 5 +-
tests/integration_tests/reports/scheduler_tests.py | 4 +-
tests/integration_tests/sqla_models_tests.py | 9 +-
tests/unit_tests/datasets/commands/export_test.py | 1 +
tests/unit_tests/db_engine_specs/test_init.py | 1 -
127 files changed, 1095 insertions(+), 275 deletions(-)
create mode 100644 superset-frontend/packages/superset-ui-core/src/currency-format/CurrencyFormatter.ts
copy superset-frontend/packages/superset-ui-core/src/{color/colorSchemes => currency-format}/index.ts (88%)
create mode 100644 superset-frontend/packages/superset-ui-core/test/currency-format/CurrencyFormatter.test.ts
create mode 100644 superset-frontend/plugins/plugin-chart-echarts/src/utils/valueFormatter.ts
copy superset-frontend/src/components/{Table/cell-renderers/BooleanCell/index.tsx => Popover/Popover.tsx} (75%)
copy superset/migrations/versions/{2017-09-15_15-09_19a814813610_adding_metric_warning_text.py => 2023-06-21_14-02_90139bf715e4_add_currency_column_to_metrics.py} (69%)
create mode 100644 superset/migrations/versions/2023-06-22_13-39_6fbe660cac39_add_on_delete_cascade_for_tables_references.py
[superset] 03/05: Add affordances
Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
beto pushed a commit to branch customize_screenshot_width
in repository https://gitbox.apache.org/repos/asf/superset.git
commit dbe32a207b4f6dc2e15277561cea190fb9774af2
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Wed Jun 28 16:03:38 2023 -0700
Add affordances
---
.../src/components/ReportModal/index.tsx | 23 ++++++++
.../src/features/alerts/AlertReportModal.tsx | 64 ++++++++++++++++------
superset-frontend/src/features/alerts/types.ts | 3 +-
superset-frontend/src/reports/types.ts | 1 +
superset/config.py | 3 +
superset/reports/api.py | 2 +
superset/reports/schemas.py | 52 +++++++++++++++++-
7 files changed, 128 insertions(+), 20 deletions(-)
diff --git a/superset-frontend/src/components/ReportModal/index.tsx b/superset-frontend/src/components/ReportModal/index.tsx
index 5bf4c2c4d2..cb229f1f3f 100644
--- a/superset-frontend/src/components/ReportModal/index.tsx
+++ b/superset-frontend/src/components/ReportModal/index.tsx
@@ -41,6 +41,7 @@ import {
NOTIFICATION_FORMATS,
} from 'src/reports/types';
import { reportSelector } from 'src/views/CRUD/hooks';
+import { TRANSLATIONS } from 'src/features/alerts/AlertReportModal';
import { CreationMethod } from './HeaderReportDropdown';
import {
antDErrorAlertStyles,
@@ -170,6 +171,7 @@ function ReportModal({
type: 'Report',
active: true,
force_screenshot: false,
+ custom_width: currentReport.custom_width,
creation_method: creationMethod,
dashboard: dashboardId,
chart: chart?.id,
@@ -257,6 +259,26 @@ function ReportModal({
</div>
</>
);
+ const renderCustomWidthSection = (
+ <div>
+ <div className="control-label">
+ {TRANSLATIONS.CUSTOM_SCREENSHOT_WIDTH_TEXT}
+ </div>
+ <div className="input-container">
+ <input
+ type="number"
+ name="custom_width"
+ value={currentReport?.custom_width || ''}
+ placeholder={TRANSLATIONS.CUSTOM_SCREENSHOT_WIDTH_PLACEHOLDER_TEXT}
+ onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
+ setCurrentReport({
+ custom_width: parseInt(event.target.value, 10) || null,
+ });
+ }}
+ />
+ </div>
+ </div>
+ );
return (
<StyledModal
@@ -331,6 +353,7 @@ function ReportModal({
}}
/>
{isChart && renderMessageContentSection}
+ {(!isChart || !isTextBasedChart) && renderCustomWidthSection}
</StyledBottomSection>
{currentReport.error && (
<Alert
diff --git a/superset-frontend/src/features/alerts/AlertReportModal.tsx b/superset-frontend/src/features/alerts/AlertReportModal.tsx
index 8ff344c97e..0aeae9103e 100644
--- a/superset-frontend/src/features/alerts/AlertReportModal.tsx
+++ b/superset-frontend/src/features/alerts/AlertReportModal.tsx
@@ -370,7 +370,7 @@ interface NotificationMethodAddProps {
onClick: () => void;
}
-const TRANSLATIONS = {
+export const TRANSLATIONS = {
ADD_NOTIFICATION_METHOD_TEXT: t('Add notification method'),
ADD_DELIVERY_METHOD_TEXT: t('Add delivery method'),
SAVE_TEXT: t('Save'),
@@ -406,7 +406,9 @@ const TRANSLATIONS = {
SEND_AS_PNG_TEXT: t('Send as PNG'),
SEND_AS_CSV_TEXT: t('Send as CSV'),
SEND_AS_TEXT: t('Send as text'),
- IGNORE_CACHE_TEXT: t('Ignore cache when generating screenshot'),
+ IGNORE_CACHE_TEXT: t('Ignore cache when generating report'),
+ CUSTOM_SCREENSHOT_WIDTH_TEXT: t('Screenshot width'),
+ CUSTOM_SCREENSHOT_WIDTH_PLACEHOLDER_TEXT: t('Input custom width in pixels'),
NOTIFICATION_METHOD_TEXT: t('Notification method'),
};
@@ -466,6 +468,14 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
);
const [forceScreenshot, setForceScreenshot] = useState<boolean>(false);
+ const [isScreenshot, setIsScreenshot] = useState<boolean>(false);
+ useEffect(() => {
+ setIsScreenshot(
+ contentType === 'dashboard' ||
+ (contentType === 'chart' && reportFormat === 'PNG'),
+ );
+ }, [contentType, reportFormat]);
+
// Dropdown options
const [conditionNotNull, setConditionNotNull] = useState<boolean>(false);
const [sourceOptions, setSourceOptions] = useState<MetaObject[]>([]);
@@ -853,12 +863,16 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
}).then(response => setChartVizType(response.json.result.viz_type));
// Handle input/textarea updates
- const onTextChange = (
+ const onInputChange = (
event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>,
) => {
const { target } = event;
+ const value =
+ target.type === 'number'
+ ? parseInt(target.value, 10) || null
+ : target.value;
- updateAlertState(target.name, target.value);
+ updateAlertState(target.name, value);
};
const onTimeoutVerifyChange = (
@@ -1180,7 +1194,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
? TRANSLATIONS.REPORT_NAME_TEXT
: TRANSLATIONS.ALERT_NAME_TEXT
}
- onChange={onTextChange}
+ onChange={onInputChange}
css={inputSpacer}
/>
</div>
@@ -1216,7 +1230,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
name="description"
value={currentAlert ? currentAlert.description || '' : ''}
placeholder={TRANSLATIONS.DESCRIPTION_TEXT}
- onChange={onTextChange}
+ onChange={onInputChange}
css={inputSpacer}
/>
</div>
@@ -1471,18 +1485,34 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
</div>
</>
)}
- {(isReport || contentType === 'dashboard') && (
- <div className="inline-container">
- <StyledCheckbox
- data-test="bypass-cache"
- className="checkbox"
- checked={forceScreenshot}
- onChange={onForceScreenshotChange}
- >
- {TRANSLATIONS.IGNORE_CACHE_TEXT}
- </StyledCheckbox>
- </div>
+ {isScreenshot && (
+ <StyledInputContainer>
+ <div className="control-label">
+ {TRANSLATIONS.CUSTOM_SCREENSHOT_WIDTH_TEXT}
+ </div>
+ <div className="input-container">
+ <input
+ type="number"
+ name="custom_width"
+ value={currentAlert?.custom_width || ''}
+ placeholder={
+ TRANSLATIONS.CUSTOM_SCREENSHOT_WIDTH_PLACEHOLDER_TEXT
+ }
+ onChange={onInputChange}
+ />
+ </div>
+ </StyledInputContainer>
)}
+ <div className="inline-container">
+ <StyledCheckbox
+ data-test="bypass-cache"
+ className="checkbox"
+ checked={forceScreenshot}
+ onChange={onForceScreenshotChange}
+ >
+ {TRANSLATIONS.IGNORE_CACHE_TEXT}
+ </StyledCheckbox>
+ </div>
<StyledSectionTitle>
<h4>{TRANSLATIONS.NOTIFICATION_METHOD_TEXT}</h4>
<span className="required">*</span>
diff --git a/superset-frontend/src/features/alerts/types.ts b/superset-frontend/src/features/alerts/types.ts
index 36d2b1d35a..34eb7fd261 100644
--- a/superset-frontend/src/features/alerts/types.ts
+++ b/superset-frontend/src/features/alerts/types.ts
@@ -68,10 +68,12 @@ export type AlertObject = {
created_by?: user;
created_on?: string;
crontab?: string;
+ custom_width?: number | null;
dashboard?: MetaObject;
dashboard_id?: number;
database?: MetaObject;
description?: string;
+ error?: string;
force_screenshot: boolean;
grace_period?: number;
id: number;
@@ -91,7 +93,6 @@ export type AlertObject = {
};
validator_type?: string;
working_timeout?: number;
- error?: string;
};
export type LogObject = {
diff --git a/superset-frontend/src/reports/types.ts b/superset-frontend/src/reports/types.ts
index 38cb3865cf..b67a7bac7b 100644
--- a/superset-frontend/src/reports/types.ts
+++ b/superset-frontend/src/reports/types.ts
@@ -56,5 +56,6 @@ export interface ReportObject {
working_timeout: number;
creation_method: string;
force_screenshot: boolean;
+ custom_width?: number | null;
error?: string;
}
diff --git a/superset/config.py b/superset/config.py
index abb73e9f56..7c05e925d7 100644
--- a/superset/config.py
+++ b/superset/config.py
@@ -1273,6 +1273,9 @@ ALERT_REPORTS_NOTIFICATION_DRY_RUN = False
# Max tries to run queries to prevent false errors caused by transient errors
# being returned to users. Set to a value >1 to enable retries.
ALERT_REPORTS_QUERY_EXECUTION_MAX_TRIES = 1
+# Custom width for screenshots
+ALERT_REPORTS_MIN_CUSTOM_SCREENSHOT_WIDTH = 600
+ALERT_REPORTS_MAX_CUSTOM_SCREENSHOT_WIDTH = 2400
# A custom prefix to use on all Alerts & Reports emails
EMAIL_REPORTS_SUBJECT_PREFIX = "[Report] "
diff --git a/superset/reports/api.py b/superset/reports/api.py
index 125a3e6763..3686ab74bd 100644
--- a/superset/reports/api.py
+++ b/superset/reports/api.py
@@ -93,6 +93,7 @@ class ReportScheduleRestApi(BaseSupersetModelRestApi):
"context_markdown",
"creation_method",
"crontab",
+ "custom_width",
"dashboard.dashboard_title",
"dashboard.id",
"database.database_name",
@@ -159,6 +160,7 @@ class ReportScheduleRestApi(BaseSupersetModelRestApi):
"context_markdown",
"creation_method",
"crontab",
+ "custom_width",
"dashboard",
"database",
"description",
diff --git a/superset/reports/schemas.py b/superset/reports/schemas.py
index fbe681be36..7bdbf34f12 100644
--- a/superset/reports/schemas.py
+++ b/superset/reports/schemas.py
@@ -17,8 +17,9 @@
from typing import Any, Union
from croniter import croniter
+from flask import current_app
from flask_babel import gettext as _
-from marshmallow import fields, Schema, validate, validates_schema
+from marshmallow import fields, Schema, validate, validates, validates_schema
from marshmallow.validate import Length, Range, ValidationError
from pytz import all_timezones
@@ -208,10 +209,34 @@ class ReportSchedulePostSchema(Schema):
dump_default=None,
)
force_screenshot = fields.Boolean(dump_default=False)
+ custom_width = fields.Integer(
+ metadata={
+ "description": _("Custom width of the screenshot in pixels"),
+ "example": 1000,
+ },
+ allow_none=True,
+ required=False,
+ default=None,
+ )
+
+ @validates("custom_width")
+ def validate_custom_width(self, value: int) -> None: # pylint: disable=no-self-use
+ min_width = current_app.config["ALERT_REPORTS_MIN_CUSTOM_SCREENSHOT_WIDTH"]
+ max_width = current_app.config["ALERT_REPORTS_MAX_CUSTOM_SCREENSHOT_WIDTH"]
+ if not min_width <= value <= max_width:
+ raise ValidationError(
+ _(
+ "Screenshot width must be between %(min)spx and %(max)spx",
+ min=min_width,
+ max=max_width,
+ )
+ )
@validates_schema
def validate_report_references( # pylint: disable=unused-argument,no-self-use
- self, data: dict[str, Any], **kwargs: Any
+ self,
+ data: dict[str, Any],
+ **kwargs: Any,
) -> None:
if data["type"] == ReportScheduleType.REPORT:
if "database" in data:
@@ -307,3 +332,26 @@ class ReportSchedulePutSchema(Schema):
)
extra = fields.Dict(dump_default=None)
force_screenshot = fields.Boolean(dump_default=False)
+
+ custom_width = fields.Integer(
+ metadata={
+ "description": _("Custom width of the screenshot in pixels"),
+ "example": 1000,
+ },
+ allow_none=True,
+ required=False,
+ default=None,
+ )
+
+ @validates("custom_width")
+ def validate_custom_width(self, value: int) -> None: # pylint: disable=no-self-use
+ min_width = current_app.config["ALERT_REPORTS_MIN_CUSTOM_SCREENSHOT_WIDTH"]
+ max_width = current_app.config["ALERT_REPORTS_MAX_CUSTOM_SCREENSHOT_WIDTH"]
+ if not min_width <= value <= max_width:
+ raise ValidationError(
+ _(
+ "Screenshot width must be between %(min)spx and %(max)spx",
+ min=min_width,
+ max=max_width,
+ )
+ )
[superset] 05/05: Revert small change
Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
beto pushed a commit to branch customize_screenshot_width
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 6a358f5fec791364ae829320ca9deb2589240ef2
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Wed Jun 28 18:07:01 2023 -0700
Revert small change
---
.../src/features/alerts/AlertReportModal.tsx | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/superset-frontend/src/features/alerts/AlertReportModal.tsx b/superset-frontend/src/features/alerts/AlertReportModal.tsx
index d8d82b33ce..f20d98b146 100644
--- a/superset-frontend/src/features/alerts/AlertReportModal.tsx
+++ b/superset-frontend/src/features/alerts/AlertReportModal.tsx
@@ -1507,16 +1507,18 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
</div>
</StyledInputContainer>
)}
- <div className="inline-container">
- <StyledCheckbox
- data-test="bypass-cache"
- className="checkbox"
- checked={forceScreenshot}
- onChange={onForceScreenshotChange}
- >
- {TRANSLATIONS.IGNORE_CACHE_TEXT}
- </StyledCheckbox>
- </div>
+ {(isReport || contentType === 'dashboard') && (
+ <div className="inline-container">
+ <StyledCheckbox
+ data-test="bypass-cache"
+ className="checkbox"
+ checked={forceScreenshot}
+ onChange={onForceScreenshotChange}
+ >
+ {TRANSLATIONS.IGNORE_CACHE_TEXT}
+ </StyledCheckbox>
+ </div>
+ )}
<StyledSectionTitle>
<h4>{TRANSLATIONS.NOTIFICATION_METHOD_TEXT}</h4>
<span className="required">*</span>
[superset] 02/05: Update reports model
Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
beto pushed a commit to branch customize_screenshot_width
in repository https://gitbox.apache.org/repos/asf/superset.git
commit e6d614b4b307df0edc78ee81f6ec259bb0a455fc
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Wed Jun 28 10:44:07 2023 -0700
Update reports model
---
...5b0fb85b9a_add_custom_size_columns_to_report.py | 46 ++++++++++++++++++++++
superset/reports/models.py | 3 ++
2 files changed, 49 insertions(+)
diff --git a/superset/migrations/versions/2023-06-27_16-54_8e5b0fb85b9a_add_custom_size_columns_to_report.py b/superset/migrations/versions/2023-06-27_16-54_8e5b0fb85b9a_add_custom_size_columns_to_report.py
new file mode 100644
index 0000000000..83185e18c7
--- /dev/null
+++ b/superset/migrations/versions/2023-06-27_16-54_8e5b0fb85b9a_add_custom_size_columns_to_report.py
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Add custom size columns to report schedule
+
+Revision ID: 8e5b0fb85b9a
+Revises: 83e1abbe777f
+Create Date: 2023-06-27 16:54:57.161475
+
+"""
+
+import sqlalchemy as sa
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = "8e5b0fb85b9a"
+down_revision = "83e1abbe777f"
+
+
+def upgrade():
+ op.add_column(
+ "report_schedule",
+ sa.Column("custom_width", sa.Integer(), nullable=True),
+ )
+ op.add_column(
+ "report_schedule",
+ sa.Column("custom_height", sa.Integer(), nullable=True),
+ )
+
+
+def downgrade():
+ op.drop_column("report_schedule", "custom_width")
+ op.drop_column("report_schedule", "custom_height")
diff --git a/superset/reports/models.py b/superset/reports/models.py
index 24d4657b7d..2cbcbe0daa 100644
--- a/superset/reports/models.py
+++ b/superset/reports/models.py
@@ -154,6 +154,9 @@ class ReportSchedule(Model, AuditMixinNullable, ExtraJSONMixin):
# (Reports) When generating a screenshot, bypass the cache?
force_screenshot = Column(Boolean, default=False)
+ custom_width = Column(Integer, nullable=True)
+ custom_height = Column(Integer, nullable=True)
+
extra: ReportScheduleExtra # type: ignore
def __repr__(self) -> str:
[superset] 01/05: Add some constants
Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
beto pushed a commit to branch customize_screenshot_width
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 785f5ff851cb7b3cb4fa4ae779daeca492a39201
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Mon Jun 26 12:54:04 2023 -0700
Add some constants
---
superset/charts/api.py | 4 ++--
superset/utils/screenshots.py | 18 ++++++++++++------
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/superset/charts/api.py b/superset/charts/api.py
index c87b7bdda8..e8ccfa0fff 100644
--- a/superset/charts/api.py
+++ b/superset/charts/api.py
@@ -82,7 +82,7 @@ from superset.extensions import event_logger
from superset.models.slice import Slice
from superset.tasks.thumbnails import cache_chart_thumbnail
from superset.tasks.utils import get_current_user
-from superset.utils.screenshots import ChartScreenshot
+from superset.utils.screenshots import ChartScreenshot, DEFAULT_CHART_WINDOW_SIZE
from superset.utils.urls import get_url_path
from superset.views.base_api import (
BaseSupersetModelRestApi,
@@ -573,7 +573,7 @@ class ChartRestApi(BaseSupersetModelRestApi):
$ref: '#/components/responses/500'
"""
rison_dict = kwargs["rison"]
- window_size = rison_dict.get("window_size") or (800, 600)
+ window_size = rison_dict.get("window_size") or DEFAULT_CHART_WINDOW_SIZE
# Don't shrink the image if thumb_size is not specified
thumb_size = rison_dict.get("thumb_size") or window_size
diff --git a/superset/utils/screenshots.py b/superset/utils/screenshots.py
index 5c699e9e19..2743f85195 100644
--- a/superset/utils/screenshots.py
+++ b/superset/utils/screenshots.py
@@ -33,6 +33,12 @@ from superset.utils.webdriver import (
logger = logging.getLogger(__name__)
+DEFAULT_SCREENSHOT_WINDOW_SIZE = 800, 600
+DEFAULT_SCREENSHOT_THUMBNAIL_SIZE = 400, 300
+DEFAULT_CHART_WINDOW_SIZE = DEFAULT_CHART_THUMBNAIL_SIZE = 800, 600
+DEFAULT_DASHBOARD_WINDOW_SIZE = 1600, 1200
+DEFAULT_DASHBOARD_THUMBNAIL_SIZE = 800, 600
+
try:
from PIL import Image
except ModuleNotFoundError:
@@ -47,8 +53,8 @@ class BaseScreenshot:
driver_type = current_app.config["WEBDRIVER_TYPE"]
thumbnail_type: str = ""
element: str = ""
- window_size: WindowSize = (800, 600)
- thumb_size: WindowSize = (400, 300)
+ window_size: WindowSize = DEFAULT_SCREENSHOT_WINDOW_SIZE
+ thumb_size: WindowSize = DEFAULT_SCREENSHOT_THUMBNAIL_SIZE
def __init__(self, url: str, digest: str):
self.digest: str = digest
@@ -216,8 +222,8 @@ class ChartScreenshot(BaseScreenshot):
standalone=ChartStandaloneMode.HIDE_NAV.value,
)
super().__init__(url, digest)
- self.window_size = window_size or (800, 600)
- self.thumb_size = thumb_size or (800, 600)
+ self.window_size = window_size or DEFAULT_CHART_WINDOW_SIZE
+ self.thumb_size = thumb_size or DEFAULT_CHART_THUMBNAIL_SIZE
class DashboardScreenshot(BaseScreenshot):
@@ -239,5 +245,5 @@ class DashboardScreenshot(BaseScreenshot):
)
super().__init__(url, digest)
- self.window_size = window_size or (1600, 1200)
- self.thumb_size = thumb_size or (800, 600)
+ self.window_size = window_size or DEFAULT_DASHBOARD_WINDOW_SIZE
+ self.thumb_size = thumb_size or DEFAULT_DASHBOARD_THUMBNAIL_SIZE
[superset] 04/05: Fix style
Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
beto pushed a commit to branch customize_screenshot_width
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 9d1516ddb88217d52d9bfafd963d38d46b36e8ad
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Wed Jun 28 16:20:01 2023 -0700
Fix style
---
superset-frontend/src/components/ReportModal/index.tsx | 15 +++++++++++----
superset-frontend/src/components/ReportModal/styles.tsx | 4 ++++
.../src/features/alerts/AlertReportModal.tsx | 6 +++++-
3 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/superset-frontend/src/components/ReportModal/index.tsx b/superset-frontend/src/components/ReportModal/index.tsx
index cb229f1f3f..c66ea0e6c3 100644
--- a/superset-frontend/src/components/ReportModal/index.tsx
+++ b/superset-frontend/src/components/ReportModal/index.tsx
@@ -41,10 +41,14 @@ import {
NOTIFICATION_FORMATS,
} from 'src/reports/types';
import { reportSelector } from 'src/views/CRUD/hooks';
-import { TRANSLATIONS } from 'src/features/alerts/AlertReportModal';
+import {
+ TRANSLATIONS,
+ StyledInputContainer,
+} from 'src/features/alerts/AlertReportModal';
import { CreationMethod } from './HeaderReportDropdown';
import {
antDErrorAlertStyles,
+ CustomWidthHeaderStyle,
StyledModal,
StyledTopSection,
StyledBottomSection,
@@ -260,8 +264,11 @@ function ReportModal({
</>
);
const renderCustomWidthSection = (
- <div>
- <div className="control-label">
+ <StyledInputContainer>
+ <div
+ className="control-label"
+ css={(theme: SupersetTheme) => CustomWidthHeaderStyle(theme)}
+ >
{TRANSLATIONS.CUSTOM_SCREENSHOT_WIDTH_TEXT}
</div>
<div className="input-container">
@@ -277,7 +284,7 @@ function ReportModal({
}}
/>
</div>
- </div>
+ </StyledInputContainer>
);
return (
diff --git a/superset-frontend/src/components/ReportModal/styles.tsx b/superset-frontend/src/components/ReportModal/styles.tsx
index 960da9b10e..dd0a410ef5 100644
--- a/superset-frontend/src/components/ReportModal/styles.tsx
+++ b/superset-frontend/src/components/ReportModal/styles.tsx
@@ -90,6 +90,10 @@ export const TimezoneHeaderStyle = (theme: SupersetTheme) => css`
margin: ${theme.gridUnit * 3}px 0 ${theme.gridUnit * 2}px;
`;
+export const CustomWidthHeaderStyle = (theme: SupersetTheme) => css`
+ margin: ${theme.gridUnit * 3}px 0 ${theme.gridUnit * 2}px;
+`;
+
export const SectionHeaderStyle = (theme: SupersetTheme) => css`
margin: ${theme.gridUnit * 3}px 0;
`;
diff --git a/superset-frontend/src/features/alerts/AlertReportModal.tsx b/superset-frontend/src/features/alerts/AlertReportModal.tsx
index 0aeae9103e..d8d82b33ce 100644
--- a/superset-frontend/src/features/alerts/AlertReportModal.tsx
+++ b/superset-frontend/src/features/alerts/AlertReportModal.tsx
@@ -46,6 +46,7 @@ import Owner from 'src/types/Owner';
import { AntdCheckbox, AsyncSelect, Select } from 'src/components';
import TextAreaControl from 'src/explore/components/controls/TextAreaControl';
import { useCommonConf } from 'src/features/databases/state';
+import { CustomWidthHeaderStyle } from 'src/components/ReportModal/styles';
import { InfoTooltipWithTrigger } from '@superset-ui/chart-controls';
import {
NotificationMethodOption,
@@ -1487,7 +1488,10 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
)}
{isScreenshot && (
<StyledInputContainer>
- <div className="control-label">
+ <div
+ className="control-label"
+ css={(theme: SupersetTheme) => CustomWidthHeaderStyle(theme)}
+ >
{TRANSLATIONS.CUSTOM_SCREENSHOT_WIDTH_TEXT}
</div>
<div className="input-container">