2016-09-11 10:39:07 -04:00
|
|
|
import { Alert, Button, Tab, Tabs } from 'react-bootstrap';
|
2016-08-30 00:55:31 -04:00
|
|
|
import QueryHistory from './QueryHistory';
|
|
|
|
import ResultSet from './ResultSet';
|
|
|
|
import React from 'react';
|
|
|
|
|
2016-09-11 10:39:07 -04:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { bindActionCreators } from 'redux';
|
|
|
|
import * as Actions from '../actions';
|
|
|
|
import shortid from 'shortid';
|
|
|
|
|
|
|
|
class SouthPane extends React.Component {
|
|
|
|
popSelectStar() {
|
|
|
|
const qe = {
|
|
|
|
id: shortid.generate(),
|
|
|
|
title: this.props.latestQuery.tempTable,
|
|
|
|
autorun: false,
|
|
|
|
dbId: this.props.latestQuery.dbId,
|
|
|
|
sql: `SELECT * FROM ${this.props.latestQuery.tempTable}`,
|
|
|
|
};
|
|
|
|
this.props.actions.addQueryEditor(qe);
|
|
|
|
}
|
|
|
|
render() {
|
|
|
|
let results = <div />;
|
|
|
|
const latestQuery = this.props.latestQuery;
|
|
|
|
if (latestQuery) {
|
|
|
|
if (['running', 'pending'].includes(latestQuery.state)) {
|
|
|
|
results = (
|
|
|
|
<img className="loading" alt="Loading.." src="/static/assets/images/loading.gif" />
|
|
|
|
);
|
|
|
|
} else if (latestQuery.state === 'failed') {
|
|
|
|
results = <Alert bsStyle="danger">{latestQuery.errorMessage}</Alert>;
|
|
|
|
} else if (latestQuery.state === 'success' && latestQuery.ctas) {
|
|
|
|
results = (
|
|
|
|
<div>
|
|
|
|
<Alert bsStyle="info">
|
|
|
|
Table [<strong>{latestQuery.tempTable}</strong>] was created
|
|
|
|
</Alert>
|
|
|
|
<p>
|
|
|
|
<Button
|
|
|
|
bsSize="small"
|
|
|
|
className="m-r-5"
|
|
|
|
onClick={this.popSelectStar.bind(this)}
|
|
|
|
>
|
|
|
|
Query in a new tab
|
|
|
|
</Button>
|
|
|
|
<Button bsSize="small">Visualize</Button>
|
|
|
|
</p>
|
|
|
|
</div>);
|
|
|
|
} else if (latestQuery.state === 'success') {
|
|
|
|
results = <ResultSet showControls search query={latestQuery} />;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
results = <Alert bsStyle="info">Run a query to display results here</Alert>;
|
2016-08-30 00:55:31 -04:00
|
|
|
}
|
2016-09-11 10:39:07 -04:00
|
|
|
return (
|
|
|
|
<div className="SouthPane">
|
2016-10-04 02:58:47 -04:00
|
|
|
<Tabs bsStyle="tabs" id={shortid.generate()}>
|
2016-10-19 12:17:08 -04:00
|
|
|
<Tab title="Results" eventKey={1}>
|
2016-09-11 10:39:07 -04:00
|
|
|
<div style={{ overflow: 'auto' }}>
|
|
|
|
{results}
|
|
|
|
</div>
|
|
|
|
</Tab>
|
|
|
|
<Tab title="Query History" eventKey={2}>
|
|
|
|
<QueryHistory />
|
|
|
|
</Tab>
|
|
|
|
</Tabs>
|
|
|
|
</div>
|
|
|
|
);
|
2016-08-30 00:55:31 -04:00
|
|
|
}
|
2016-09-11 10:39:07 -04:00
|
|
|
}
|
2016-08-30 00:55:31 -04:00
|
|
|
|
|
|
|
SouthPane.propTypes = {
|
|
|
|
latestQuery: React.PropTypes.object,
|
2016-09-11 10:39:07 -04:00
|
|
|
actions: React.PropTypes.object,
|
2016-08-30 00:55:31 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
SouthPane.defaultProps = {
|
|
|
|
};
|
|
|
|
|
2016-09-11 10:39:07 -04:00
|
|
|
function mapDispatchToProps(dispatch) {
|
|
|
|
return {
|
|
|
|
actions: bindActionCreators(Actions, dispatch),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
export default connect(null, mapDispatchToProps)(SouthPane);
|