-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow query to display while slice is loading (#2100)
* Allow query to display while slice is loading * Put latestQueryFormData in store * Reorganized query function, got rid of tu[le return values
- Loading branch information
1 parent
ffa15c2
commit 0cddcaa
Showing
9 changed files
with
133 additions
and
65 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
56 changes: 40 additions & 16 deletions
56
superset/assets/javascripts/explorev2/components/DisplayQueryButton.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,25 +1,49 @@ | ||
import React, { PropTypes } from 'react'; | ||
import ModalTrigger from './../../components/ModalTrigger'; | ||
const $ = window.$ = require('jquery'); | ||
|
||
const propTypes = { | ||
query: PropTypes.string, | ||
queryEndpoint: PropTypes.string.isRequired, | ||
}; | ||
|
||
const defaultProps = { | ||
query: '', | ||
}; | ||
|
||
export default function DisplayQueryButton({ query }) { | ||
const modalBody = (<pre>{query}</pre>); | ||
return ( | ||
<ModalTrigger | ||
isButton | ||
triggerNode={<span>Query</span>} | ||
modalTitle="Query" | ||
modalBody={modalBody} | ||
/> | ||
); | ||
export default class DisplayQueryButton extends React.PureComponent { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
modalBody: <pre />, | ||
}; | ||
} | ||
beforeOpen() { | ||
this.setState({ | ||
modalBody: | ||
(<img | ||
className="loading" | ||
alt="Loading..." | ||
src="/static/assets/images/loading.gif" | ||
/>), | ||
}); | ||
$.ajax({ | ||
type: 'GET', | ||
url: this.props.queryEndpoint, | ||
success: (data) => { | ||
this.setState({ modalBody: (<pre>{data.query}</pre>) }); | ||
}, | ||
error(data) { | ||
this.setState({ modalBody: (<pre>{data.error}</pre>) }); | ||
}, | ||
}); | ||
} | ||
render() { | ||
return ( | ||
<ModalTrigger | ||
isButton | ||
triggerNode={<span>Query</span>} | ||
modalTitle="Query" | ||
beforeOpen={this.beforeOpen.bind(this)} | ||
modalBody={this.state.modalBody} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
DisplayQueryButton.propTypes = propTypes; | ||
DisplayQueryButton.defaultProps = defaultProps; |
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
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
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
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