Commit 4146a8ac authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch '32-links-to-datasets-and-subsets' into 'release/1.1'

Links to datasets and subsets

See merge request !31
parents 519ac7d3 0741030f
......@@ -21,6 +21,7 @@ interface IAccessionDetailsPageState {
interface IAccessionDetailsPage {
match: any;
publicWebsiteUrl: string;
}
class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithTranslation & WithConfig, IAccessionDetailsPageState> {
......@@ -98,7 +99,7 @@ class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithT
public render() {
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;
......@@ -281,7 +282,7 @@ class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithT
<h2 className="mt-4">{ t('accession.subsets') }</h2>
{ accession.subsets.map((subset, idx) => (
<div key={ idx }>
<h5>{ subset.title }</h5>
<a target="_blank" href= { `${publicWebsiteUrl}/subset/${subset.uuid}` }>{ subset.title }</a>
<p>{ subset.description }</p>
</div>
)) }
......@@ -293,7 +294,7 @@ class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithT
<h2 className="mt-4">{ t('accession.datasets') }</h2>
{ accession.datasets.map((dataset, idx) => (
<div key={ idx }>
<h5>{ dataset.title }</h5>
<a target="_blank" href= { `${publicWebsiteUrl}/dataset/${dataset.uuid}` }>{ dataset.title }</a>
<p>{ dataset.description }</p>
</div>
)) }
......@@ -324,6 +325,7 @@ class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithT
const mapStateToProps = (state) => ({
appConfig: state.appConfig.config,
publicWebsiteUrl: (state.apiInfo.apiInfo && state.apiInfo.apiInfo.publicWebsiteUrl) || '',
});
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 appConfig from 'core/reducer/appConfig';
import decoding from './decoding';
import apiInfo from './apiInfo';
const rootReducer = () => (combineReducers({
appConfig,
decoding,
apiInfo,
}));
......
import React from 'react';
import { ApiInfoDisplay } from './ApiInfoDisplay';
import { ApiInfoService } from '@genesys/client/service';
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> {}
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);
});
}
interface IApiInfoPage extends React.ClassAttributes<any>, WithTranslation {
apiInfo: ApiInfo;
}
class ApiInfoPage extends React.Component<IApiInfoPage, any> {
public render() {
const { t } = this.props;
const { t, apiInfo } = this.props;
return (
<>
<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';
import { createHashHistory } from 'history';
import { bindActionCreators } from 'redux';
import { getCountryCodes } from 'core/actions/decoding';
import { getApiInfo } from 'core/actions/apiInfo';
import { withTranslation, WithTranslation } from 'react-i18next';
import { WithConfig } from 'config/config';
import CartPage from 'request/CartPage';
import OverviewPage from 'accession/OverviewPage';
import RequestPage from 'request/RequestPage';
import MapPage from 'map/MapPage';
import ApiInfo from '@genesys/client/model/ApiInfo';
import 'leaflet/dist/leaflet.css';
......@@ -21,12 +23,14 @@ const hashHistory = createHashHistory({});
interface IAppProps extends React.ClassAttributes<any> {
getCountryCodes: (lang: string) => Promise<Record<string, string>>;
getApiInfo: () => Promise<ApiInfo>;
}
class App extends React.Component<IAppProps & WithTranslation & WithConfig, any> {
public componentDidMount() {
const { getCountryCodes, i18n } = this.props;
const { getCountryCodes, i18n, getApiInfo } = this.props;
getCountryCodes(i18n.language);
getApiInfo()
}
public render() {
......@@ -59,6 +63,7 @@ const mapStateToProps = (state) => ({
const mapDispatchToProps = (dispatch) => bindActionCreators({
getCountryCodes,
getApiInfo,
}, dispatch);
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