Skip to content
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

Replace query once query response returned #2415

Merged
merged 2 commits into from
Mar 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added jitney_events
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ class ChartContainer extends React.PureComponent {
if (this.props.standalone) {
return this.renderChart();
}
const queryResponse = this.props.queryResponse;
const query = queryResponse && queryResponse.query ? queryResponse.query : null;
return (
<div className="chart-container">
<Panel
Expand Down Expand Up @@ -270,6 +272,7 @@ class ChartContainer extends React.PureComponent {
<ExploreActionButtons
slice={this.state.mockSlice}
canDownload={this.props.can_download}
query={query}
queryEndpoint={getExploreUrl(this.props.latestQueryFormData, 'query')}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { github } from 'react-syntax-highlighter/dist/styles';
const $ = window.$ = require('jquery');

const propTypes = {
query: PropTypes.string,
queryEndpoint: PropTypes.string.isRequired,
};

Expand All @@ -25,22 +26,29 @@ export default class DisplayQueryButton extends React.PureComponent {
src="/static/assets/images/loading.gif"
/>),
});
$.ajax({
type: 'GET',
url: this.props.queryEndpoint,
success: (data) => {
const modalBody = data.language ?
<SyntaxHighlighter language={data.language} style={github}>
{data.query}
</SyntaxHighlighter>
:
<pre>{data.query}</pre>;
this.setState({ modalBody });
},
error(data) {
this.setState({ modalBody: (<pre>{data.error}</pre>) });
},
});
if (this.props.query) {
const modalBody = (
<pre>{this.props.query}</pre>
);
this.setState({ modalBody });
} else {
$.ajax({
type: 'GET',
url: this.props.queryEndpoint,
success: (data) => {
const modalBody = data.language ?
<SyntaxHighlighter language={data.language} style={github}>
{data.query}
</SyntaxHighlighter>
:
<pre>{data.query}</pre>;
this.setState({ modalBody });
},
error(data) {
this.setState({ modalBody: (<pre>{data.error}</pre>) });
},
});
}
}
render() {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ const propTypes = {
canDownload: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]).isRequired,
slice: PropTypes.object,
queryEndpoint: PropTypes.string,
query: PropTypes.string,
};

export default function ExploreActionButtons({ canDownload, slice, queryEndpoint }) {
export default function ExploreActionButtons({ canDownload, slice, query, queryEndpoint }) {
const exportToCSVClasses = cx('btn btn-default btn-sm', {
'disabled disabledButton': !canDownload,
});
Expand Down Expand Up @@ -40,6 +41,7 @@ export default function ExploreActionButtons({ canDownload, slice, queryEndpoint
</a>

<DisplayQueryButton
query={query}
queryEndpoint={queryEndpoint}
/>
</div>
Expand Down
3 changes: 2 additions & 1 deletion superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2182,7 +2182,8 @@ def search_queries(self):
def refresh_datasources(self):
"""endpoint that refreshes druid datasources metadata"""
session = db.session()
DruidCluster = ConnectorRegistry.sources['druid']
DruidDatasource = ConnectorRegistry.sources['druid']
DruidCluster = DruidDatasource.cluster_class
for cluster in session.query(DruidCluster).all():
cluster_name = cluster.cluster_name
try:
Expand Down