mirror of
https://github.com/apache/superset.git
synced 2026-04-25 19:14:27 +00:00
Added access check + Druid in endpoint (#1224)
* Explore control panel - Chart control, TimeFilter, GroupBy, Filters (#1205) * create structure for new forked explore view (#1099) * create structure for new forked explore view * update component name * add bootstrap data pattern * remove console.log * Associate version to entry files (#1060) * Associate version to entry files * Modified path joins for configs * Made changes based on comments * Created store and reducers (#1108) * Created store and reducers * Added spec * Modifications based on comments * Explore control panel components: Chart control, Time filter, SQL, GroupBy and Filters * Modifications based on comments * Added access check + Druid in endpoint * pull grains to constants * Switch explore.html to old version
This commit is contained in:
@@ -29,6 +29,7 @@ export const CHANGE_FILTER_OP = 'CHANGE_FILTER_OP';
|
||||
export const CHANGE_FILTER_VALUE = 'CHANGE_FILTER_VALUE';
|
||||
export const RESET_FORM_DATA = 'RESET_FORM_DATA';
|
||||
export const CLEAR_ALL_OPTS = 'CLEAR_ALL_OPTS';
|
||||
export const SET_DATASOURCE_CLASS = 'SET_DATASOURCE_CLASS';
|
||||
|
||||
export function setTimeColumnOpts(timeColumnOpts) {
|
||||
return { type: SET_TIME_COLUMN_OPTS, timeColumnOpts };
|
||||
@@ -59,6 +60,10 @@ export function clearAllOpts() {
|
||||
return { type: CLEAR_ALL_OPTS };
|
||||
}
|
||||
|
||||
export function setDatasourceClass(datasourceClass) {
|
||||
return { type: SET_DATASOURCE_CLASS, datasourceClass };
|
||||
}
|
||||
|
||||
export function setFormOpts(datasourceId, datasourceType) {
|
||||
return function (dispatch) {
|
||||
const timeColumnOpts = [];
|
||||
@@ -73,7 +78,7 @@ export function setFormOpts(datasourceId, datasourceType) {
|
||||
|
||||
$.get(url, (data, status) => {
|
||||
if (status === 'success') {
|
||||
data.dttm_cols.forEach((d) => {
|
||||
data.time_columns.forEach((d) => {
|
||||
if (d) timeColumnOpts.push({ value: d, label: d });
|
||||
});
|
||||
data.groupby_cols.forEach((d) => {
|
||||
@@ -89,6 +94,7 @@ export function setFormOpts(datasourceId, datasourceType) {
|
||||
if (d) timeGrainOpts.push({ value: d, label: d });
|
||||
});
|
||||
// Repopulate options for controls
|
||||
dispatch(setDatasourceClass(data.datasource_class));
|
||||
dispatch(setTimeColumnOpts(timeColumnOpts));
|
||||
dispatch(setTimeGrainOpts(timeGrainOpts));
|
||||
dispatch(setGroupByColumnOpts(groupByColumnOpts));
|
||||
|
||||
@@ -7,6 +7,7 @@ import { sinceOptions, untilOptions } from '../constants';
|
||||
|
||||
const propTypes = {
|
||||
actions: React.PropTypes.object,
|
||||
datasourceClass: React.PropTypes.string,
|
||||
timeColumnOpts: React.PropTypes.array,
|
||||
timeColumn: React.PropTypes.string,
|
||||
timeGrainOpts: React.PropTypes.array,
|
||||
@@ -42,16 +43,20 @@ class TimeFilter extends React.Component {
|
||||
this.props.actions.setUntil(val);
|
||||
}
|
||||
render() {
|
||||
const timeColumnPlaceHolder =
|
||||
(this.props.datasourceClass === 'SqlaTable') ? 'Time Column' : 'Time Granularity';
|
||||
const timeGrainPlaceHolder =
|
||||
(this.props.datasourceClass === 'SqlaTable') ? 'Time Grain' : 'Origin';
|
||||
return (
|
||||
<div className="panel space-1">
|
||||
<div className="panel-header">Time Filter</div>
|
||||
<div className="panel-body">
|
||||
<div className="row">
|
||||
<h5 className="section-heading">Time Column & Grain</h5>
|
||||
<h5 className="section-heading">Time Column & Grains</h5>
|
||||
<Select
|
||||
className="col-sm-6"
|
||||
name="select-time-column"
|
||||
placeholder="Select a time column"
|
||||
placeholder={`Select a ${timeColumnPlaceHolder}`}
|
||||
options={this.props.timeColumnOpts}
|
||||
value={this.props.timeColumn}
|
||||
autosize={false}
|
||||
@@ -60,7 +65,7 @@ class TimeFilter extends React.Component {
|
||||
<Select
|
||||
className="col-sm-6"
|
||||
name="select-time-grain"
|
||||
placeholder="Select a time grain"
|
||||
placeholder={`Select a ${timeGrainPlaceHolder}`}
|
||||
options={this.props.timeGrainOpts}
|
||||
value={this.props.timeGrain}
|
||||
autosize={false}
|
||||
@@ -99,6 +104,7 @@ TimeFilter.defaultProps = defaultProps;
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
datasourceClass: state.datasourceClass,
|
||||
timeColumnOpts: state.timeColumnOpts,
|
||||
timeColumn: state.timeColumn,
|
||||
timeGrainOpts: state.timeGrainOpts,
|
||||
|
||||
@@ -17,12 +17,13 @@ const bootstrappedState = Object.assign(initialState, {
|
||||
datasources: bootstrapData.datasources,
|
||||
datasourceId: parseInt(bootstrapData.datasource_id, 10),
|
||||
datasourceType: bootstrapData.datasource_type,
|
||||
datasourceClass: bootstrapData.datasource_class,
|
||||
sliceName: bootstrapData.viz.form_data.slice_name,
|
||||
sliceId: bootstrapData.viz.form_data.slice_id,
|
||||
vizType: bootstrapData.viz.form_data.viz_type,
|
||||
timeColumn: bootstrapData.viz.form_data.granularity_sqla,
|
||||
timeGrain: bootstrapData.viz.form_data.time_grain_sqla,
|
||||
metrics: [bootstrapData.viz.form_data.metric].map((m) => ({ value: m, label: m })),
|
||||
metrics: [bootstrapData.viz.form_data.metrics].map((m) => ({ value: m, label: m })),
|
||||
since: bootstrapData.viz.form_data.since,
|
||||
until: bootstrapData.viz.form_data.until,
|
||||
havingClause: bootstrapData.viz.form_data.having,
|
||||
|
||||
@@ -103,6 +103,9 @@ export const exploreReducer = function (state, action) {
|
||||
[actions.CLEAR_ALL_OPTS]() {
|
||||
return Object.assign({}, state, defaultOpts);
|
||||
},
|
||||
[actions.SET_DATASOURCE_CLASS]() {
|
||||
return Object.assign({}, state, { datasourceClass: action.datasourceClass });
|
||||
},
|
||||
};
|
||||
if (action.type in actionHandlers) {
|
||||
return actionHandlers[action.type]();
|
||||
|
||||
@@ -2,6 +2,7 @@ export const initialState = {
|
||||
datasources: null,
|
||||
datasourceId: null,
|
||||
datasourceType: null,
|
||||
datasourceClass: null,
|
||||
vizType: null,
|
||||
timeColumnOpts: [],
|
||||
timeColumn: null,
|
||||
|
||||
Reference in New Issue
Block a user