Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Feb 1, 2017
1 parent e8afca8 commit 874ad1e
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class GridLayout extends React.Component {
}

render() {
console.log(this.state.slices);
return (
<ResponsiveReactGridLayout
className="layout"
Expand Down
21 changes: 11 additions & 10 deletions superset/assets/javascripts/explorev2/components/ChartContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ class ChartContainer extends React.PureComponent {
renderViz() {
const mockSlice = this.getMockedSliceObject();
this.setState({ mockSlice });
visMap[this.props.viz_type](mockSlice, this.props.queryResponse);
try {
//visMap[this.props.viz_type](mockSlice, this.props.queryResponse);
visMap[this.props.viz_type](mockSlice, this.props.queryResponse);
} catch (e) {
this.props.actions.chartRenderingFailed(e);
}
Expand Down Expand Up @@ -114,10 +113,10 @@ class ChartContainer extends React.PureComponent {
},

data: {
csv_endpoint: getExploreUrl(this.props.form_data, this.props.datasource_type, 'csv'),
json_endpoint: getExploreUrl(this.props.form_data, this.props.datasource_type, 'json'),
csv_endpoint: getExploreUrl(this.props.formData, this.props.datasource_type, 'csv'),
json_endpoint: getExploreUrl(this.props.formData, this.props.datasource_type, 'json'),
standalone_endpoint: getExploreUrl(
this.props.form_data, this.props.datasource_type, 'standalone'),
this.props.formData, this.props.datasource_type, 'standalone'),
},

};
Expand Down Expand Up @@ -236,8 +235,10 @@ class ChartContainer extends React.PureComponent {
ChartContainer.propTypes = propTypes;

function mapStateToProps(state) {
const form_data = {};
Object.keys(state.fields).forEach(f => form_data[f] = state.fields[f].value);
const formData = {};
Object.keys(state.fields).forEach(f => {
formData[f] = state.fields[f].value;
});
return {
alert: state.chartAlert,
can_download: state.can_download,
Expand All @@ -247,12 +248,12 @@ function mapStateToProps(state) {
column_formats: state.datasource ? state.datasource.column_formats : null,
containerId: state.slice ? `slice-container-${state.slice.slice_id}` : 'slice-container',
datasource_type: state.datasource_type,
form_data,
formData,
isStarred: state.isStarred,
queryResponse: state.queryResponse,
slice: state.slice,
table_name: form_data.datasource_name,
viz_type: form_data.viz_type,
table_name: formData.datasource_name,
viz_type: formData.viz_type,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { bindActionCreators } from 'redux';
import * as actions from '../actions/exploreActions';
import { connect } from 'react-redux';
import { Panel, Alert } from 'react-bootstrap';
import visTypes, { sectionsToRender } from '../stores/visTypes';
import { sectionsToRender } from '../stores/visTypes';
import ControlPanelSection from './ControlPanelSection';
import FieldSetRow from './FieldSetRow';
import FieldSet from './FieldSet';
Expand Down Expand Up @@ -36,9 +36,9 @@ class ControlPanelsContainer extends React.Component {
}
}
getFieldData(fieldName) {
const mapStateToProps = fields[fieldName].mapStateToProps;
if (mapStateToProps) {
return Object.assign({}, this.props.fields[fieldName], mapStateToProps(this.props.exploreState));
const mapF = fields[fieldName].mapStateToProps;
if (mapF) {
return Object.assign({}, this.props.fields[fieldName], mapF(this.props.exploreState));
}
return this.props.fields[fieldName];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ const propTypes = {
datasource_type: React.PropTypes.string.isRequired,
chartStatus: React.PropTypes.string.isRequired,
fields: React.PropTypes.object.isRequired,
form_data: React.PropTypes.object.isRequired,
};


class ExploreViewContainer extends React.Component {
constructor(props) {
super(props);
Expand All @@ -30,9 +30,6 @@ class ExploreViewContainer extends React.Component {
componentDidMount() {
window.addEventListener('resize', this.handleResize.bind(this));
this.runQuery();

const datasource_id = this.props.fields.datasource.value;
const datasource_type = this.props.datasource_type;
this.props.actions.fetchDatasources();
}

Expand All @@ -55,8 +52,7 @@ class ExploreViewContainer extends React.Component {
history.pushState(
{},
document.title,
getExploreUrl(this.props.form_data),
);
getExploreUrl(this.props.form_data));
// remove alerts when query
this.props.actions.removeControlPanelAlert();
this.props.actions.removeChartAlert();
Expand Down Expand Up @@ -156,7 +152,9 @@ ExploreViewContainer.propTypes = propTypes;

function mapStateToProps(state) {
const form_data = {};
Object.keys(state.fields).forEach(f => form_data[f] = state.fields[f].value);
Object.keys(state.fields).forEach(f => {
form_data[f] = state.fields[f].value;
});
return {
chartStatus: state.chartStatus,
datasource_type: state.datasource_type,
Expand Down
1 change: 0 additions & 1 deletion superset/assets/javascripts/explorev2/exploreUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export function getParamObject(form_data, datasource_type, saveNewSlice) {
return data;
}

//TODO
export function getExploreUrl(form_data, dummy, endpoint = 'base') {
const [datasource_id, datasource_type] = form_data.datasource.split('__');
let params = `${datasource_type}/${datasource_id}/`;
Expand Down
6 changes: 3 additions & 3 deletions superset/assets/javascripts/explorev2/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const exploreViewContainer = document.getElementById('js-explore-view-container'
const bootstrapData = JSON.parse(exploreViewContainer.getAttribute('data-bootstrap'));

import { exploreReducer } from './reducers/exploreReducer';
const fields = getFieldsState(bootstrapData, bootstrapData.form_data);
const formData = bootstrapData.form_data;
const fields = getFieldsState(bootstrapData, formData);
fields.filters.value = getFilters(formData, bootstrapData.datasource_type);
delete bootstrapData.form_data;

// Initial state
Expand All @@ -38,9 +40,7 @@ const bootstrappedState = Object.assign(
queryResponse: null,
}
);
console.log(bootstrappedState);

//bootstrappedState.form_data.filters = getFilters(form_data, bootstrapData.datasource_type);

const store = createStore(exploreReducer, bootstrappedState,
compose(applyMiddleware(thunk), initEnhancer(false))
Expand Down
2 changes: 1 addition & 1 deletion superset/assets/javascripts/explorev2/stores/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const fields = {
choices: datasources,
isLoading: datasources.length === 0,
editUrl: MAP_DATASOURCE_TYPE_TO_EDIT_URL[state.datasource_type],
}
};
},
description: '',
},
Expand Down
3 changes: 1 addition & 2 deletions superset/assets/javascripts/modules/superset.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,8 @@ const px = function () {
$('#timer').removeClass('label-danger label-success');
$('#timer').addClass('label-warning');
$.getJSON(this.jsonEndpoint(), queryResponse => {
vizMap[formData.viz_type](this, queryResponse);
try {
//vizMap[formData.viz_type](this, queryResponse);
vizMap[formData.viz_type](this, queryResponse);
this.done(queryResponse);
} catch (e) {
this.error('An error occurred while rendering the visualization: ' + e);
Expand Down

0 comments on commit 874ad1e

Please sign in to comment.