forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: so 514 tablechart plugin controls migration (apache#508)
* add controls to index * remove consoles * Update package.json
- Loading branch information
1 parent
247b68a
commit 68949ce
Showing
3 changed files
with
246 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
242 changes: 242 additions & 0 deletions
242
.../temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-table/src/controlPanel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,242 @@ | ||
/** | ||
* 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. | ||
*/ | ||
import React from 'react'; | ||
import { t } from '@superset-ui/translation'; | ||
import { | ||
formatSelectOptions, | ||
D3_TIME_FORMAT_OPTIONS, | ||
ColumnOption, | ||
} from '@superset-ui/control-utils'; | ||
import { validateNonEmpty } from '@superset-ui/validator'; | ||
|
||
export default { | ||
controlPanelSections: [ | ||
{ | ||
label: t('GROUP BY'), | ||
description: t('Use this section if you want a query that aggregates'), | ||
expanded: true, | ||
controlSetRows: [ | ||
['groupby'], | ||
['metrics'], | ||
[ | ||
{ | ||
name: 'percent_metrics', | ||
config: { | ||
type: 'MetricsControl', | ||
multi: true, | ||
mapStateToProps: (state: never) => { | ||
const { datasource } = state; | ||
const { columns, metrics, type } = datasource; | ||
return { | ||
columns: datasource ? columns : [], | ||
savedMetrics: datasource ? metrics : [], | ||
datasourceType: datasource && type, | ||
}; | ||
}, | ||
default: [], | ||
label: t('Percentage Metrics'), | ||
validators: [], | ||
description: t('Metrics for which percentage of total are to be displayed'), | ||
}, | ||
}, | ||
], | ||
['timeseries_limit_metric', 'row_limit'], | ||
[ | ||
{ | ||
name: 'include_time', | ||
config: { | ||
type: 'CheckboxControl', | ||
label: t('Include Time'), | ||
description: t( | ||
'Whether to include the time granularity as defined in the time section', | ||
), | ||
default: false, | ||
}, | ||
}, | ||
{ | ||
name: 'order_desc', | ||
config: { | ||
type: 'CheckboxControl', | ||
label: t('Sort Descending'), | ||
default: true, | ||
description: t('Whether to sort descending or ascending'), | ||
}, | ||
}, | ||
], | ||
], | ||
}, | ||
{ | ||
label: t('NOT GROUPED BY'), | ||
description: t('Use this section if you want to query atomic rows'), | ||
expanded: true, | ||
controlSetRows: [ | ||
[ | ||
{ | ||
name: 'all_columns', | ||
config: { | ||
type: 'SelectControl', | ||
multi: true, | ||
label: t('Columns'), | ||
default: [], | ||
description: t('Columns to display'), | ||
optionRenderer: (c: never) => <ColumnOption showType column={c} />, | ||
valueRenderer: (c: never) => <ColumnOption column={c} />, | ||
valueKey: 'column_name', | ||
allowAll: true, | ||
mapStateToProps: (state: { datasource: { columns: unknown } }) => ({ | ||
options: state.datasource ? state.datasource.columns : [], | ||
}), | ||
commaChoosesOption: false, | ||
freeForm: true, | ||
}, | ||
}, | ||
], | ||
[ | ||
{ | ||
name: 'order_by_cols', | ||
config: { | ||
type: 'SelectControl', | ||
multi: true, | ||
label: t('Ordering'), | ||
default: [], | ||
description: t('One or many metrics to display'), | ||
// eslint-disable-next-line camelcase | ||
mapStateToProps: (state: { datasource: { order_by_choices: never } }) => ({ | ||
choices: state.datasource ? state.datasource.order_by_choices : [], | ||
}), | ||
}, | ||
}, | ||
], | ||
['row_limit', null], | ||
], | ||
}, | ||
{ | ||
label: t('Query'), | ||
expanded: true, | ||
controlSetRows: [['adhoc_filters']], | ||
}, | ||
{ | ||
label: t('Options'), | ||
expanded: true, | ||
controlSetRows: [ | ||
[ | ||
{ | ||
name: 'table_timestamp_format', | ||
config: { | ||
type: 'SelectControl', | ||
freeForm: true, | ||
label: t('Table Timestamp Format'), | ||
default: '%Y-%m-%d %H:%M:%S', | ||
renderTrigger: true, | ||
validators: [validateNonEmpty], | ||
clearable: false, | ||
choices: D3_TIME_FORMAT_OPTIONS, | ||
description: t('Timestamp Format'), | ||
}, | ||
}, | ||
], | ||
[ | ||
{ | ||
name: 'page_length', | ||
config: { | ||
type: 'SelectControl', | ||
freeForm: true, | ||
renderTrigger: true, | ||
label: t('Page Length'), | ||
default: 0, | ||
choices: formatSelectOptions([0, 10, 25, 40, 50, 75, 100, 150, 200]), | ||
description: t('Rows per page, 0 means no pagination'), | ||
}, | ||
}, | ||
null, | ||
], | ||
[ | ||
{ | ||
name: 'include_search', | ||
config: { | ||
type: 'CheckboxControl', | ||
label: t('Search Box'), | ||
renderTrigger: true, | ||
default: false, | ||
description: t('Whether to include a client-side search box'), | ||
}, | ||
}, | ||
{ | ||
name: 'table_filter', | ||
config: { | ||
type: 'CheckboxControl', | ||
label: t('Emit Filter Events'), | ||
renderTrigger: true, | ||
default: false, | ||
description: t('Whether to apply filter when items are clicked'), | ||
}, | ||
}, | ||
], | ||
[ | ||
{ | ||
name: 'align_pn', | ||
config: { | ||
type: 'CheckboxControl', | ||
label: t('Align +/-'), | ||
renderTrigger: true, | ||
default: false, | ||
description: t('Whether to align the background chart for +/- values'), | ||
}, | ||
}, | ||
{ | ||
name: 'color_pn', | ||
config: { | ||
type: 'CheckboxControl', | ||
label: t('Color +/-'), | ||
renderTrigger: true, | ||
default: true, | ||
description: t('Whether to color +/- values'), | ||
}, | ||
}, | ||
], | ||
[ | ||
{ | ||
name: 'show_cell_bars', | ||
config: { | ||
type: 'CheckboxControl', | ||
label: t('Show Cell Bars'), | ||
renderTrigger: true, | ||
default: true, | ||
description: t('Enable to display bar chart background elements in table columns'), | ||
}, | ||
}, | ||
null, | ||
], | ||
], | ||
}, | ||
], | ||
controlOverrides: { | ||
metrics: { | ||
validators: [], | ||
}, | ||
}, | ||
sectionOverrides: { | ||
druidTimeSeries: { | ||
controlSetRows: [['granularity', 'druid_time_origin'], ['time_range']], | ||
}, | ||
sqlaTimeSeries: { | ||
controlSetRows: [['granularity_sqla', 'time_grain_sqla'], ['time_range']], | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters