mirror of
https://github.com/apache/superset.git
synced 2024-09-20 04:29:47 -04:00
4b77710016
* [SQL Lab] Adding DB options for SQL LAb each db can be exposed or not in SQL Lab CTAS is an option target_schema placeholder (not hooked yet, but would force the CTAS to target a specific schema) * Addressing comments
56 lines
1.1 KiB
JavaScript
56 lines
1.1 KiB
JavaScript
import React from 'react';
|
|
import { bindActionCreators } from 'redux';
|
|
import { connect } from 'react-redux';
|
|
import * as Actions from '../actions';
|
|
|
|
const $ = require('jquery');
|
|
|
|
|
|
class QueryAutoRefresh extends React.Component {
|
|
componentWillMount() {
|
|
this.startTimer();
|
|
}
|
|
componentWillUnmount() {
|
|
this.stopTimer();
|
|
}
|
|
startTimer() {
|
|
if (!(this.timer)) {
|
|
this.timer = setInterval(this.stopwatch.bind(this), 1000);
|
|
}
|
|
}
|
|
stopTimer() {
|
|
clearInterval(this.timer);
|
|
this.timer = null;
|
|
}
|
|
stopwatch() {
|
|
const url = '/caravel/queries/0';
|
|
// No updates in case of failure.
|
|
$.getJSON(url, (data, status) => {
|
|
if (status === 'success') {
|
|
this.props.actions.refreshQueries(data);
|
|
}
|
|
});
|
|
}
|
|
render() {
|
|
return null;
|
|
}
|
|
}
|
|
QueryAutoRefresh.propTypes = {
|
|
actions: React.PropTypes.object,
|
|
};
|
|
QueryAutoRefresh.defaultProps = {
|
|
// queries: null,
|
|
};
|
|
|
|
function mapStateToProps() {
|
|
return {};
|
|
}
|
|
|
|
function mapDispatchToProps(dispatch) {
|
|
return {
|
|
actions: bindActionCreators(Actions, dispatch),
|
|
};
|
|
}
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(QueryAutoRefresh);
|