-
Notifications
You must be signed in to change notification settings - Fork 12.9k
/
FaveQueries.jsx
68 lines (63 loc) · 1.49 KB
/
FaveQueries.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const $ = window.$ = require('jquery');
import QueryTable from './QueryTable';
import React from 'react';
const propTypes = {
actions: React.PropTypes.object.isRequired,
};
class FaveQueries extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
favedQueries: [],
fetching: false,
};
}
deleteQuery(query) {
this.props.actions.favouriteQuery(query, false);
this.fetchFaveQueries();
}
fetchFaveQueries() {
this.setState({ fetching: true });
$.ajax({
type: 'GET',
url: '/superset/fave_queries/',
success: (data) => {
this.setState({ favedQueries: data });
this.setState({ fetching: false });
},
});
}
componentDidMount() {
this.fetchFaveQueries();
}
render() {
if (this.state.fetching) {
return (
<img
className="loading"
alt="Loading..."
src="/static/assets/images/loading.gif"
/>
);
}
return (
<div
style={{ height: this.props.height }}
className="scrollbar-container"
>
<div className="scrollbar-content">
<QueryTable
columns={[
'db', 'schema', 'sql', 'querylink', 'delete',
]}
queries={this.state.favedQueries}
actions={this.props.actions}
onDelete={this.deleteQuery.bind(this)}
/>
</div>
</div>
);
}
}
FaveQueries.propTypes = propTypes;
export default FaveQueries;