mirror of
https://github.com/apache/superset.git
synced 2026-04-17 07:05:04 +00:00
User profile pages (favorites, created content, recent activity, security & access) (#1615)
* Super * User profile page * Fixing python style * Python unit tests * Touchups and js tests * Addressing comments
This commit is contained in:
committed by
GitHub
parent
5ae98bc7c9
commit
7e1852ee88
@@ -0,0 +1,64 @@
|
||||
import React from 'react';
|
||||
import { Table, Tr, Td } from 'reactable';
|
||||
import { Collapse } from 'react-bootstrap';
|
||||
import $ from 'jquery';
|
||||
|
||||
const propTypes = {
|
||||
dataEndpoint: React.PropTypes.string.isRequired,
|
||||
mutator: React.PropTypes.func,
|
||||
columns: React.PropTypes.arrayOf(React.PropTypes.string),
|
||||
};
|
||||
|
||||
export default class TableLoader extends React.PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
isLoading: true,
|
||||
data: [],
|
||||
};
|
||||
}
|
||||
componentWillMount() {
|
||||
$.get(this.props.dataEndpoint, (data) => {
|
||||
let actualData = data;
|
||||
if (this.props.mutator) {
|
||||
actualData = this.props.mutator(data);
|
||||
}
|
||||
this.setState({ data: actualData, isLoading: false });
|
||||
});
|
||||
}
|
||||
render() {
|
||||
const tableProps = Object.assign({}, this.props);
|
||||
let columns = this.props.columns;
|
||||
if (!columns && this.state.data.length > 0) {
|
||||
columns = Object.keys(this.state.data[0]).filter(col => col[0] !== '_');
|
||||
}
|
||||
delete tableProps.dataEndpoint;
|
||||
delete tableProps.mutator;
|
||||
delete tableProps.columns;
|
||||
if (this.state.isLoading) {
|
||||
return <img alt="loading" width="25" src="/static/assets/images/loading.gif" />;
|
||||
}
|
||||
return (
|
||||
<Collapse in transitionAppear >
|
||||
<div>
|
||||
<Table {...tableProps}>
|
||||
{this.state.data.map((row, i) => (
|
||||
<Tr key={i}>
|
||||
{columns.map(col => {
|
||||
if (row.hasOwnProperty('_' + col)) {
|
||||
return (
|
||||
<Td key={col} column={col} value={row['_' + col]}>
|
||||
{row[col]}
|
||||
</Td>);
|
||||
}
|
||||
return <Td key={col} column={col}>{row[col]}</Td>;
|
||||
})}
|
||||
</Tr>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
</Collapse>
|
||||
);
|
||||
}
|
||||
}
|
||||
TableLoader.propTypes = propTypes;
|
||||
Reference in New Issue
Block a user