Commit 78758833 authored by Matija Obreza's avatar Matija Obreza
Browse files

Removed unused files

parent ee2a6e8b
import { AccessionService } from 'service/AccessionService';
import { log } from 'utilities/debug';
export const listAccessions = (filters: object, page: number = 0, results: number = 50) => (dispatch, getState) => {
const token = getState().login.access_token;
return AccessionService.listAccessions(token, filters, page, results)
.then((data) => {
return data;
}).catch((error) => {
log(`Genesys error`, error);
});
};
export const ACCESSIONS_FILTERFORM = 'Form/Accession/BROWSE';
export default {
pigeonpea: 'Pigeonpea',
sorghum: 'Sorghum',
forages: 'Forages',
pearlmillet: 'Pearl millet',
tomato: 'Tomato',
apple: 'Apple',
potato: 'Potato',
beans: 'Beans',
cassava: 'Cassava',
wheat: 'Wheat',
taro: 'Taro',
eggplant: 'Eggplant',
fababean: 'Faba bean',
banana: 'Banana',
cowpea: 'Cowpea',
yam: 'Yam',
grasspea: 'Grass pea',
barley: 'Barley',
lentil: 'Lentil',
rice: 'Rice',
lettuce: 'Lettuce',
maize: 'Maize',
sweetpotato: 'Sweet potato',
chickpea: 'Chickpea',
sunflower: 'Sunflower',
coconut: 'Coconut',
fingermillet: 'Finger millet',
coffee: 'Coffee',
breadfruit: 'Breadfruit',
};
export default [
{
code: 'ALB026',
name: 'Plant Genetic Resources Center',
},
{
code: 'ARM005',
name: 'Institute of Botany',
},
{
code: 'ARM006',
name: 'Scientific Center of Agriculture',
},
{
code: 'ARM008',
name: 'Scientific Center of Vegetables and Industrial Crops',
},
{
code: 'ARM035',
name: 'Laboratory of Plants Gene Pool and Breeding',
},
{
code: 'ARM059',
name: 'Scientific Center of Agrobiotechnology',
},
];
export default [1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017];
import authenticatedRequest from 'utilities/requestUtils';
import * as _ from 'lodash';
import {API_BASE_URL} from 'constants/apiURLS';
import Page from 'model/Page';
export class AccessionService {
public static listAccessions(token: string, filters: object, page: number = 0, results: number = 50): Promise<Page<object>> {
const flatFilters = genesysFlatten('', renameFilters(filters), {});
return authenticatedRequest(token, {
url: `${API_BASE_URL}/acn/filter?p=${page}&l=${results}`,
method: 'POST',
data: {
...flatFilters,
},
}).then(({ data }) => data as Page<object>);
}
}
const renameFilters = (filters: any) => {
const renamed: any = { ...filters };
renamed.crops = renamed.crop;
delete renamed.crop;
return renamed;
};
/**
* Genesys PGR uses a semi-flat JSON structure, with arrays and literals as values:
* { institute: { code: [ 'NGA039' ] } } --> { 'institute.code': [ 'NGA039' ] }
*/
const genesysFlatten = (prefix: string, obj: object, result: any) => {
for (const k of Object.keys(obj)) {
const val = obj[k];
// console.log(`${k} = ${val} typeof ${typeof val}`);
if (_.isObject(val)) {
if (_.isArray(val) && val.length > 0) {
result[`${prefix}${k}`] = val;
} else {
genesysFlatten(`${prefix}${k}.`, val, result);
}
} else if (val !== null) {
result[`${prefix}${k}`] = val;
}
}
return result;
};
import * as React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { withStyles } from '@material-ui/core/styles';
import Page from 'model/Page';
import PageLayout from 'ui/layout/PageLayout';
import ContentHeader from 'ui/common/heading/ContentHeader';
import AccessionsBrowseFilters from './c/Filters';
// import Loading from 'ui/common/Loading';
// import PaginationComponent from 'ui/common/pagination';
// import PrettyFilters from 'ui/common/filter/PrettyFilters';
// import DOI from 'ui/common/DOI';
// import { MultiGrid as VMultiGrid, AutoSizer, InfiniteLoader } from 'react-virtualized';
const styles = (theme) => ({
filterSection: theme.leftPanel.root,
BodyGrid: {
width: '100%',
border: '1px solid #e0e0e0',
},
tableCell: {
padding: '.5rem 1rem',
borderRight: 'dotted 1px White',
borderBottom: 'solid 1px White',
textOverflow: 'ellipsis' as 'ellipsis',
whiteSpace: 'nowrap' as 'nowrap',
display: 'inline-block' as 'inline-block',
overflow: 'hidden' as 'hidden',
},
tableHeaderCell: {
fontWeight: 'bold' as 'bold',
color: 'White',
borderRight: 'dotted 1px #a0d457',
},
evenRow: {
backgroundColor: '#f3f2ee',
},
oddRow: {
backgroundColor: '#f8f7f5',
},
noCells: {
position: 'absolute' as 'absolute',
top: 0,
bottom: 0,
left: 0,
right: 0,
display: 'flex' as 'flex',
alignItems: 'center' as 'center',
justifyContent: 'center' as 'center',
fontSize: '1em',
color: '#bdbdbd',
},
});
interface IBrowsePageProps extends React.ClassAttributes<any> {
classes: any;
router: any;
paged: Page<any>;
}
// const SORT_OPTIONS = null;
// Page to browse and filter descriptor lists
class BrowsePage extends React.Component<IBrowsePageProps, any> {
protected static needs = [
];
public constructor(props: any) {
super(props);
}
public render() {
const { paged } = this.state;
// const stillLoading: boolean = (! paged || ! paged.content);
return (
<PageLayout sidebar={ <AccessionsBrowseFilters initialValues={ paged.filter } /> }>
<ContentHeader title="Accession browser" subTitle="Explore Genesys PGR database" />
</PageLayout>
);
}
}
const mapStateToProps = (state, ownProps) => ({
});
const mapDispatchToProps = (dispatch) => bindActionCreators({
}, dispatch);
export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(BrowsePage));
import * as React from 'react';
import { reduxForm } from 'redux-form';
import FiltersBlock from 'ui/common/filter/FiltersBlock';
import CollapsibleComponentSearch from 'ui/common/filter/CollapsibleComponentSearch';
import StringArrFilter from 'ui/common/filter/StringArrFilter';
import {ACCESSIONS_FILTERFORM} from 'constants/accession';
const AccessionsBrowseFilters = ({handleSubmit, initialize, ...other}) => (
<FiltersBlock title="Accessions" handleSubmit={ handleSubmit } initialize={ initialize } { ...other }>
<CollapsibleComponentSearch title="Species">
<StringArrFilter name="crop" label="Crop name" placeholder="barley"/>
<StringArrFilter name="taxonomy.genus" label="Genus" placeholder="Hordeum"/>
<StringArrFilter name="taxonomy.species" label="Species" placeholder="vulgare"/>
<StringArrFilter name="taxonomy.subtaxa" label="Subtaxon" placeholder="..."/>
</CollapsibleComponentSearch>
<CollapsibleComponentSearch title="Holding institute">
<StringArrFilter name="institute.code" label="INSTCODE" placeholder="NGA039"/>
<StringArrFilter name="orgCty.iso3" label="ORIGCTY" placeholder="SVN"/>
</CollapsibleComponentSearch>
</FiltersBlock>
);
export default reduxForm({
enableReinitialize: true,
form: ACCESSIONS_FILTERFORM,
})(AccessionsBrowseFilters);
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