-
Notifications
You must be signed in to change notification settings - Fork 14.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added controls for Table Viz #1253
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
import React from 'react'; | ||
import TimeFilter from './components/TimeFilter'; | ||
import ChartControl from './components/ChartControl'; | ||
import GroupBy from './components/GroupBy'; | ||
import SqlClause from './components/SqlClause'; | ||
import Filters from './components/Filters'; | ||
import NotGroupBy from './components/NotGroupBy'; | ||
import Options from './components/Options'; | ||
|
||
export const VIZ_TYPES = [ | ||
{ value: 'dist_bar', label: 'Distribution - Bar Chart', requiresTime: false }, | ||
{ value: 'pie', label: 'Pie Chart', requiresTime: false }, | ||
|
@@ -33,3 +42,35 @@ export const sinceOptions = ['1 hour ago', '12 hours ago', '1 day ago', | |
'7 days ago', '28 days ago', '90 days ago', '1 year ago']; | ||
export const untilOptions = ['now', '1 day ago', '7 days ago', | ||
'28 days ago', '90 days ago', '1 year ago']; | ||
|
||
export const timestampOptions = [ | ||
['smart_date', 'Adaptative formating'], | ||
['%m/%d/%Y', '"%m/%d/%Y" | 01/14/2019'], | ||
['%Y-%m-%d', '"%Y-%m-%d" | 2019-01-14'], | ||
['%Y-%m-%d %H:%M:%S', | ||
'"%Y-%m-%d %H:%M:%S" | 2019-01-14 01:32:10'], | ||
['%H:%M:%S', '"%H:%M:%S" | 01:32:10'], | ||
]; | ||
|
||
export const rowLimitOptions = [10, 50, 100, 250, 500, 1000, 5000, 10000, 50000]; | ||
|
||
export const DefaultControls = ( | ||
<div> | ||
<ChartControl /> | ||
<TimeFilter /> | ||
<GroupBy /> | ||
<SqlClause /> | ||
<Filters /> | ||
</div> | ||
); | ||
|
||
export const TableVizControls = ( | ||
<div> | ||
<NotGroupBy /> | ||
<Options /> | ||
</div> | ||
); | ||
|
||
export const VIZ_CONTROL_MAPPING = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The viz-control panel mapping is stored here |
||
table: TableVizControls, | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the variable names here to avoid confusion: Opts variables are for dropdown menu values, non-Opts values are for selected ones.