Commit 9606ef40 authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch '17-overviews-only' into 'master'

Resolve "Overviews only"

Closes #17

See merge request !13
parents f7e7c579 301fce9d
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
"error", "error",
{ {
"types": { "types": {
"object": false // "object": false
} }
} }
], ],
......
...@@ -8,6 +8,7 @@ import { reconfigureServiceAxios, LoginService } from '@genesys/client/service'; ...@@ -8,6 +8,7 @@ import { reconfigureServiceAxios, LoginService } from '@genesys/client/service';
import App from './ui/App'; import App from './ui/App';
import ApiAccessError from './ui/ApiAccessError'; import ApiAccessError from './ui/ApiAccessError';
import { Config, DefaultConfig } from '../config/config'; import { Config, DefaultConfig } from '../config/config';
import OverviewPage from './ui/OverviewPage';
// declare const window: Window & { devToolsExtension: any, __REDUX_DEVTOOLS_EXTENSION_COMPOSE__: any, initialLanguage: any, initialI18nStore: any, localeMapping: any }; // declare const window: Window & { devToolsExtension: any, __REDUX_DEVTOOLS_EXTENSION_COMPOSE__: any, initialLanguage: any, initialI18nStore: any, localeMapping: any };
// const AUTH_COOKIE = 'GENESYS_AUTH'; // const AUTH_COOKIE = 'GENESYS_AUTH';
...@@ -62,3 +63,25 @@ export function showGenesysUI(holdingNode: HTMLElement, config: Config = Default ...@@ -62,3 +63,25 @@ export function showGenesysUI(holdingNode: HTMLElement, config: Config = Default
); );
}); });
} }
export function showOverview(holdingNode: HTMLElement, config: Config = DefaultConfig, language: string = 'en') {
const { apiUrl, clientId, clientKey, filter } = config;
reconfigureServiceAxios({ apiUrl });
initI18n(language);
checkAccessTokens(apiUrl, clientId, clientKey).then( (result) => {
ReactDOM.render(
<OverviewPage filter={ filter } />,
holdingNode,
);
}).catch((err) => {
log('Oh, oh', err);
ReactDOM.render(
<ApiAccessError error={ err } apiUrl={ apiUrl } />,
holdingNode,
);
});
}
import * as React from 'react'; import * as React from 'react';
import { WithTranslation, withTranslation } from 'react-i18next'; import { WithTranslation, withTranslation } from 'react-i18next';
import { parse } from 'query-string';
// Models // Models
import { IPageRequest } from '@genesys/client/model/FilteredPage';
import { AccessionService } from '@genesys/client/service'; import { AccessionService } from '@genesys/client/service';
// UI // UI
...@@ -12,7 +10,6 @@ import AccessionFilter from '@genesys/client/model/accession/AccessionFilter'; ...@@ -12,7 +10,6 @@ import AccessionFilter from '@genesys/client/model/accession/AccessionFilter';
interface IOverviewPageProps extends React.ClassAttributes<any>, WithTranslation { interface IOverviewPageProps extends React.ClassAttributes<any>, WithTranslation {
filter: AccessionFilter; filter: AccessionFilter;
location: any;
} }
class BrowsePage extends React.Component<IOverviewPageProps, any> { class BrowsePage extends React.Component<IOverviewPageProps, any> {
...@@ -25,9 +22,9 @@ class BrowsePage extends React.Component<IOverviewPageProps, any> { ...@@ -25,9 +22,9 @@ class BrowsePage extends React.Component<IOverviewPageProps, any> {
} }
} }
private loadData = (pageR: IPageRequest): Promise<any> => { private loadData = (): Promise<any> => {
return AccessionService return AccessionService
.listOverview(this.props.filter, pageR) .listOverview(this.props.filter)
.then((data) => { .then((data) => {
console.log('overview: ', data); console.log('overview: ', data);
this.setState({ overviewData: data }); this.setState({ overviewData: data });
...@@ -40,8 +37,7 @@ class BrowsePage extends React.Component<IOverviewPageProps, any> { ...@@ -40,8 +37,7 @@ class BrowsePage extends React.Component<IOverviewPageProps, any> {
public componentDidMount() { public componentDidMount() {
if (typeof window !== 'undefined') { // Call should be started only on client side if (typeof window !== 'undefined') { // Call should be started only on client side
const current = +parse(this.props.location.search).p this.loadData();
this.loadData(current ? { page: current } : {});
} }
} }
......
This diff is collapsed.
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