2020-03-05 22:12:46 +01:00
|
|
|
import React from 'react';
|
2020-04-29 20:15:45 +02:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
import { BrowserRouter, HashRouter } from 'react-router-dom';
|
2020-04-07 22:16:11 +02:00
|
|
|
import { ThemeWrapper } from '@ohif/ui';
|
2020-05-07 16:19:58 +02:00
|
|
|
import {
|
|
|
|
|
CommandsManager,
|
|
|
|
|
ExtensionManager,
|
|
|
|
|
ServicesManager,
|
|
|
|
|
HotkeysManager,
|
|
|
|
|
UINotificationService,
|
|
|
|
|
UIModalService,
|
|
|
|
|
UIDialogService,
|
|
|
|
|
MeasurementService,
|
|
|
|
|
utils,
|
|
|
|
|
redux as reduxOHIF,
|
|
|
|
|
} from '@ohif/core';
|
2020-04-29 20:15:45 +02:00
|
|
|
import routes from './routes';
|
|
|
|
|
|
2020-05-07 16:19:58 +02:00
|
|
|
/**
|
|
|
|
|
* ENV Variable to determine routing behavior
|
|
|
|
|
*/
|
|
|
|
|
const Router = JSON.parse(process.env.USE_HASH_ROUTER)
|
|
|
|
|
? HashRouter
|
|
|
|
|
: BrowserRouter;
|
|
|
|
|
|
|
|
|
|
const commandsManagerConfig = {
|
|
|
|
|
/** Used by commands to inject `viewports` from "redux" */
|
|
|
|
|
getAppState: () => store.getState(),
|
|
|
|
|
/** Used by commands to determine active context */
|
|
|
|
|
getActiveContexts: () => getActiveContexts(store.getState()),
|
|
|
|
|
};
|
|
|
|
|
const commandsManager = new CommandsManager(commandsManagerConfig);
|
|
|
|
|
const servicesManager = new ServicesManager();
|
|
|
|
|
// const hotkeysManager = new HotkeysManager(commandsManager, servicesManager);
|
|
|
|
|
const extensionManager = new ExtensionManager({
|
|
|
|
|
commandsManager,
|
|
|
|
|
servicesManager,
|
|
|
|
|
appConfig,
|
|
|
|
|
api: {
|
|
|
|
|
contexts: CONTEXTS,
|
|
|
|
|
hooks: {
|
|
|
|
|
useAppContext,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
extensionManager.registerExtensions(/* Array of Extensions */);
|
|
|
|
|
|
|
|
|
|
function App({ config, defaultExtensions }) {
|
|
|
|
|
const appConfig = {
|
|
|
|
|
...(typeof config === 'function' ? config({ servicesManager }) : config),
|
|
|
|
|
};
|
2019-12-09 18:47:23 +01:00
|
|
|
|
2020-03-05 22:12:46 +01:00
|
|
|
return (
|
2020-05-07 16:19:58 +02:00
|
|
|
<Router basename={appConfig.routerBasename}>
|
2020-04-29 20:15:45 +02:00
|
|
|
<ThemeWrapper>{routes()}</ThemeWrapper>
|
|
|
|
|
</Router>
|
2020-02-12 21:35:04 +01:00
|
|
|
);
|
2020-04-29 20:15:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
App.propTypes = {
|
|
|
|
|
config: PropTypes.oneOfType([
|
|
|
|
|
PropTypes.func,
|
|
|
|
|
PropTypes.shape({
|
|
|
|
|
routerBasename: PropTypes.string.isRequired,
|
|
|
|
|
oidc: PropTypes.array,
|
|
|
|
|
whiteLabeling: PropTypes.shape({
|
|
|
|
|
createLogoComponentFn: PropTypes.func,
|
|
|
|
|
}),
|
|
|
|
|
extensions: PropTypes.array,
|
|
|
|
|
}),
|
|
|
|
|
]).isRequired,
|
|
|
|
|
/* Extensions that are "bundled" or "baked-in" to the application */
|
|
|
|
|
defaultExtensions: PropTypes.array,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
App.defaultProps = {
|
|
|
|
|
config: {
|
2020-05-07 16:19:58 +02:00
|
|
|
/**
|
|
|
|
|
* Relative route from domain root that OHIF instance is installed at.
|
|
|
|
|
* For example:
|
|
|
|
|
*
|
|
|
|
|
* Hosted at: https://ohif.org/where-i-host-the/viewer/
|
|
|
|
|
* Value: `/where-i-host-the/viewer/`
|
|
|
|
|
* */
|
|
|
|
|
routerBaseName: '/',
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
2020-04-29 20:15:45 +02:00
|
|
|
showStudyList: true,
|
|
|
|
|
oidc: [],
|
|
|
|
|
extensions: [],
|
|
|
|
|
},
|
|
|
|
|
defaultExtensions: [],
|
2020-03-05 22:12:46 +01:00
|
|
|
};
|
2020-02-12 21:35:04 +01:00
|
|
|
|
2020-03-05 22:12:46 +01:00
|
|
|
export default App;
|