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

Accession browser and basic display page

- includes updates to existing functions
- Implemented NumberFilter
- PagedLoader more sensitive to page size
parent bde3a43e
......@@ -25,6 +25,8 @@ const optionsBase = {
return value.toUpperCase();
} else if (format === 'lowercase') {
return value.toLowerCase();
} else if (format === 'number') {
return value && value.toLocaleString();
}
return value;
},
......
......@@ -20,6 +20,6 @@
"confirmDelete": "Deleting the {{what, lowercase}} record is only possible when there is no associated data."
},
"paginate": {
"numberOfItems": "{{count}} {{what, lowercase}}"
"numberOfItems": "{{count, number}} {{what, lowercase}}"
}
}
......@@ -19,7 +19,9 @@
"crop_plural": "Crops",
"metadata": "Record metadata",
"subset": "Subset",
"subset_plural": "Subsets"
"subset_plural": "Subsets",
"accession": "Accession",
"accession_plural": "Accessions"
},
"m": {
"crop": {
......@@ -101,11 +103,23 @@
"f": {
"accessions": {
"crops": "Crop name",
"institute": {
"acceNumb": "Accession number contains",
"seqNo": "Sequential number",
"geo": {
"latitude": "Latitude",
"longitude": "Longitude",
"elevation": "Elevation"
},
"holder": {
"code" : "Institute code"
},
"orgCty": {
"iso3": "ORIGCTY"
"taxa": {
"genus": "Genus",
"species": "Species",
"subtaxa": "Subtaxa"
},
"origin": {
"iso3": "Origin"
},
"taxonomy": {
"genus": "Genus",
......
/**
* This is a top-level group for actions in /accessions/* routes.
*/
import navigateTo from 'actions/navigation';
import FilteredPage, { IPageRequest } from 'model/FilteredPage';
import Accession from 'model/Accession';
import AccessionFilter from 'model/AccessionFilter';
import { list as listAccessions, getByUuid } from 'actions/genesys/accessionService';
import { RECEIVE_ACCESSIONS, RECEIVE_ACCESSION } from 'constants/accessions';
const receiveAccessions = (paged: FilteredPage<Accession>, error = null) => ({
type: RECEIVE_ACCESSIONS,
payload: { paged, error },
});
const receiveAccession = (accession: Accession, error = null) => ({
type: RECEIVE_ACCESSION,
payload: { accession, error },
});
export { listAccessions as listAccessionsPromise };
export const updateRoute = (paged: FilteredPage<Accession>) => (dispatch) => {
const qs = {
s: paged.sort[0].property === Accession.DEFAULT_SORT.property ? undefined : paged.sort[0].property,
d: paged.sort[0].direction === Accession.DEFAULT_SORT.direction ? undefined : paged.sort[0].direction,
};
dispatch(navigateTo(paged.filterCode ? `/a/${paged.filterCode}` : '/a', qs));
};
export const applyFilters = (filters: string | AccessionFilter, page: IPageRequest = { page: 0 }) => (dispatch) => {
console.log('Applying new filter', filters);
return dispatch(listAccessions(filters, page))
.then((paged) => {
dispatch(receiveAccessions(paged));
dispatch(updateRoute(paged));
}).catch((error) => {
console.log(`API response ${error.response.status}`, error.response);
dispatch(receiveAccessions(null, error.response));
});
};
export const loadAccessionsPage = (page: IPageRequest) => (dispatch, getState) => {
const filterCode = getState().accessions.paged.filterCode;
return dispatch(listAccessions(filterCode, page))
.then((paged) => {
dispatch(receiveAccessions(paged));
dispatch(updateRoute(paged));
}).catch((error: { response }) => {
console.log(`API response ${error.response.status}`, error.response);
dispatch(receiveAccessions(null, error.response));
});
};
export const loadAccession = (uuid: string) => (dispatch) => {
return dispatch(getByUuid(uuid))
.then((accession) => {
dispatch(receiveAccession(accession));
}).catch((error) => {
console.log(`API response ${error.response.status}`, error.response);
dispatch(receiveAccession(null, error.response));
});
};
import AccessionService from 'service/genesys/AccessionService';
import Accession from 'model/Accession';
import AccessionFilter from 'model/AccessionFilter';
import FilteredPage, { IPageRequest } from 'model/FilteredPage';
/**
* Action getByDoi
*
*/
export const getByDoi = (doi: string) => (dispatch, getState): Promise<Accession> => {
const authorization = getState().login.access_token;
return AccessionService.getByDoi(authorization, doi);
};
/**
* Action getByUuid
*
* @param UUID UUID
*/
export const getByUuid = (UUID: string) => (dispatch, getState): Promise<Accession> => {
const authorization = getState().login.access_token;
return AccessionService.getByUuid(authorization, UUID);
};
/**
* Action list
*
* @param filter filter
* @param d d
* @param f f
* @param l l
* @param p p
* @param s s
*/
export const list = (filter: string | AccessionFilter, page: IPageRequest) => (dispatch, getState): Promise<FilteredPage<Accession>> => {
const authorization = getState().login.access_token;
return AccessionService.list(authorization, filter, page);
};
export const RECEIVE_ACCESSIONS = 'accessions/RECEIVE_ACCESSIONS';
export const RECEIVE_ACCESSION = 'accessions/RECEIVE_ACCESSION';
export const ACCESSION_FILTERFORM = 'Form/Accession/ACCESSION_FILTERFORM';
export const ACCESSION_FORM = 'Form/Accession/ACCESSION_FORM';
import AccessionAlias from 'model/AccessionAlias';
import AccessionCollect from 'model/AccessionCollect';
import AccessionGeo from 'model/AccessionGeo';
import AccessionRemark from 'model/AccessionRemark';
import Country from 'model/Country';
import Crop from 'model/Crop';
import FaoInstitute from 'model/FaoInstitute';
import PDCI from 'model/PDCI';
import Taxonomy2 from 'model/Taxonomy2';
/*
* Defined in Swagger as '#/definitions/Accession'
*/
class Accession {
public accNames: string;
public acceUrl: string;
public accessionNumber: string;
public acquisitionDate: string;
public acquisitionSource: string;
public active: boolean;
public aliases: AccessionAlias[];
public ancest: string;
public breederCode: string[];
public breederName: string[];
public coll: AccessionCollect;
public countryOfOrigin: Country;
public createdBy: number;
public createdDate: Date;
public crop: Crop;
public cropName: string;
public doi: string;
public donorCode: string;
public donorName: string;
public donorNumb: string;
public duplSite: string[];
public duplSiteStr: string;
public geo: AccessionGeo;
public id: number;
public inSvalbard: boolean;
public inTrust: boolean;
public institute: FaoInstitute;
public instituteCode: string;
public lastModifiedBy: number;
public lastModifiedDate: Date;
public mlsStatus: boolean;
public origCty: string;
public otherIds: string;
public pdci: PDCI;
public remarks: AccessionRemark[];
public sampStat: number;
public seqNo: number;
public storage: number[];
public storageStr: string;
public taxonomy: Taxonomy2;
public uuid: string;
public version: number;
public static DEFAULT_SORT = {
property: 'seqNo',
direction: 'ASC',
};
public static SORT_OPTIONS = {
seqNo: { label: 'Accession number', dir: 'ASC' },
};
}
export default Accession;
/*
* Defined in Swagger as '#/definitions/AccessionAlias'
*/
class AccessionAlias {
public aliasType: string;
public empty: boolean;
public id: number;
public lang: string;
public name: string;
public usedBy: string;
public version: number;
}
export default AccessionAlias;
/*
* Defined in Swagger as '#/definitions/AccessionCollect'
*/
class AccessionCollect {
public collCode: string[];
public collDate: string;
public collInstAddress: string[];
public collMissId: string;
public collName: string[];
public collNumb: string;
public collSite: string;
public collSrc: number;
public empty: boolean;
public id: number;
public version: number;
}
export default AccessionCollect;
import CountryFilter from 'model/CountryFilter';
import DateFilter from 'model/DateFilter';
import InstituteFilter from 'model/InstituteFilter';
import NumberFilter from 'model/NumberFilter';
import StringFilter from 'model/StringFilter';
import TaxonomyFilter from 'model/TaxonomyFilter';
/*
* Defined in Swagger as '#/definitions/AccessionFilter'
*/
class AccessionFilter {
public acceNumb: StringFilter;
public active: boolean;
public available: boolean;
public createdBy: number[];
public createdDate: DateFilter;
public crop: string;
public cropName: string;
public doi: string[];
public elevation: NumberFilter;
public historic: boolean;
public holder: InstituteFilter;
public id: number[];
public lastModifiedBy: number[];
public lastModifiedDate: DateFilter;
public latitude: NumberFilter;
public longitude: NumberFilter;
public mlsStatus: boolean;
public origin: CountryFilter;
public sampStat: number[];
public seqNo: NumberFilter;
public taxa: TaxonomyFilter;
public uuid: string[];
public version: number[];
}
export default AccessionFilter;
/*
* Defined in Swagger as '#/definitions/AccessionGeo'
*/
class AccessionGeo {
public datum: string;
public elevation: number;
public empty: boolean;
public id: number;
public latitude: number;
public longitude: number;
public method: string;
public tileIndex: number;
public uncertainty: number;
public version: number;
}
export default AccessionGeo;
/*
* Defined in Swagger as '#/definitions/AccessionRemark'
*/
class AccessionRemark {
public empty: boolean;
public fieldName: string;
public id: number;
public remark: string;
public version: number;
}
export default AccessionRemark;
/*
* Defined in Swagger as '#/definitions/Country'
*/
class Country {
public iso2: string;
public iso3: string;
public name: string;
}
export default Country;
/*
* Defined in Swagger as '#/definitions/CountryFilter'
*/
class CountryFilter {
public iso3: string[];
}
export default CountryFilter;
/*
* Defined in Swagger as '#/definitions/Crop'
*/
class Crop {
public active: boolean;
public createdBy: number;
public createdDate: Date;
public description: string;
public i18n: string;
public id: number;
public lastModifiedBy: number;
public lastModifiedDate: Date;
public name: string;
public otherNames: string[];
public rdfUri: string;
public shortName: string;
public version: number;
}
export default Crop;
import Country from 'model/Country';
/*
* Defined in Swagger as '#/definitions/FaoInstitute'
*/
class FaoInstitute {
public accessionCount: number;
public acronym: string;
public allowMaterialRequests: boolean;
public code: string;
public codeSGSV: string;
public current: boolean;
public elevation: number;
public email: string;
public fullName: string;
public id: number;
public latitude: number;
public longitude: number;
public maintainsCollection: boolean;
public pgrActivity: boolean;
public safeUrls: string[];
public type: string;
public uniqueAcceNumbs: boolean;
public url: string;
public urls: string[];
public vCode: string;
public country: Country;
}
export default FaoInstitute;
import CountryFilter from 'model/CountryFilter';
import StringFilter from 'model/StringFilter';
/*
* Defined in Swagger as '#/definitions/InstituteFilter'
*/
class InstituteFilter {
public code: string[];
public country: CountryFilter;
public name: StringFilter;
}
export default InstituteFilter;
/*
* Defined in Swagger as '#/definitions/NumberFilter«double»'
*/
class NumberFilter {
public between: number[];
public eq: number;
public ge: number;
public gt: number;
public le: number;
public lt: number;
}
export default NumberFilter;
/*
* Defined in Swagger as '#/definitions/PDCI'
*/
class PDCI {
public acceName: number;
public acceUrl: number;
public acqDate: number;
public active: boolean;
public ancest: number;
public bredCode: number;
public collCode: number;
public collDate: number;
public collName: number;
public collNumb: number;
public collSite: number;
public collSrc: number;
public cropName: number;
public dependentItems: string[];
public donorCode: number;
public donorName: number;
public donorNumb: number;
public duplInstName: number;
public duplSite: number;
public elevation: number;
public genus: number;
public id: number;
public independentItems: string[];
public latitude: number;
public longitude: number;
public mlsStat: number;
public origCty: number;
public otherNumb: number;
public sampStat: number;
public score: number;
public scoreHist: number;
public spAuthor: number;
public species: number;
public storage: number;
public subTaxa: number;
public subtAuthor: number;
public version: number;
}
export default PDCI;
/*
* Defined in Swagger as '#/definitions/Taxonomy2'
*/
class Taxonomy2 {
public active: boolean;
public createdBy: number;
public createdDate: Date;
public genus: string;
public id: number;
public lastModifiedBy: number;
public lastModifiedDate: Date;
public rdfUri: string;
public spAuthor: string;
public species: string;
public subtAuthor: string;
public subtaxa: string;
public taxGenus: number;
public taxSpecies: number;
public taxonName: string;
public version: number;
public taxonNameHtml: string;
}
export default Taxonomy2;
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