Commit b1992b4a authored by Oleksii Savran's avatar Oleksii Savran

Added Table for accessions

parent bacd8325
This diff is collapsed.
import * as React from 'react';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux'
// import Accession from 'model/accession/Accession';
import Country from 'model/geo/Country';
import DOI from 'ui/common/DOI';
export const CountryOfOrigin = ({country}: {country: Country}): JSX.Element => {
const translatedCountry = useSelector((state) => {
return state.decoder.countryCodes && state.decoder.countryCodes.data
? state.decoder.countryCodes.data[country.code3]
: null;
});
return <span>{ translatedCountry ? translatedCountry : country.name }</span>;
};
export const SampStatus = ({status}: {status: string}): JSX.Element => {
const { t } = useTranslation();
return <span>{ t(`accessions.common.sampleStatus.${status}`) }</span>;
};
export const DoiRender = ({doi}: {doi: string}): JSX.Element => {
const { t } = useTranslation();
return doi && <DOI noPrefix value={ doi } /> || t('common:label.notApplicable');
};
......@@ -68,7 +68,7 @@ export const addAccessionToMyList = (accession: Accession) => (dispatch, getStat
}
};
const addAccnsToMyList = (accessions: Accession[]) => (dispatch) => {
export const addAccnsToMyList = (accessions: Accession[]) => (dispatch) => {
const uuidsToAdd = accessions.reduce((arr, a) => [ ...arr, a.uuid], []);
dispatch(addAccessionUuids(ApiCall.success(uuidsToAdd)));
dispatch(addLoadedAccessions(accessions));
......
......@@ -27,6 +27,16 @@ const styles = (theme) => ({
minHeight: 'calc(100vh - 3.5rem)',
},
},
contentWithTable: {
height: 'calc(100vh - 80px)',
// maxHeight: 'calc(100vh - 80px)',
flexGrow: 0,
flexShrink: 2,
overflow: 'hidden' as 'hidden',
[theme.breakpoints.down('md')]: {
height: 'calc(100vh - 3.5rem)',
},
},
contentWithClosedSidebar: {
maxWidth: 'calc(100% - 25px)',
},
......@@ -34,6 +44,10 @@ const styles = (theme) => ({
flex: '1',
width: '100%',
},
tableLayoutChildren: {
height: '100%',
flexBasis: 'initial' as 'initial',
},
footer: {
marginTop: '2em',
flexGrow: 'initial' as 'initial',
......@@ -64,25 +78,32 @@ const styles = (theme) => ({
});
interface ILayoutProps extends React.ClassAttributes<any>, WithStyles {
children?: any;
sidebar?: any;
withFooter?: any;
children?: React.ReactNode;
sidebar?: React.ReactNode;
withFooter?: boolean;
withTable?: boolean;
}
function Layout({classes, children = null, sidebar = null, withFooter = false}: ILayoutProps) {
function Layout({classes, children = null, sidebar = null, withFooter = false, withTable = false}: ILayoutProps) {
const sidebarIsOpen = useSelector((state) => state.user.public.sidebarOpen) || false;
return (
<div>
<div className={ classes.root }>
{ sidebar && <SidebarWrapper sidebarContent={ sidebar }/> }
{ children && (
<div className={ `${classes.content} ${sidebar && !sidebarIsOpen ? classes.contentWithClosedSidebar : ''}` }>
<div className={ classes.children }>
<div className={ `
${classes.content}
${sidebar && !sidebarIsOpen ? classes.contentWithClosedSidebar : ''}
${withTable ? classes.contentWithTable : ''}
` }>
<div className={ `${classes.children} ${withTable ? classes.tableLayoutChildren : ''}` }>
{ children }
</div>
<div className={ classes.footer }>
{ withFooter && <Footer /> }
</div>
{ withFooter &&
<div className={ classes.footer }>
<Footer />
</div>
}
</div>
) }
</div>
......
......@@ -81,7 +81,15 @@ class BrowsePage<T> extends React.Component<IBrowsePageProps<T> & any, any> {
} else {
return applyFilters(filters, { page: 0 });
}
}
};
protected loadMore = () => {
const { apiCall, loadMoreData } = this.props;
if (apiCall && apiCall.data && ! apiCall.data.last) {
console.log('Calling for next page', apiCall.data.number + 1);
loadMoreData(apiCall.data);
}
};
}
......
......@@ -70,7 +70,7 @@ class BrowsePage extends BrowsePageTemplate<User> {
};
public render() {
const { apiCall, loadMoreData, width, t } = this.props;
const { apiCall, width, t } = this.props;
const {data: paged, error } = apiCall || {data: undefined, loading: true, error: undefined};
// const renderUser = (user: User, index: number) => {
......@@ -109,7 +109,7 @@ class BrowsePage extends BrowsePageTemplate<User> {
data={ paged ? paged.content : null }
tableConfig={ UserTableConfig }
total={ paged && paged.content ? paged.totalElements : null }
loadMore={ loadMoreData }
loadMore={ this.loadMore }
onRowToggled={ this.rowToggled }
onColumnToggled={ this.columnToggled }
sort={ paged ? paged.sort : null }
......
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