Commit a81960fa authored by Matija Obreza's avatar Matija Obreza

Merge branch 'ui-accessionref-performance' into 'master'

Ui accessionref updates

See merge request genesys-pgr/genesys-ui!159
parents a00a3920 33e2d49c
...@@ -105,7 +105,7 @@ export { rejectDataset, approveDataset, publishDataset, deleteDataset }; ...@@ -105,7 +105,7 @@ export { rejectDataset, approveDataset, publishDataset, deleteDataset };
// Accession identifiers step // Accession identifiers step
function clearAccessionRefList(dataset: Dataset) { function clearAccessionRefList(dataset: Dataset) {
return (dispatch, getState) => { return (dispatch, getState) => {
return DatasetService.upsertAccessions(dataset.uuid, dataset.version, []) return DatasetService.setAccessions(dataset.uuid, dataset.version, [])
.then((saved) => { .then((saved) => {
dispatch(receiveDataset(saved)); dispatch(receiveDataset(saved));
dispatch(loadMoreAccessions(saved.uuid)); dispatch(loadMoreAccessions(saved.uuid));
...@@ -115,10 +115,10 @@ function clearAccessionRefList(dataset: Dataset) { ...@@ -115,10 +115,10 @@ function clearAccessionRefList(dataset: Dataset) {
}; };
} }
function updateDatasetAccessionRefs(dataset: Dataset, accessionRefs: AccessionRef[]) { function addDatasetAccessionRefs(dataset: Dataset, accessionRefs: AccessionRef[]) {
return (dispatch, getState) => { return (dispatch, getState) => {
return DatasetService.upsertAccessions(dataset.uuid, dataset.version, accessionRefs) return DatasetService.addAccessions(dataset.uuid, dataset.version, accessionRefs)
.then((saved) => { .then((saved) => {
dispatch(receiveDataset(saved)); dispatch(receiveDataset(saved));
dispatch(loadMoreAccessions(saved.uuid)); dispatch(loadMoreAccessions(saved.uuid));
...@@ -143,7 +143,7 @@ function rematchDatasetAccessions(dataset: Dataset) { ...@@ -143,7 +143,7 @@ function rematchDatasetAccessions(dataset: Dataset) {
} }
// Accession identifiers step exports // Accession identifiers step exports
export { updateDatasetAccessionRefs, rematchDatasetAccessions, clearAccessionRefList }; export { addDatasetAccessionRefs as addDatasetAccessionRefs, rematchDatasetAccessions, clearAccessionRefList };
// Descriptors step // Descriptors step
......
...@@ -2,7 +2,7 @@ import * as React from 'react'; ...@@ -2,7 +2,7 @@ import * as React from 'react';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
// actions // actions
import { rematchDatasetAccessions, updateDatasetAccessionRefs, clearAccessionRefList } from 'datasets/actions/editor'; import { rematchDatasetAccessions, addDatasetAccessionRefs, clearAccessionRefList } from 'datasets/actions/editor';
import {loadMoreAccessions} from 'datasets/actions/dashboard'; import {loadMoreAccessions} from 'datasets/actions/dashboard';
// models // models
...@@ -19,7 +19,7 @@ import Loading from 'ui/common/Loading'; ...@@ -19,7 +19,7 @@ import Loading from 'ui/common/Loading';
interface IAccessionsListStep extends React.ClassAttributes<any> { interface IAccessionsListStep extends React.ClassAttributes<any> {
item: Dataset; item: Dataset;
accessionRefs: Page<AccessionRef>; accessionRefs: Page<AccessionRef>;
updateDatasetAccessionRefs: (dataset: Dataset, accessionRefs: AccessionRef[]) => Promise<Dataset>; addDatasetAccessionRefs: (dataset: Dataset, accessionRefs: AccessionRef[]) => Promise<Dataset>;
loadMore: (uuid: string, page?: Page<AccessionRef>) => any; loadMore: (uuid: string, page?: Page<AccessionRef>) => any;
stillLoading: boolean; stillLoading: boolean;
onDelete: () => void; onDelete: () => void;
...@@ -58,8 +58,8 @@ class AccessionsListStep extends StepperTemplate<IAccessionsListStep> { ...@@ -58,8 +58,8 @@ class AccessionsListStep extends StepperTemplate<IAccessionsListStep> {
} }
protected updateAccessionsRefs = (AccessionRefs: AccessionRef[]) => { protected updateAccessionsRefs = (AccessionRefs: AccessionRef[]) => {
const { item: dataset, updateDatasetAccessionRefs } = this.props; const { item: dataset, addDatasetAccessionRefs } = this.props;
return updateDatasetAccessionRefs(dataset, AccessionRefs); return addDatasetAccessionRefs(dataset, AccessionRefs);
} }
public componentWillMount() { public componentWillMount() {
...@@ -82,7 +82,7 @@ const mapStateToProps = (state, ownProps) => ({ ...@@ -82,7 +82,7 @@ const mapStateToProps = (state, ownProps) => ({
}); });
const mapDispatchToProps = (dispatch) => bindActionCreators({ const mapDispatchToProps = (dispatch) => bindActionCreators({
updateDatasetAccessionRefs, addDatasetAccessionRefs,
clearAccessionRefList, clearAccessionRefList,
rematchDatasetAccessions, rematchDatasetAccessions,
loadMore: loadMoreAccessions, loadMore: loadMoreAccessions,
......
...@@ -23,7 +23,8 @@ const URL_REJECT_DATASET = `/api/v1/dataset/reject`; ...@@ -23,7 +23,8 @@ const URL_REJECT_DATASET = `/api/v1/dataset/reject`;
const URL_REMOVE_DESCRIPTORS = UrlTemplate.parse(`/api/v1/dataset/remove-descriptors/{uuid},{version}`); const URL_REMOVE_DESCRIPTORS = UrlTemplate.parse(`/api/v1/dataset/remove-descriptors/{uuid},{version}`);
const URL_UPDATE_DESCRIPTORS = UrlTemplate.parse(`/api/v1/dataset/set-descriptors/{uuid},{version}`); const URL_UPDATE_DESCRIPTORS = UrlTemplate.parse(`/api/v1/dataset/set-descriptors/{uuid},{version}`);
const URL_UPDATE_DATASET = `/api/v1/dataset/update`; const URL_UPDATE_DATASET = `/api/v1/dataset/update`;
const URL_UPSERT_ACCESSIONS = UrlTemplate.parse(`/api/v1/dataset/upsertaccessions/{uuid},{version}`); const URL_ADD_ACCESSIONS = UrlTemplate.parse(`/api/v1/dataset/add-accessions/{uuid},{version}`);
const URL_SET_ACCESSIONS = UrlTemplate.parse(`/api/v1/dataset/set-accessions/{uuid},{version}`);
const URL_GET_DATASET = UrlTemplate.parse(`/api/v1/dataset/{uuid}`); const URL_GET_DATASET = UrlTemplate.parse(`/api/v1/dataset/{uuid}`);
const URL_DELETE_DATASET = UrlTemplate.parse(`/api/v1/dataset/{uuid},{version}`); const URL_DELETE_DATASET = UrlTemplate.parse(`/api/v1/dataset/{uuid},{version}`);
const URL_AUTOCOMPLETE = UrlTemplate.parse(`/api/v1/dataset/{uuid}/datasetcreator/autocomplete`); const URL_AUTOCOMPLETE = UrlTemplate.parse(`/api/v1/dataset/{uuid}/datasetcreator/autocomplete`);
...@@ -289,21 +290,43 @@ class DatasetService { ...@@ -289,21 +290,43 @@ class DatasetService {
} }
/** /**
* upsertAccessions at /api/v1/dataset/upsertaccessions/{uuid},{version} * addAccessions at /api/v1/dataset/add-accessions/{uuid},{version}
* *
* @param uuid uuid * @param uuid uuid
* @param version version * @param version version
* @param accessionRefs accessionRefs * @param accessionRefs accessionRefs
*/ */
public static upsertAccessions(uuid: string, version: number, accessionRefs: AccessionRef[]): Promise<Dataset> { public static addAccessions(uuid: string, version: number, accessionRefs: AccessionRef[]): Promise<Dataset> {
const apiUrl = URL_UPSERT_ACCESSIONS.expand({ uuid, version }); const apiUrl = URL_ADD_ACCESSIONS.expand({ uuid, version });
// console.log(`Fetching from ${apiUrl}`); // console.log(`Fetching from ${apiUrl}`);
const content = { data: accessionRefs }; const content = { data: accessionRefs };
return axiosBackend.request({ return axiosBackend.request({
url: apiUrl, url: apiUrl,
method: 'POST', method: 'POST',
timeout: 0, // don't timeout
...content,
}).then(({ data }) => data as Dataset);
}
/**
* setAccessions at /api/v1/dataset/add-accessions/{uuid},{version}
*
* @param uuid uuid
* @param version version
* @param accessionRefs accessionRefs
*/
public static setAccessions(uuid: string, version: number, accessionRefs: AccessionRef[]): Promise<Dataset> {
const apiUrl = URL_SET_ACCESSIONS.expand({ uuid, version });
// console.log(`Fetching from ${apiUrl}`);
const content = { data: accessionRefs };
return axiosBackend.request({
url: apiUrl,
method: 'POST',
timeout: 0, // don't timeout
...content, ...content,
}).then(({ data }) => data as Dataset); }).then(({ data }) => data as Dataset);
} }
......
...@@ -12,6 +12,8 @@ import {AccessionRef} from 'model/accession/AccessionRef'; ...@@ -12,6 +12,8 @@ import {AccessionRef} from 'model/accession/AccessionRef';
const URL_LIST_ACCESSIONS = UrlTemplate.parse(`/api/v1/subset/accessions/{uuid}`); const URL_LIST_ACCESSIONS = UrlTemplate.parse(`/api/v1/subset/accessions/{uuid}`);
const URL_ADD_ACCESSIONS = UrlTemplate.parse(`/api/v1/subset/add-accessions/{uuid},{version}`); const URL_ADD_ACCESSIONS = UrlTemplate.parse(`/api/v1/subset/add-accessions/{uuid},{version}`);
const URL_SET_ACCESSIONS = UrlTemplate.parse(`/api/v1/subset/set-accessions/{uuid},{version}`);
const URL_REMATCH_ACCESSIONS = UrlTemplate.parse(`/api/v1/subset/rematch-accessions/{uuid},{version}`);
const URL_APPROVE_SUBSET = `/api/v1/subset/approve`; const URL_APPROVE_SUBSET = `/api/v1/subset/approve`;
const URL_CREATE = `/api/v1/subset/create`; const URL_CREATE = `/api/v1/subset/create`;
const URL_REVIEW_SUBSET = `/api/v1/subset/for-review`; const URL_REVIEW_SUBSET = `/api/v1/subset/for-review`;
...@@ -66,11 +68,53 @@ class SubsetService { ...@@ -66,11 +68,53 @@ class SubsetService {
* @param version version * @param version version
* @param accessionIds accessionIds * @param accessionIds accessionIds
*/ */
public static addAccessions(uuid: string, version: number, accessionIds: string[]): Promise<Subset> { public static addAccessions(uuid: string, version: number, accessionRefs: AccessionRef[]): Promise<Subset> {
const apiUrl = URL_ADD_ACCESSIONS.expand({uuid, version}); const apiUrl = URL_ADD_ACCESSIONS.expand({uuid, version});
// console.log(`Fetching from ${apiUrl}`); // console.log(`Fetching from ${apiUrl}`);
const content = { data: accessionIds }; const content = { data: accessionRefs };
return axiosBackend.request({
url: apiUrl,
method: 'POST',
timeout: 0, // don't timeout
...content,
}).then(({ data }) => data as Subset);
}
/**
* setAccessions at /api/v1/subset/set-accessions/{uuid},{version}
*
* @param uuid UUID
* @param version version
* @param accessionIds accessionIds
*/
public static setAccessions(uuid: string, version: number, accessionRefs: AccessionRef[]): Promise<Subset> {
const apiUrl = URL_SET_ACCESSIONS.expand({uuid, version});
// console.log(`Fetching from ${apiUrl}`);
const content = { data: accessionRefs };
return axiosBackend.request({
url: apiUrl,
method: 'POST',
timeout: 0, // don't timeout
...content,
}).then(({ data }) => data as Subset);
}
/**
* rematchAccessions at /api/v1/subset/rematch-accessions/{uuid},{version}
*
* @param uuid UUID
* @param version version
* @param accessionIds accessionIds
*/
public static rematchAccessions(uuid: string, version: number): Promise<Subset> {
const apiUrl = URL_REMATCH_ACCESSIONS.expand({uuid, version});
// console.log(`Fetching from ${apiUrl}`);
const content = { };
return axiosBackend.request({ return axiosBackend.request({
url: apiUrl, url: apiUrl,
......
...@@ -12,24 +12,47 @@ import { AccessionRef } from 'model/accession/AccessionRef'; ...@@ -12,24 +12,47 @@ import { AccessionRef } from 'model/accession/AccessionRef';
// Service // Service
import SubsetService from 'service/genesys/SubsetService'; import SubsetService from 'service/genesys/SubsetService';
import AccessionService from 'service/genesys/AccessionService';
// UI // UI
import steps from 'subsets/ui/dashboard/subset-stepper/steps'; import steps from 'subsets/ui/dashboard/subset-stepper/steps';
// Accession Identifiers step // Accession Identifiers step
export const updateSubsetAccessionRefs = (subset: Subset, accessionRefs: AccessionRef[]) => (dispatch) => { export const addSubsetAccessionRefs = (subset: Subset, accessionRefs: AccessionRef[]) => (dispatch) => {
return AccessionService.toUUID(accessionRefs) return SubsetService.addAccessions(subset.uuid, subset.version, accessionRefs)
.then((accessionRefs) => { .then((subset) => {
SubsetService.addAccessions(subset.uuid, subset.version, Object.keys(accessionRefs)) dispatch(receiveSubset(subset));
.then((subset) => { dispatch(loadMoreAccessions(subset.uuid));
dispatch(receiveSubset(subset)); return subset;
dispatch(loadMoreAccessions(subset.uuid));
return subset;
});
}); });
}; };
export const clearAccessionRefList = (subset: Subset) => {
return (dispatch, getState) => {
return SubsetService.setAccessions(subset.uuid, subset.version, [])
.then((saved) => {
dispatch(receiveSubset(saved));
dispatch(loadMoreAccessions(saved.uuid));
return saved;
}).catch((error) => {
console.log('Clear error', error);
});
};
};
export const rematchSubsetAccessions = (subset: Subset) => {
return (dispatch, getState) => {
return SubsetService.rematchAccessions(subset.uuid, subset.version)
.then((saved) => {
dispatch(receiveSubset(saved));
dispatch(loadMoreAccessions(saved.uuid));
return saved;
}).catch((error) => {
console.log('Rematch error', error);
});
};
};
// Review step // Review step
export const publishSubset = (subset: Subset) => (dispatch) => { export const publishSubset = (subset: Subset) => (dispatch) => {
return SubsetService.reviewSubset(subset.uuid, subset.version) return SubsetService.reviewSubset(subset.uuid, subset.version)
......
...@@ -18,6 +18,8 @@ import CSVConfiguration, { CSVConfig } from 'ui/common/csv-configuration/CSVConf ...@@ -18,6 +18,8 @@ import CSVConfiguration, { CSVConfig } from 'ui/common/csv-configuration/CSVConf
import AccessionRefsTable from 'ui/catalog/accession/AccessionRefsTable'; import AccessionRefsTable from 'ui/catalog/accession/AccessionRefsTable';
import Loading from 'ui/common/Loading'; import Loading from 'ui/common/Loading';
import Page from 'model/Page'; import Page from 'model/Page';
import ButtonBar from 'ui/common/buttons/ButtonBar';
import ActionButton from 'ui/common/buttons/ActionButton';
interface IListOfAccession extends React.ClassAttributes<any> { interface IListOfAccession extends React.ClassAttributes<any> {
classes: any; classes: any;
...@@ -25,6 +27,8 @@ interface IListOfAccession extends React.ClassAttributes<any> { ...@@ -25,6 +27,8 @@ interface IListOfAccession extends React.ClassAttributes<any> {
onAccessionsUpdated: (AccessionRefs: AccessionRef[]) => Promise<Subset>; onAccessionsUpdated: (AccessionRefs: AccessionRef[]) => Promise<Subset>;
accessionRefs: Page<AccessionRef>; accessionRefs: Page<AccessionRef>;
loadAccessions: (page?: Page<AccessionRef>) => any; loadAccessions: (page?: Page<AccessionRef>) => any;
rematchAccessions: (subset: Subset) => void;
clearAccessionRefList: (subset: Subset) => void;
t: any; t: any;
} }
...@@ -62,6 +66,15 @@ class ListOfAccession extends React.Component<IListOfAccession, any> { ...@@ -62,6 +66,15 @@ class ListOfAccession extends React.Component<IListOfAccession, any> {
this.setState({...this.state, csvConfig: value}); this.setState({...this.state, csvConfig: value});
} }
private rematchAccessions = () => {
const {subset, rematchAccessions} = this.props;
rematchAccessions(subset);
}
private clearList = () => {
const {subset, clearAccessionRefList} = this.props;
clearAccessionRefList(subset);
}
public constructor(props: any) { public constructor(props: any) {
super(props); super(props);
...@@ -107,7 +120,17 @@ class ListOfAccession extends React.Component<IListOfAccession, any> { ...@@ -107,7 +120,17 @@ class ListOfAccession extends React.Component<IListOfAccession, any> {
{ uploading && <Loading message={ uploadText } /> } { uploading && <Loading message={ uploadText } /> }
<h3>{ t('subsets.dashboard.p.stepper.accessionList.accessionListCount', {count: subset && subset.accessionCount || 0}) }</h3> <h3>
{ t('subsets.dashboard.p.stepper.accessionList.accessionListCount', {count: subset && subset.accessionCount || 0}) }
{ !uploading &&
<span className="float-right">
<ButtonBar>
<ActionButton title={ t('datasets.dashboard.p.stepper.listOfAccessions.rematch') } action={ this.rematchAccessions }/>
<ActionButton title={ t('datasets.dashboard.p.stepper.listOfAccessions.clearList') } action={ this.clearList }/>
</ButtonBar>
</span>
}
</h3>
<AccessionRefsTable <AccessionRefsTable
loadNextPage={ loadAccessions } loadNextPage={ loadAccessions }
paged={ accessionRefs } paged={ accessionRefs }
......
...@@ -2,7 +2,7 @@ import * as React from 'react'; ...@@ -2,7 +2,7 @@ import * as React from 'react';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
// actions // actions
import { updateSubsetAccessionRefs } from 'subsets/actions/editor'; import { addSubsetAccessionRefs, rematchSubsetAccessions, clearAccessionRefList } from 'subsets/actions/editor';
import {loadMoreAccessions} from 'subsets/actions/dashboard'; import {loadMoreAccessions} from 'subsets/actions/dashboard';
// models // models
...@@ -18,6 +18,8 @@ import Loading from 'ui/common/Loading'; ...@@ -18,6 +18,8 @@ import Loading from 'ui/common/Loading';
interface IAccessionsListStep extends React.ClassAttributes<any> { interface IAccessionsListStep extends React.ClassAttributes<any> {
item: Subset; item: Subset;
updateSubsetAccessionRefs: (subset: Subset, accessionRefs: AccessionRef[]) => Promise<Subset>; updateSubsetAccessionRefs: (subset: Subset, accessionRefs: AccessionRef[]) => Promise<Subset>;
rematchSubsetAccessions: (subset: Subset) => Promise<Subset>;
clearAccessionRefList: (subset: Subset) => Promise<Subset>;
loadMore: (uuid: string, page?: Page<AccessionRef>) => any; loadMore: (uuid: string, page?: Page<AccessionRef>) => any;
accessionRefs: Page<AccessionRef>; accessionRefs: Page<AccessionRef>;
uuid: string; uuid: string;
...@@ -44,13 +46,15 @@ class AccessionsListStep extends StepperTemplate<IAccessionsListStep> { ...@@ -44,13 +46,15 @@ class AccessionsListStep extends StepperTemplate<IAccessionsListStep> {
} }
protected renderContent = () => { protected renderContent = () => {
const { item, accessionRefs } = this.props; const { item, accessionRefs, rematchSubsetAccessions, clearAccessionRefList } = this.props;
return !item ? <Loading /> : ( return !item ? <Loading /> : (
<ListOfAccessions <ListOfAccessions
onAccessionsUpdated={ this.updateaccessionRefs } onAccessionsUpdated={ this.updateaccessionRefs }
subset={ item } subset={ item }
accessionRefs={ accessionRefs } accessionRefs={ accessionRefs }
rematchAccessions={ rematchSubsetAccessions }
clearAccessionRefList={ clearAccessionRefList }
loadAccessions={ this.loadMoreAccessions } loadAccessions={ this.loadMoreAccessions }
/> />
); );
...@@ -69,7 +73,9 @@ const mapStateToProps = (state, ownProps) => ({ ...@@ -69,7 +73,9 @@ const mapStateToProps = (state, ownProps) => ({
}); });
const mapDispatchToProps = (dispatch) => bindActionCreators({ const mapDispatchToProps = (dispatch) => bindActionCreators({
updateSubsetAccessionRefs, updateSubsetAccessionRefs: addSubsetAccessionRefs,
rematchSubsetAccessions,
clearAccessionRefList,
loadMore: loadMoreAccessions, loadMore: loadMoreAccessions,
}, dispatch); }, dispatch);
......
...@@ -94,7 +94,7 @@ class AccessionRefsTable extends React.Component<IAccessionRefsTableProps, any> ...@@ -94,7 +94,7 @@ class AccessionRefsTable extends React.Component<IAccessionRefsTableProps, any>
</TableRow> </TableRow>
); );
return paged ? paged.content && paged.content.sort((a, b) => a.acceNumb.localeCompare(b.acceNumb)) && ( return paged ? paged.content && (
<div className={ this.props.classes.root }> <div className={ this.props.classes.root }>
<Table maxHeight="500px" widths={ widths } headers={ [ <Table maxHeight="500px" widths={ widths } headers={ [
t('institutes.common.instCode'), t('institutes.common.instCode'),
......
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