mirror of
https://github.com/apache/superset.git
synced 2026-04-17 15:15:20 +00:00
* Add #views and #distinct users to created dashboard on profile page * Added index on logs to speed up query * Added #views and #users for slice table * Add a views column to dashboards and slices, prepopulate them with Log data * Remove index on Log model * Remove unused index * Update 1b2c3f7c96f9_.py fix multiple heads * Exclude postgres in prepopulating views column
70 lines
1.7 KiB
JavaScript
70 lines
1.7 KiB
JavaScript
import React from 'react';
|
|
import moment from 'moment';
|
|
import TableLoader from './TableLoader';
|
|
|
|
const propTypes = {
|
|
user: React.PropTypes.object.isRequired,
|
|
};
|
|
|
|
class CreatedContent extends React.PureComponent {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
dashboardsLoading: true,
|
|
slicesLoading: true,
|
|
dashboards: [],
|
|
slices: [],
|
|
};
|
|
}
|
|
renderSliceTable() {
|
|
const mutator = (data) => data.map(slice => ({
|
|
slice: <a href={slice.url}>{slice.title}</a>,
|
|
views: slice.views,
|
|
favorited: moment.utc(slice.dttm).fromNow(),
|
|
_favorited: slice.dttm,
|
|
}));
|
|
return (
|
|
<TableLoader
|
|
dataEndpoint={`/superset/created_slices/${this.props.user.userId}/`}
|
|
className="table table-condensed"
|
|
columns={['slice', 'favorited', 'views']}
|
|
mutator={mutator}
|
|
noDataText="No slices"
|
|
sortable
|
|
/>
|
|
);
|
|
}
|
|
renderDashboardTable() {
|
|
const mutator = (data) => data.map(dash => ({
|
|
dashboard: <a href={dash.url}>{dash.title}</a>,
|
|
views: dash.views,
|
|
favorited: moment.utc(dash.dttm).fromNow(),
|
|
_favorited: dash.dttm,
|
|
}));
|
|
return (
|
|
<TableLoader
|
|
className="table table-condensed"
|
|
mutator={mutator}
|
|
dataEndpoint={`/superset/created_dashboards/${this.props.user.userId}/`}
|
|
noDataText="No dashboards"
|
|
columns={['dashboard', 'favorited', 'views']}
|
|
sortable
|
|
/>
|
|
);
|
|
}
|
|
render() {
|
|
return (
|
|
<div>
|
|
<h3>Dashboards</h3>
|
|
{this.renderDashboardTable()}
|
|
<hr />
|
|
<h3>Slices</h3>
|
|
{this.renderSliceTable()}
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
CreatedContent.propTypes = propTypes;
|
|
|
|
export default CreatedContent;
|