mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
[dashboard scoped filters] Add all time related options to filter scope settings (#8636)
This commit is contained in:
parent
f04b72c341
commit
acf0753504
@ -24,6 +24,7 @@ import {
|
|||||||
getDashboardFilterKey,
|
getDashboardFilterKey,
|
||||||
} from './getDashboardFilterKey';
|
} from './getDashboardFilterKey';
|
||||||
import { CHART_TYPE } from '../util/componentTypes';
|
import { CHART_TYPE } from '../util/componentTypes';
|
||||||
|
import { DASHBOARD_FILTER_SCOPE_GLOBAL } from '../reducers/dashboardFilters';
|
||||||
|
|
||||||
let allFilterBoxChartIds = [];
|
let allFilterBoxChartIds = [];
|
||||||
let activeFilters = {};
|
let activeFilters = {};
|
||||||
@ -61,7 +62,9 @@ export function getAppliedFilterValues(chartId) {
|
|||||||
return appliedFilterValuesByChart[chartId];
|
return appliedFilterValuesByChart[chartId];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getChartIdsInFilterScope({ filterScope }) {
|
export function getChartIdsInFilterScope({
|
||||||
|
filterScope = DASHBOARD_FILTER_SCOPE_GLOBAL,
|
||||||
|
}) {
|
||||||
function traverse(chartIds = [], component = {}, immuneChartIds = []) {
|
function traverse(chartIds = [], component = {}, immuneChartIds = []) {
|
||||||
if (!component) {
|
if (!component) {
|
||||||
return;
|
return;
|
||||||
|
@ -18,12 +18,20 @@
|
|||||||
*/
|
*/
|
||||||
/* eslint-disable camelcase */
|
/* eslint-disable camelcase */
|
||||||
import {
|
import {
|
||||||
|
TIME_FILTER_MAP,
|
||||||
TIME_RANGE,
|
TIME_RANGE,
|
||||||
FILTER_LABELS,
|
FILTER_LABELS,
|
||||||
} from '../../visualizations/FilterBox/FilterBox';
|
} from '../../visualizations/FilterBox/FilterBox';
|
||||||
|
|
||||||
export default function getFilterConfigsFromFormdata(form_data = {}) {
|
export default function getFilterConfigsFromFormdata(form_data = {}) {
|
||||||
const { date_filter, filter_configs = [] } = form_data;
|
const {
|
||||||
|
date_filter,
|
||||||
|
filter_configs = [],
|
||||||
|
show_druid_time_granularity,
|
||||||
|
show_druid_time_origin,
|
||||||
|
show_sqla_time_column,
|
||||||
|
show_sqla_time_granularity,
|
||||||
|
} = form_data;
|
||||||
let configs = filter_configs.reduce(
|
let configs = filter_configs.reduce(
|
||||||
({ columns, labels }, config) => {
|
({ columns, labels }, config) => {
|
||||||
const updatedColumns = {
|
const updatedColumns = {
|
||||||
@ -44,15 +52,43 @@ export default function getFilterConfigsFromFormdata(form_data = {}) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (date_filter) {
|
if (date_filter) {
|
||||||
const updatedColumns = {
|
let updatedColumns = {
|
||||||
...configs.columns,
|
...configs.columns,
|
||||||
[TIME_RANGE]: form_data[TIME_RANGE],
|
[TIME_FILTER_MAP.time_range]: form_data.time_range,
|
||||||
};
|
};
|
||||||
const updatedLabels = {
|
const updatedLabels = {
|
||||||
...configs.labels,
|
...configs.labels,
|
||||||
[TIME_RANGE]: FILTER_LABELS[TIME_RANGE],
|
[TIME_FILTER_MAP.time_range]: FILTER_LABELS[TIME_RANGE],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (show_sqla_time_column) {
|
||||||
|
updatedColumns = {
|
||||||
|
...updatedColumns,
|
||||||
|
[TIME_FILTER_MAP.time_grain_sqla]: form_data.time_grain_sqla,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (show_sqla_time_granularity) {
|
||||||
|
updatedColumns = {
|
||||||
|
...updatedColumns,
|
||||||
|
[TIME_FILTER_MAP.granularity_sqla]: form_data.granularity_sqla,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (show_druid_time_granularity) {
|
||||||
|
updatedColumns = {
|
||||||
|
...updatedColumns,
|
||||||
|
[TIME_FILTER_MAP.granularity]: form_data.granularity,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (show_druid_time_origin) {
|
||||||
|
updatedColumns = {
|
||||||
|
...updatedColumns,
|
||||||
|
[TIME_FILTER_MAP.druid_time_origin]: form_data.druid_time_origin,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
configs = {
|
configs = {
|
||||||
...configs,
|
...configs,
|
||||||
columns: updatedColumns,
|
columns: updatedColumns,
|
||||||
|
@ -36,7 +36,7 @@ import FilterBadgeIcon from '../../components/FilterBadgeIcon';
|
|||||||
import './FilterBox.less';
|
import './FilterBox.less';
|
||||||
|
|
||||||
// maps control names to their key in extra_filters
|
// maps control names to their key in extra_filters
|
||||||
const TIME_FILTER_MAP = {
|
export const TIME_FILTER_MAP = {
|
||||||
time_range: '__time_range',
|
time_range: '__time_range',
|
||||||
granularity_sqla: '__time_col',
|
granularity_sqla: '__time_col',
|
||||||
time_grain_sqla: '__time_grain',
|
time_grain_sqla: '__time_grain',
|
||||||
@ -44,7 +44,8 @@ const TIME_FILTER_MAP = {
|
|||||||
granularity: '__granularity',
|
granularity: '__granularity',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const TIME_RANGE = '__time_range';
|
// a shortcut to a map key, used by many components
|
||||||
|
export const TIME_RANGE = TIME_FILTER_MAP.time_range;
|
||||||
export const FILTER_LABELS = {
|
export const FILTER_LABELS = {
|
||||||
[TIME_RANGE]: 'Time range',
|
[TIME_RANGE]: 'Time range',
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user