Commit 0741030f authored by Oleksii Savran's avatar Oleksii Savran
Browse files

Links to datasets and subsets

parent 519ac7d3
...@@ -21,6 +21,7 @@ interface IAccessionDetailsPageState { ...@@ -21,6 +21,7 @@ interface IAccessionDetailsPageState {
interface IAccessionDetailsPage { interface IAccessionDetailsPage {
match: any; match: any;
publicWebsiteUrl: string;
} }
class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithTranslation & WithConfig, IAccessionDetailsPageState> { class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithTranslation & WithConfig, IAccessionDetailsPageState> {
...@@ -98,7 +99,7 @@ class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithT ...@@ -98,7 +99,7 @@ class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithT
public render() { public render() {
const { accession, cartItems } = this.state; const { accession, cartItems } = this.state;
const { t, appConfig: { apiUrl, shoppingCart, map }, appConfig } = this.props; const { t, appConfig: { apiUrl, shoppingCart, map }, appConfig, publicWebsiteUrl } = this.props;
let propertyIndex = 0; let propertyIndex = 0;
...@@ -281,7 +282,7 @@ class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithT ...@@ -281,7 +282,7 @@ class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithT
<h2 className="mt-4">{ t('accession.subsets') }</h2> <h2 className="mt-4">{ t('accession.subsets') }</h2>
{ accession.subsets.map((subset, idx) => ( { accession.subsets.map((subset, idx) => (
<div key={ idx }> <div key={ idx }>
<h5>{ subset.title }</h5> <a target="_blank" href= { `${publicWebsiteUrl}/subset/${subset.uuid}` }>{ subset.title }</a>
<p>{ subset.description }</p> <p>{ subset.description }</p>
</div> </div>
)) } )) }
...@@ -293,7 +294,7 @@ class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithT ...@@ -293,7 +294,7 @@ class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithT
<h2 className="mt-4">{ t('accession.datasets') }</h2> <h2 className="mt-4">{ t('accession.datasets') }</h2>
{ accession.datasets.map((dataset, idx) => ( { accession.datasets.map((dataset, idx) => (
<div key={ idx }> <div key={ idx }>
<h5>{ dataset.title }</h5> <a target="_blank" href= { `${publicWebsiteUrl}/dataset/${dataset.uuid}` }>{ dataset.title }</a>
<p>{ dataset.description }</p> <p>{ dataset.description }</p>
</div> </div>
)) } )) }
...@@ -324,6 +325,7 @@ class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithT ...@@ -324,6 +325,7 @@ class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithT
const mapStateToProps = (state) => ({ const mapStateToProps = (state) => ({
appConfig: state.appConfig.config, appConfig: state.appConfig.config,
publicWebsiteUrl: (state.apiInfo.apiInfo && state.apiInfo.apiInfo.publicWebsiteUrl) || '',
}); });
export default connect(mapStateToProps)(withTranslation()(AccessionDetailsPage)); export default connect(mapStateToProps)(withTranslation()(AccessionDetailsPage));
import { ApiInfoService } from '@genesys/client/service';
import { RECEIVE_API_INFO } from 'core/constants/apiInfo';
export const getApiInfo = () => (dispatch) => {
return ApiInfoService
.apiInfo()
.then((data) => {
console.log('apiInfo: ', data);
dispatch({
type: RECEIVE_API_INFO,
payload: data,
});
})
.catch((e) => {
console.log('Api info call failed: ', e);
});
};
export const RECEIVE_API_INFO = 'core/apiInfo/RECEIVE';
import update from 'immutability-helper';
import { RECEIVE_API_INFO } from 'core/constants/apiInfo';
import ApiInfo from '@genesys/client/model/ApiInfo';
const INITIAL_STATE: {
apiInfo: ApiInfo,
} = {
apiInfo: null,
};
export default (state = INITIAL_STATE, action: { type?: string, payload?: any } = { type: '', payload: {} }) => {
switch (action.type) {
case RECEIVE_API_INFO: {
return update(state, {
apiInfo: { $set: action.payload },
});
}
default:
return state;
}
}
import { combineReducers } from 'redux'; import { combineReducers } from 'redux';
import appConfig from 'core/reducer/appConfig'; import appConfig from 'core/reducer/appConfig';
import decoding from './decoding'; import decoding from './decoding';
import apiInfo from './apiInfo';
const rootReducer = () => (combineReducers({ const rootReducer = () => (combineReducers({
appConfig, appConfig,
decoding, decoding,
apiInfo,
})); }));
......
import React from 'react'; import React from 'react';
import { ApiInfoDisplay } from './ApiInfoDisplay'; import { ApiInfoDisplay } from './ApiInfoDisplay';
import { ApiInfoService } from '@genesys/client/service';
import PageTitle from 'ui/common/PageTitle'; import PageTitle from 'ui/common/PageTitle';
import { withTranslation } from 'react-i18next'; import { WithTranslation, withTranslation } from 'react-i18next';
import { connect } from 'react-redux';
import ApiInfo from '@genesys/client/model/ApiInfo';
// interface IApiInfoPage extends React.ClassAttributes<any> {} interface IApiInfoPage extends React.ClassAttributes<any>, WithTranslation {
apiInfo: ApiInfo;
class ApiInfoPage extends React.Component<any, any> { }
public state = {
apiInfo: null,
};
public componentDidMount() {
ApiInfoService
.apiInfo()
.then((data) => {
console.log('apiInfo: ', data);
this.setState({ apiInfo: data });
})
.catch((e) => {
console.log('Api info call failed: ', e);
});
}
class ApiInfoPage extends React.Component<IApiInfoPage, any> {
public render() { public render() {
const { t } = this.props; const { t, apiInfo } = this.props;
return ( return (
<> <>
<PageTitle title={ t('pagetitle.apiInfo') } /> <PageTitle title={ t('pagetitle.apiInfo') } />
<ApiInfoDisplay data={ this.state.apiInfo }/> <ApiInfoDisplay data={ apiInfo }/>
</> </>
); );
}; };
} }
export default withTranslation()(ApiInfoPage); const mapStateToProps = (state) => ({
apiInfo: state.apiInfo.apiInfo,
});
export default connect(mapStateToProps)(withTranslation()(ApiInfoPage));
...@@ -8,12 +8,14 @@ import AccessionDetails from 'accession/AccessionDetailsPage'; ...@@ -8,12 +8,14 @@ import AccessionDetails from 'accession/AccessionDetailsPage';
import { createHashHistory } from 'history'; import { createHashHistory } from 'history';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import { getCountryCodes } from 'core/actions/decoding'; import { getCountryCodes } from 'core/actions/decoding';
import { getApiInfo } from 'core/actions/apiInfo';
import { withTranslation, WithTranslation } from 'react-i18next'; import { withTranslation, WithTranslation } from 'react-i18next';
import { WithConfig } from 'config/config'; import { WithConfig } from 'config/config';
import CartPage from 'request/CartPage'; import CartPage from 'request/CartPage';
import OverviewPage from 'accession/OverviewPage'; import OverviewPage from 'accession/OverviewPage';
import RequestPage from 'request/RequestPage'; import RequestPage from 'request/RequestPage';
import MapPage from 'map/MapPage'; import MapPage from 'map/MapPage';
import ApiInfo from '@genesys/client/model/ApiInfo';
import 'leaflet/dist/leaflet.css'; import 'leaflet/dist/leaflet.css';
...@@ -21,12 +23,14 @@ const hashHistory = createHashHistory({}); ...@@ -21,12 +23,14 @@ const hashHistory = createHashHistory({});
interface IAppProps extends React.ClassAttributes<any> { interface IAppProps extends React.ClassAttributes<any> {
getCountryCodes: (lang: string) => Promise<Record<string, string>>; getCountryCodes: (lang: string) => Promise<Record<string, string>>;
getApiInfo: () => Promise<ApiInfo>;
} }
class App extends React.Component<IAppProps & WithTranslation & WithConfig, any> { class App extends React.Component<IAppProps & WithTranslation & WithConfig, any> {
public componentDidMount() { public componentDidMount() {
const { getCountryCodes, i18n } = this.props; const { getCountryCodes, i18n, getApiInfo } = this.props;
getCountryCodes(i18n.language); getCountryCodes(i18n.language);
getApiInfo()
} }
public render() { public render() {
...@@ -59,6 +63,7 @@ const mapStateToProps = (state) => ({ ...@@ -59,6 +63,7 @@ const mapStateToProps = (state) => ({
const mapDispatchToProps = (dispatch) => bindActionCreators({ const mapDispatchToProps = (dispatch) => bindActionCreators({
getCountryCodes, getCountryCodes,
getApiInfo,
}, dispatch); }, dispatch);
export default connect(mapStateToProps, mapDispatchToProps)(withTranslation()(App)); export default connect(mapStateToProps, mapDispatchToProps)(withTranslation()(App));
......
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