-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added controls for Table Viz (#1253)
* Added controls for Table Viz * Change control panel container to stateless * Changed specs * Resolved conflicts
- Loading branch information
Showing
11 changed files
with
298 additions
and
89 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
42 changes: 29 additions & 13 deletions
42
caravel/assets/javascripts/explorev2/components/ControlPanelsContainer.jsx
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 |
---|---|---|
@@ -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); |
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
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
82 changes: 82 additions & 0 deletions
82
caravel/assets/javascripts/explorev2/components/NotGroupBy.jsx
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,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 changes: 76 additions & 0 deletions
76
caravel/assets/javascripts/explorev2/components/Options.jsx
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,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); |
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
Oops, something went wrong.