import ListHeader from './ListHeader';
import Spinner from '../../components/Spinner';
import SourceViewer from '../../../code/components/SourceViewer';
+import ListFooter from '../../../../components/shared/list-footer';
export default class ListView extends React.Component {
static contextTypes = {
onFetchList(baseComponent, metric, Number(periodIndex));
}
+ handleFetchMore () {
+ const periodIndex = this.props.location.query.period || 1;
+ this.props.onFetchMore(Number(periodIndex));
+ }
+
changeSelected (selected) {
this.props.onSelect(selected);
}
}
render () {
- const { component, components, metrics, metric, leakPeriod, selected, fetching } = this.props;
+ const { component, components, metrics, metric, leakPeriod, selected, total, fetching } = this.props;
const { onSelectNext, onSelectPrevious } = this.props;
const breadcrumbs = [component];
{!selected && (
<div className={classNames({ 'new-loading': fetching })}>
{(!fetching || components.length !== 0) ? (
- <ComponentsList
- components={components}
- metrics={metrics}
- selected={selected}
- metric={metric}
- onClick={this.handleClick.bind(this)}/>
+ <div>
+ <ComponentsList
+ components={components}
+ metrics={metrics}
+ selected={selected}
+ metric={metric}
+ onClick={this.handleClick.bind(this)}/>
+ <ListFooter
+ count={components.length}
+ total={total}
+ loadMore={this.handleFetchMore.bind(this)}/>
+ </div>
) : (
<Spinner/>
)}
import pick from '../../../../../../../node_modules/lodash/pick';
import ListView from './ListView';
-import { fetchList, selectComponent, selectNext, selectPrevious } from '../../store/listViewActions';
+import { fetchList, fetchMore, selectComponent, selectNext, selectPrevious } from '../../store/listViewActions';
const mapStateToProps = state => {
const drilldown = pick(state.list, [
const mapDispatchToProps = dispatch => {
return {
onFetchList: (baseComponent, metric, periodIndex) => dispatch(fetchList(baseComponent, metric, periodIndex)),
+ onFetchMore: periodIndex => dispatch(fetchMore(periodIndex)),
onSelect: component => dispatch(selectComponent(component)),
onSelectNext: component => dispatch(selectNext(component)),
onSelectPrevious: component => dispatch(selectPrevious(component))
import ListHeader from './ListHeader';
import Spinner from '../../components/Spinner';
import SourceViewer from '../../../code/components/SourceViewer';
+import ListFooter from '../../../../components/shared/list-footer';
export default class TreeView extends React.Component {
componentDidMount () {
onStart(baseComponent, metric, Number(periodIndex));
}
+ handleFetchMore () {
+ this.props.onFetchMore();
+ }
+
changeSelected (selected) {
this.props.onSelect(selected);
}
}
render () {
- const { components, metrics, breadcrumbs, metric, leakPeriod, selected, fetching } = this.props;
+ const { components, metrics, breadcrumbs, metric, leakPeriod, selected, total, fetching } = this.props;
const { onSelectNext, onSelectPrevious } = this.props;
const selectedIndex = components.indexOf(selected);
{!selected && (
<div>
{(!fetching || components.length !== 0) ? (
- <ComponentsList
- components={components}
- metrics={metrics}
- selected={selected}
- metric={metric}
- onClick={this.handleClick.bind(this)}/>
+ <div>
+ <ComponentsList
+ components={components}
+ metrics={metrics}
+ selected={selected}
+ metric={metric}
+ onClick={this.handleClick.bind(this)}/>
+ <ListFooter
+ count={components.length}
+ total={total}
+ loadMore={this.handleFetchMore.bind(this)}/>
+ </div>
) : (
<Spinner/>
)}
start,
drilldown,
useBreadcrumbs,
+ fetchMore,
selectComponent,
selectNext,
selectPrevious
onStart: (rootComponent, metric, periodIndex) => dispatch(start(rootComponent, metric, periodIndex)),
onDrilldown: component => dispatch(drilldown(component)),
onUseBreadcrumbs: component => dispatch(useBreadcrumbs(component)),
+ onFetchMore: () => dispatch(fetchMore()),
onSelect: component => dispatch(selectComponent(component)),
onSelectNext: component => dispatch(selectNext(component)),
onSelectPrevious: component => dispatch(selectPrevious(component))
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { getComponentTree } from '../../../api/components';
-import { enhanceWithMeasure, filterOutEmptyMeasures } from '../utils';
+import { enhanceWithMeasure } from '../utils';
import { startFetching, stopFetching } from './statusActions';
import complementary from '../config/complementary';
function makeRequest (baseComponent, metric, options, periodIndex = 1) {
const asc = metric.direction === 1;
- const ps = 200;
- const finalOptions = { asc, ps };
+ const ps = 100;
+ const finalOptions = { asc, ps, metricSortFilter: 'withMeasuresOnly' };
if (metric.key.indexOf('new_') === 0) {
Object.assign(options, {
const options = { p: pageIndex };
return makeRequest(baseComponent, metric, options, periodIndex).then(r => {
- const nextComponents = filterOutEmptyMeasures(enhanceWithMeasure(r.components, metric.key, periodIndex));
+ const nextComponents = enhanceWithMeasure(r.components, metric.key, periodIndex);
return {
components: nextComponents,
};
}
+export function fetchMore (periodIndex) {
+ return (dispatch, getState) => {
+ const { baseComponent, metric, pageIndex, components } = getState().list;
+ dispatch(startFetching());
+ return fetchLeaves(baseComponent, metric, pageIndex + 1, periodIndex).then(r => {
+ const nextComponents = [...components, ...r.components];
+ dispatch(updateStore({ ...r, components: nextComponents }));
+ dispatch(stopFetching());
+ });
+ };
+}
+
/**
* Select specified component from the list
* @param component A component to select
import initial from 'lodash/initial';
import { getComponentTree } from '../../../api/components';
-import { filterOutEmptyMeasures, enhanceWithMeasure } from '../utils';
+import { enhanceWithMeasure } from '../utils';
import { startFetching, stopFetching } from './statusActions';
import complementary from '../config/complementary';
function makeRequest (rootComponent, baseComponent, metric, options, periodIndex = 1) {
const asc = metric.direction === 1;
const ps = 100;
- const finalOptions = { asc, ps };
+ const finalOptions = { asc, ps, metricSortFilter: 'withMeasuresOnly' };
if (metric.key.indexOf('new_') === 0) {
Object.assign(options, {
const options = { p: pageIndex };
return makeRequest(rootComponent, baseComponent, metric, options, periodIndex).then(r => {
- const nextComponents = filterOutEmptyMeasures(enhanceWithMeasure(r.components, metric.key, periodIndex));
+ const nextComponents = enhanceWithMeasure(r.components, metric.key, periodIndex);
return {
baseComponent,
};
}
+export function fetchMore () {
+ return (dispatch, getState) => {
+ const { rootComponent, baseComponent, metric, pageIndex, components, periodIndex } = getState().tree;
+ dispatch(startFetching());
+ return fetchComponents(rootComponent, baseComponent, metric, pageIndex + 1, periodIndex).then(r => {
+ const nextComponents = [...components, ...r.components];
+ dispatch(updateStore({ ...r, components: nextComponents }));
+ dispatch(stopFetching());
+ });
+ };
+}
+
/**
* Select given component from the list
* @param component