Commit c4264db4 authored by Jakub Beránek's avatar Jakub Beránek
Browse files

ENH: add option to hide empty views from grid overview

parent 4eb7287d
......@@ -45,7 +45,8 @@ type Props = OwnProps & StateProps & DispatchProps & RouteComponentProps<void>;
const initialState = {
viewFilter: {
query: '',
sortMode: ViewSortMode.CreationTime
sortMode: ViewSortMode.CreationTime,
hideEmpty: true
} as ViewFilter
};
type State = Readonly<typeof initialState>;
......@@ -75,6 +76,7 @@ const Label = styled.div`
text-align: center;
`;
class GridChartPageComponent extends PureComponent<Props, State>
{
readonly state: State = initialState;
......@@ -134,6 +136,9 @@ class GridChartPageComponent extends PureComponent<Props, State>
renderView = (view: View): JSX.Element =>
{
const measurements = view.measurements;
if (this.state.viewFilter.hideEmpty && measurements.length === 0) return null;
const datasets = view.yAxes.map(yAxis => ({
name: `${view.name} (${formatKey(yAxis)})`,
yAxis,
......
......@@ -15,6 +15,11 @@ const Wrapper = styled.div`
margin-bottom: 0;
}
`;
const Row = styled.div`
display: flex;
align-items: center;
justify-content: space-between;
`;
const Label = styled.div`
font-size: 1.25rem;
`;
......@@ -42,6 +47,10 @@ export class ViewFilterComponent extends PureComponent<Props>
<option value={ViewSortMode.Name}>View name</option>
</Input>
</Wrapper>
<Row>
<Label>Hide empty: </Label>
<input type='checkbox' checked={this.props.filter.hideEmpty} onChange={this.changeHideEmpty} />
</Row>
</>
);
}
......@@ -53,6 +62,13 @@ export class ViewFilterComponent extends PureComponent<Props>
query: event.currentTarget.value
});
}
changeHideEmpty = (event: React.ChangeEvent<HTMLInputElement>) =>
{
this.props.onChange({
...this.props.filter,
hideEmpty: event.currentTarget.checked
});
}
changeSortMode = (event: React.ChangeEvent<HTMLInputElement>) =>
{
this.props.onChange({
......
......@@ -12,6 +12,7 @@ export interface ViewFilter
{
query: string;
sortMode: ViewSortMode;
hideEmpty: boolean;
}
export function applyFilter(views: View[], filter: ViewFilter): View[]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment