Commit 4c5b1c5e authored by Matija Obreza's avatar Matija Obreza
Browse files

Added 'Dataset lists' tab to Dashboard

parent a7a7d03d
Pipeline #3792 passed with stages
in 3 minutes and 39 seconds
......@@ -27,7 +27,7 @@ function descriptorList(state = INITIAL_STATE, action: { type: string, payload?:
}
case LIST_DESCRIPTORLISTS: {
console.log('Marking loading of ', action.payload);
// console.log('Marking loading of ', action.payload);
return update(state, {
loading: { $set: { uuid: null, ...action.payload } },
});
......@@ -50,7 +50,7 @@ function descriptorList(state = INITIAL_STATE, action: { type: string, payload?:
// set the paged to whatever came in
case RECEIVE_DESCRIPTORLISTS: {
console.log('Marking loaded pagedQuery', action.payload.query);
// console.log('Marking loaded pagedQuery', action.payload.query);
return update(state, {
loading: { $set: null },
paged: { $set: action.payload.paged },
......
......@@ -6,7 +6,7 @@ import {bindActionCreators} from 'redux';
import {createDatasetRequest, listMyDatasets} from 'actions/dataset';
import {listMyDescriptors} from 'actions/descriptors';
import {createDescriptorList} from 'actions/descriptorList';
import {listMyDescriptorLists, createDescriptorList} from 'actions/descriptorList';
import {IDatasetFilter, IDescriptorFilter} from 'model/filter.model';
import {Page} from 'model/common.model';
import {Dataset} from 'model/dataset.model';
......@@ -20,18 +20,6 @@ import {BaseMyDataPage} from './MyDataPage';
import DashboardButton from './c/DashboardButton';
import MyDataTable from './c/MyDataTable';
interface IAdministrationDashboardProps extends React.ClassAttributes<any> {
classes: any;
createDatasetRequest: () => void;
router: any;
listMyDatasets: (page?: number, results?: number, sortBy?: string, filter?: IDatasetFilter, order?: string) => void;
datasetPage: Page<Dataset>;
listMyDescriptors: (page?: number, results?: number, sortBy?: string, filter?: IDescriptorFilter, order?: string) => void;
descriptorPage: Page<Descriptor>;
createDescriptorList: any;
appMounted: boolean;
}
const styles = {
root: {
width: '100%',
......@@ -49,9 +37,6 @@ const styles = {
},
};
const sortBy = 'lastModifiedDate';
const order = 'DESC';
class AdministrationDashboard extends BaseMyDataPage {
constructor(props) {
super(props);
......@@ -79,25 +64,32 @@ class AdministrationDashboard extends BaseMyDataPage {
public render() {
const {classes, tab, datasetPage, descriptorPage, pageSort, createDescriptorList} = this.props;
const {classes, tab, datasets, descriptors, descriptorLists, createDescriptorList} = this.props;
const paged = 'descriptors' === this.state.tab ? descriptorPage : datasetPage;
let paged = datasets;
switch (tab) {
case 'descriptorlists': paged = descriptorLists; break;
case 'descriptors': paged = descriptors; break;
case 'datasets':
default: break;
}
return (
<div>
<ContentHeaderWithButton title="What do you want to do?"/>
<div className={ classes.content }>
<Grid container spacing={ 0 }>
<Grid item xs={ 6 } lg={ 4 }>
<Grid item xs={ 6 } lg={ 3 }>
<DashboardButton title="CREATE DATASET" onClickFunction={ this.goToNewDataset }/>
</Grid>
<Grid item xs={ 6 } lg={ 4 }>
<Grid item xs={ 6 } lg={ 3 }>
<DashboardButton title="CREATE DESCRIPTOR" onClickFunction={ this.goToNewDescriptorForm }/>
</Grid>
<Grid item xs={ 6 } lg={ 4 }>
<Grid item xs={ 6 } lg={ 3 }>
<DashboardButton title="CREATE DESCRIPTOR LIST" onClickFunction={ createDescriptorList }/>
</Grid>
<Grid item xs={ 6 } lg={ 4 }>
<Grid item xs={ 6 } lg={ 3 }>
<DashboardButton title="MANAGE PARTNERS" onClickFunction={ this.goToPartners }/>
</Grid>
</Grid>
......@@ -113,9 +105,7 @@ class AdministrationDashboard extends BaseMyDataPage {
</div>
<MyDataTable tab={ tab } basePath="/dashboard"
paged={ paged }
onPaginationChange={ this.onPaginationChange }
pageSort={ pageSort } />
paged={ paged } onPaginationChange={ this.onPaginationChange } />
</div>
);
}
......@@ -128,14 +118,16 @@ const mapStateToProps = (state, ownProps) => ({
pageSize: +ownProps.location.query.l || 20, // page size
pageSort: ownProps.location.query.s, // page sort
pageDir: ownProps.location.query.d, // page sort direction
datasetPage: state.pagination.datasetPage,
descriptorPage: state.pagination.descriptorPage,
datasets: state.pagination.datasetPage,
descriptors: state.pagination.descriptorPage,
descriptorLists: state.descriptorList.paged,
});
const mapDispatchToProps = (dispatch) => ({
listDatasets: (page?: number, results?: number, sortBy?: string, filter?: IDatasetFilter, order?: string): void => dispatch(listMyDatasets(page, results, sortBy, filter, order)),
listDescriptors: (page?: number, results?: number, sortBy?: string, filter?: IDescriptorFilter, order?: string): void => dispatch(listMyDescriptors(page, results, sortBy, filter, order)),
createDescriptorList: (): void => dispatch(createDescriptorList()),
});
const mapDispatchToProps = (dispatch) => bindActionCreators({
listDatasets: listMyDatasets,
listDescriptors: listMyDescriptors,
listDescriptorLists: listMyDescriptorLists,
createDescriptorList,
}, dispatch);
export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(AdministrationDashboard));
import * as React from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import * as update from 'immutability-helper';
import * as moment from 'moment';
import {Dataset} from 'model/dataset.model';
import {Descriptor} from 'model/descriptors.model';
import {Descriptor, DescriptorList} from 'model/descriptors.model';
import {Page} from 'model/common.model';
import {IDatasetFilter, IDescriptorFilter} from 'model/filter.model';
import {listMyDatasets} from 'actions/dataset';
import {listMyDescriptors} from 'actions/descriptors';
import {listMyDescriptorLists} from 'actions/descriptorList';
import ContentHeaderWithButton from 'ui/common/heading/ContentHeaderWithButton';
import MyDataTable from './c/MyDataTable';
......@@ -20,8 +22,9 @@ interface IDataPublishedContainerProps extends React.ClassAttributes<any> {
pageCurrent: number;
pageSize: number;
pageSort?: string;
datasetPage: Page<Dataset>;
descriptorPage: Page<Descriptor>;
datasets: Page<Dataset>;
descriptors: Page<Descriptor>;
descriptorLists: Page<DescriptorList>;
preFilter?: object;
}
......@@ -32,11 +35,10 @@ class BaseMyDataPage extends React.Component<any, any> {
({ params: { tab }, route: { filter }, location: { query: { p: pageCurrent, l: pageSize, s: pageSort, d: pageDir } } } ) => {
// console.log('Needs route, params, location', route, params, location);
switch (tab) {
case 'descriptors':
return listMyDescriptors(pageCurrent, pageSize, pageSort, filter, pageDir);
case 'descriptors': return listMyDescriptors(pageCurrent, pageSize, pageSort, filter, pageDir);
case 'descriptorlists': return listMyDescriptorLists(pageCurrent, pageSize, pageSort, filter, pageDir);
case 'datasets':
default:
return listMyDatasets(pageCurrent, pageSize, pageSort, filter, pageDir);
default: return listMyDatasets(pageCurrent, pageSize, pageSort, filter, pageDir);
}
},
];
......@@ -91,7 +93,7 @@ class BaseMyDataPage extends React.Component<any, any> {
}
protected loadData(tab, page, size, sortBy, dir) {
const {listDatasets, listDescriptors, preFilter} = this.props;
const {listDatasets, listDescriptors, listDescriptorLists, preFilter} = this.props;
const filters = preFilter;
......@@ -107,11 +109,10 @@ class BaseMyDataPage extends React.Component<any, any> {
}));
switch (tab) {
case 'descriptors': listDescriptors(page, size, sortBy, filters, dir); break;
case 'descriptorlists': listDescriptorLists(page, size, sortBy, filters, dir); break;
case 'datasets':
listDatasets(page, size, sortBy, filters, dir); break;
case 'descriptors':
listDescriptors(page, size, sortBy, filters, dir); break;
default:
default: listDatasets(page, size, sortBy, filters, dir); break;
}
} else {
/*console.log('Not reloading data');*/
......@@ -126,9 +127,16 @@ class DP extends BaseMyDataPage {
}
public render() {
const {title, tab, basePath, datasetPage, descriptorPage, pageSort} = this.props;
const {title, tab, basePath, datasets, descriptors, descriptorLists} = this.props;
const paged = 'descriptors' === this.state.tab ? descriptorPage : datasetPage;
let paged = datasets;
switch (tab) {
case 'descriptorlists': paged = descriptorLists; break;
case 'descriptors': paged = descriptors; break;
case 'datasets':
default: break;
}
return (
<div>
......@@ -137,9 +145,7 @@ class DP extends BaseMyDataPage {
buttonUrl="/dashboard" />
<MyDataTable tab={ tab } basePath={ basePath }
paged={ paged }
onPaginationChange={ this.onPaginationChange }
pageSort={ pageSort } />
paged={ paged } onPaginationChange={ this.onPaginationChange } />
</div>
);
}
......@@ -154,14 +160,16 @@ const mapStateToProps = (state, ownProps) => ({
pageSize: +ownProps.location.query.l || 20, // page size
pageSort: ownProps.location.query.s, // page sort
pageDir: ownProps.location.query.d, // page sort direction
datasetPage: state.pagination.datasetPage,
descriptorPage: state.pagination.descriptorPage,
datasets: state.pagination.datasetPage,
descriptors: state.pagination.descriptorPage,
descriptorLists: state.descriptorList.paged,
});
const mapDispatchToProps = (dispatch) => ({
listDatasets: (page?: number, results?: number, sortBy?: string, filter?: IDatasetFilter, order?: string): void => dispatch(listMyDatasets(page, results, sortBy, filter, order)),
listDescriptors: (page?: number, results?: number, sortBy?: string, filter?: IDescriptorFilter, order?: string): void => dispatch(listMyDescriptors(page, results, sortBy, filter, order)),
});
const mapDispatchToProps = (dispatch) => bindActionCreators({
listDatasets: listMyDatasets,
listDescriptors: listMyDescriptors,
listDescriptorLists: listMyDescriptorLists,
}, dispatch);
const MyDataPage = connect(
mapStateToProps, mapDispatchToProps,
......
......@@ -9,7 +9,7 @@ import Tabs, {Tab} from 'ui/common/Tabs';
import {Table, TableRow, TableCell} from 'ui/common/tables';
import PaginationComponent from 'ui/common/pagination';
import {ContentContainer} from 'ui/layout/Container';
import {DatasetLink, DescriptorLink} from 'ui/common/Links';
import {DatasetLink, DescriptorLink, DescriptorListLink} from 'ui/common/Links';
import Paper from 'material-ui/Paper';
import Button from 'material-ui/Button';
......@@ -36,22 +36,36 @@ const descriptorSortOptions = {
...defaultSortOptions,
};
const descriptorListSortOptions = {
...defaultSortOptions,
};
export default function MyDataTable({
tab,
basePath,
paged,
onPaginationChange,
pageSort = '',
}: IDatasetLinkProps) {
const sortOptions = 'descriptors' === tab ? descriptorSortOptions : datasetSortOptions;
let sortOptions = defaultSortOptions;
switch (tab) {
case 'datasets': sortOptions = datasetSortOptions; break;
case 'descriptors': sortOptions = descriptorSortOptions; break;
case 'descriptorlists': sortOptions = descriptorListSortOptions; break;
default: break;
}
const ResolveLink = ({row, children}) => {
if (tab === 'datasets') {
return <DatasetLink dataset={ row } edit={ ! row.published && row._permissions.write }>{ children }</DatasetLink>;
}
if (tab === 'descriptors') {
return <DescriptorLink descriptor={ row } edit={ ! row.published && row._permissions.write }>{ children }</DescriptorLink>;
switch (tab) {
case 'datasets':
return <DatasetLink dataset={ row } edit={ ! row.published && row._permissions.write }>{ children }</DatasetLink>;
case 'descriptors':
return <DescriptorLink descriptor={ row } edit={ ! row.published && row._permissions.write }>{ children }</DescriptorLink>;
case 'descriptorlists':
return <DescriptorListLink to={ row } edit={ ! row.published && row._permissions.write }>{ children }</DescriptorListLink>;
default:
return (<span>{ children }</span>);
}
};
......@@ -60,9 +74,10 @@ export default function MyDataTable({
<Tabs tab={ tab }>
<Tab name="datasets" to={ basePath }>Datasets</Tab>
<Tab name="descriptors" to={ `${basePath}/descriptors` }>Descriptors</Tab>
<Tab name="descriptorlists" to={ `${basePath}/descriptorlists` }>Descriptor lists</Tab>
</Tabs>
<PaginationComponent displayName="records" pageObj={ paged } onChange={ onPaginationChange } sortOptions={ sortOptions } sortBy={ pageSort } />
<PaginationComponent displayName="records" pageObj={ paged } onChange={ onPaginationChange } sortOptions={ sortOptions } />
<ContentContainer>
<Paper>
......@@ -95,7 +110,7 @@ export default function MyDataTable({
</Paper>
</ContentContainer>
<PaginationComponent displayName="records" pageObj={ paged } onChange={ onPaginationChange } sortOptions={ sortOptions } sortBy={ pageSort } />
<PaginationComponent displayName="records" pageObj={ paged } onChange={ onPaginationChange } sortOptions={ sortOptions } />
</div>
);
}
Markdown is supported
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