mirror of
https://github.com/apache/superset.git
synced 2026-04-21 17:14:57 +00:00
Added controls for Table Viz (#1253)
* Added controls for Table Viz * Change control panel container to stateless * Changed specs * Resolved conflicts
This commit is contained in:
@@ -1,20 +1,36 @@
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { Panel } from 'react-bootstrap';
|
||||
import TimeFilter from './TimeFilter';
|
||||
import ChartControl from './ChartControl';
|
||||
import GroupBy from './GroupBy';
|
||||
import SqlClause from './SqlClause';
|
||||
import Filters from './Filters';
|
||||
import { DefaultControls, VIZ_CONTROL_MAPPING } from '../constants';
|
||||
|
||||
const ControlPanelsContainer = function () {
|
||||
const propTypes = {
|
||||
vizType: React.PropTypes.string,
|
||||
};
|
||||
|
||||
const defaultProps = {
|
||||
vizType: null,
|
||||
};
|
||||
|
||||
function ControlPanelsContainer(props) {
|
||||
return (
|
||||
<Panel>
|
||||
<ChartControl />
|
||||
<TimeFilter />
|
||||
<GroupBy />
|
||||
<SqlClause />
|
||||
<Filters />
|
||||
{DefaultControls}
|
||||
{VIZ_CONTROL_MAPPING[props.vizType]}
|
||||
</Panel>
|
||||
);
|
||||
};
|
||||
export default ControlPanelsContainer;
|
||||
}
|
||||
|
||||
ControlPanelsContainer.propTypes = propTypes;
|
||||
ControlPanelsContainer.defaultProps = defaultProps;
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
vizType: state.vizType,
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps() {
|
||||
return {};
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(ControlPanelsContainer);
|
||||
|
||||
@@ -109,7 +109,6 @@ class Filters extends React.Component {
|
||||
}
|
||||
|
||||
Filters.propTypes = propTypes;
|
||||
|
||||
Filters.defaultProps = defaultProps;
|
||||
|
||||
function mapStateToProps(state) {
|
||||
|
||||
@@ -20,11 +20,11 @@ const defaultProps = {
|
||||
};
|
||||
|
||||
class GroupBy extends React.Component {
|
||||
changeColumns(groupByColumnOpts) {
|
||||
this.props.actions.setGroupByColumns(groupByColumnOpts);
|
||||
changeColumns(groupByColumns) {
|
||||
this.props.actions.setGroupByColumns(groupByColumns);
|
||||
}
|
||||
changeMetrics(metricsOpts) {
|
||||
this.props.actions.setMetrics(metricsOpts);
|
||||
changeMetrics(metrics) {
|
||||
this.props.actions.setMetrics(metrics);
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
import React from 'react';
|
||||
import Select from 'react-select';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import * as actions from '../actions/exploreActions';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
const propTypes = {
|
||||
actions: React.PropTypes.object,
|
||||
columnOpts: React.PropTypes.array,
|
||||
columns: React.PropTypes.array,
|
||||
orderingOpts: React.PropTypes.array,
|
||||
orderings: React.PropTypes.array,
|
||||
};
|
||||
|
||||
const defaultProps = {
|
||||
columnOpts: [],
|
||||
columns: [],
|
||||
orderingOpts: [],
|
||||
orderings: [],
|
||||
};
|
||||
|
||||
class NotGroupBy extends React.Component {
|
||||
changeColumns(columns) {
|
||||
this.props.actions.setNotGroupByColumns(columns);
|
||||
}
|
||||
changeOrderings(orderings) {
|
||||
this.props.actions.setOrderings(orderings);
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<div className="panel space-1">
|
||||
<div className="panel-header">Not GroupBy</div>
|
||||
<div className="panel-body">
|
||||
<div className="row">
|
||||
<h5 className="section-heading">Columns</h5>
|
||||
<Select
|
||||
multi
|
||||
name="select-column"
|
||||
placeholder="Select columns"
|
||||
options={this.props.columnOpts}
|
||||
value={this.props.columns}
|
||||
autosize={false}
|
||||
onChange={this.changeColumns.bind(this)}
|
||||
/>
|
||||
</div>
|
||||
<div className="row">
|
||||
<h5 className="section-heading">Orderings</h5>
|
||||
<Select
|
||||
multi
|
||||
name="select-orderings"
|
||||
placeholder="Select orderings"
|
||||
options={this.props.orderingOpts}
|
||||
value={this.props.orderings}
|
||||
autosize={false}
|
||||
onChange={this.changeOrderings.bind(this)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
NotGroupBy.propTypes = propTypes;
|
||||
NotGroupBy.defaultProps = defaultProps;
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
columnOpts: state.columnOpts,
|
||||
columns: state.columns,
|
||||
orderingOpts: state.orderingOpts,
|
||||
orderings: state.orderings,
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators(actions, dispatch),
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(NotGroupBy);
|
||||
76
caravel/assets/javascripts/explorev2/components/Options.jsx
Normal file
76
caravel/assets/javascripts/explorev2/components/Options.jsx
Normal file
@@ -0,0 +1,76 @@
|
||||
import React from 'react';
|
||||
import Select from 'react-select';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import * as actions from '../actions/exploreActions';
|
||||
import { connect } from 'react-redux';
|
||||
import { timestampOptions, rowLimitOptions } from '../constants';
|
||||
|
||||
const propTypes = {
|
||||
actions: React.PropTypes.object,
|
||||
timeStampFormat: React.PropTypes.string,
|
||||
rowLimit: React.PropTypes.number,
|
||||
};
|
||||
|
||||
const defaultProps = {
|
||||
timeStampFormat: null,
|
||||
rowLimit: null,
|
||||
};
|
||||
|
||||
class Options extends React.Component {
|
||||
changeTimeStampFormat(timeStampFormat) {
|
||||
const val = (timeStampFormat) ? timeStampFormat.value : null;
|
||||
this.props.actions.setTimeStampFormat(val);
|
||||
}
|
||||
changeRowLimit(rowLimit) {
|
||||
this.props.actions.setRowLimit(rowLimit);
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<div className="panel space-1">
|
||||
<div className="panel-header">Options</div>
|
||||
<div className="panel-body">
|
||||
<div className="row">
|
||||
<h5 className="section-heading">Table Timestamp Format</h5>
|
||||
<Select
|
||||
name="select-timestamp-format"
|
||||
placeholder="Select timestamp format"
|
||||
options={timestampOptions.map((t) => ({ value: t[0], label: t[1] }))}
|
||||
value={this.props.timeStampFormat}
|
||||
autosize={false}
|
||||
onChange={this.changeTimeStampFormat.bind(this)}
|
||||
/>
|
||||
</div>
|
||||
<div className="row">
|
||||
<h5 className="section-heading">Row Limit</h5>
|
||||
<Select
|
||||
name="select-row-limit"
|
||||
placeholder="Select row limit"
|
||||
options={rowLimitOptions.map((r) => ({ value: r, label: r }))}
|
||||
value={this.props.rowLimit}
|
||||
autosize={false}
|
||||
onChange={this.changeRowLimit.bind(this)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Options.propTypes = propTypes;
|
||||
Options.defaultProps = defaultProps;
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
timeStampFormat: state.timeStampFormat,
|
||||
rowLimit: state.rowLimit,
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators(actions, dispatch),
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Options);
|
||||
Reference in New Issue
Block a user