2019-05-29 14:39:54 +02:00
|
|
|
import './config';
|
2019-05-30 18:57:46 +02:00
|
|
|
|
2019-06-03 21:41:49 +02:00
|
|
|
import {
|
|
|
|
|
CommandsManager,
|
|
|
|
|
HotkeysManager,
|
|
|
|
|
extensions,
|
|
|
|
|
redux,
|
|
|
|
|
utils,
|
|
|
|
|
} from 'ohif-core';
|
2019-05-30 18:57:46 +02:00
|
|
|
import React, { Component } from 'react';
|
2019-01-24 10:22:40 +01:00
|
|
|
import {
|
2019-05-01 18:56:41 +02:00
|
|
|
getDefaultToolbarButtons,
|
2019-04-29 21:39:09 +02:00
|
|
|
getUserManagerForOpenIdConnectClient,
|
|
|
|
|
initWebWorkers,
|
2019-05-29 14:39:54 +02:00
|
|
|
} from './utils/index.js';
|
2019-05-30 18:57:46 +02:00
|
|
|
|
2019-05-29 14:39:54 +02:00
|
|
|
import ConnectedToolContextMenu from './connectedComponents/ConnectedToolContextMenu';
|
2019-05-30 18:57:46 +02:00
|
|
|
import OHIFCornerstoneExtension from '@ohif/extension-cornerstone';
|
|
|
|
|
import OHIFDicomHtmlExtension from 'ohif-dicom-html-extension';
|
2019-06-04 08:54:02 +02:00
|
|
|
import OHIFDicomMicroscopyExtension from '@ohif/extension-dicom-microscopy';
|
2019-05-30 18:57:46 +02:00
|
|
|
import OHIFDicomPDFExtension from 'ohif-dicom-pdf-extension';
|
|
|
|
|
import OHIFStandaloneViewer from './OHIFStandaloneViewer';
|
|
|
|
|
import OHIFVTKExtension from '@ohif/extension-vtk';
|
2019-05-31 17:55:44 +02:00
|
|
|
import { OidcProvider } from 'redux-oidc';
|
2019-05-30 18:57:46 +02:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
|
import { BrowserRouter as Router } from 'react-router-dom';
|
|
|
|
|
import WhiteLabellingContext from './WhiteLabellingContext';
|
2019-06-03 21:41:49 +02:00
|
|
|
import appCommands from './appCommands';
|
2019-05-30 18:57:46 +02:00
|
|
|
import setupTools from './setupTools';
|
2019-05-31 17:55:44 +02:00
|
|
|
import store from './store';
|
2019-01-24 10:22:40 +01:00
|
|
|
|
2019-06-03 04:44:13 +02:00
|
|
|
// ~~~~ APP SETUP
|
2019-06-03 21:41:49 +02:00
|
|
|
const commandsManagerConfig = {
|
|
|
|
|
getAppState: () => store.getState(),
|
|
|
|
|
getActiveContexts: () => store.getState().ui.activeContexts,
|
|
|
|
|
};
|
|
|
|
|
|
2019-06-06 20:41:31 +02:00
|
|
|
const commandsManager = new CommandsManager(commandsManagerConfig);
|
|
|
|
|
const hotkeysManager = new HotkeysManager(commandsManager);
|
2019-01-17 17:00:21 +01:00
|
|
|
|
2019-06-03 21:41:49 +02:00
|
|
|
// TODO: Should be done in extensions w/ commandsModule
|
2019-06-06 03:29:50 +02:00
|
|
|
// ~~ ADD COMMANDS
|
2019-06-06 20:41:31 +02:00
|
|
|
appCommands.init(commandsManager);
|
2019-06-08 21:26:11 +02:00
|
|
|
if (window.config.hotkeys) {
|
|
|
|
|
hotkeysManager.setHotkeys(window.config.hotkeys, true);
|
|
|
|
|
}
|
2019-06-02 21:44:27 +02:00
|
|
|
|
2019-06-03 18:22:25 +02:00
|
|
|
// Force active contexts for now. These should be set in Viewer/ActiveViewer
|
|
|
|
|
store.dispatch({
|
|
|
|
|
type: 'ADD_ACTIVE_CONTEXT',
|
|
|
|
|
item: 'VIEWER',
|
|
|
|
|
});
|
|
|
|
|
store.dispatch({
|
|
|
|
|
type: 'ADD_ACTIVE_CONTEXT',
|
|
|
|
|
item: 'VIEWER::CORNERSTONE',
|
|
|
|
|
});
|
|
|
|
|
|
2019-06-06 03:29:50 +02:00
|
|
|
// ~~~~ END APP SETUP
|
2019-06-03 04:44:13 +02:00
|
|
|
|
2019-05-29 14:39:54 +02:00
|
|
|
setupTools(store);
|
2019-02-10 22:28:42 +01:00
|
|
|
|
2019-05-02 23:12:06 +02:00
|
|
|
const children = {
|
2019-05-31 17:55:44 +02:00
|
|
|
viewport: [<ConnectedToolContextMenu key="tool-context" />],
|
2019-05-29 14:39:54 +02:00
|
|
|
};
|
2019-02-10 22:28:42 +01:00
|
|
|
|
2019-02-02 12:10:56 +01:00
|
|
|
/** TODO: extensions should be passed in as prop as soon as we have the extensions as separate packages and then registered by ExtensionsManager */
|
2019-06-03 04:44:13 +02:00
|
|
|
extensions.ExtensionManager.registerExtensions(store, [
|
2019-05-02 23:12:06 +02:00
|
|
|
new OHIFCornerstoneExtension({ children }),
|
2019-03-01 10:55:52 +01:00
|
|
|
new OHIFVTKExtension(),
|
2019-02-02 12:10:56 +01:00
|
|
|
new OHIFDicomPDFExtension(),
|
2019-02-08 19:13:12 +01:00
|
|
|
new OHIFDicomHtmlExtension(),
|
2019-04-28 21:54:56 +02:00
|
|
|
new OHIFDicomMicroscopyExtension(),
|
2019-06-03 04:44:13 +02:00
|
|
|
]);
|
2019-01-17 17:00:21 +01:00
|
|
|
|
2019-01-24 10:22:40 +01:00
|
|
|
// TODO[react] Use a provider when the whole tree is React
|
2019-05-29 14:39:54 +02:00
|
|
|
window.store = store;
|
2019-01-24 10:22:40 +01:00
|
|
|
|
|
|
|
|
function handleServers(servers) {
|
|
|
|
|
if (servers) {
|
2019-06-03 04:44:13 +02:00
|
|
|
utils.addServers(servers, store);
|
2019-01-24 10:22:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-17 17:00:21 +01:00
|
|
|
class App extends Component {
|
2019-01-17 17:39:08 +01:00
|
|
|
static propTypes = {
|
2019-05-09 22:10:14 +02:00
|
|
|
routerBasename: PropTypes.string.isRequired,
|
|
|
|
|
relativeWebWorkerScriptsPath: PropTypes.string.isRequired,
|
|
|
|
|
servers: PropTypes.object.isRequired,
|
2019-01-24 10:22:40 +01:00
|
|
|
oidc: PropTypes.array,
|
2019-04-29 21:06:17 +02:00
|
|
|
whiteLabelling: PropTypes.object,
|
2019-05-29 14:39:54 +02:00
|
|
|
};
|
2019-01-24 10:22:40 +01:00
|
|
|
|
2019-01-30 12:24:34 +01:00
|
|
|
static defaultProps = {
|
2019-04-28 21:54:56 +02:00
|
|
|
whiteLabelling: {},
|
2019-05-09 22:10:14 +02:00
|
|
|
oidc: [],
|
2019-05-29 14:39:54 +02:00
|
|
|
};
|
2019-01-30 12:24:34 +01:00
|
|
|
|
2019-01-24 10:22:40 +01:00
|
|
|
constructor(props) {
|
2019-05-29 14:39:54 +02:00
|
|
|
super(props);
|
2019-01-24 10:22:40 +01:00
|
|
|
|
2019-05-01 18:56:41 +02:00
|
|
|
//
|
2019-05-29 14:39:54 +02:00
|
|
|
const defaultButtons = getDefaultToolbarButtons(this.props.routerBasename);
|
2019-06-03 04:44:13 +02:00
|
|
|
const buttonsAction = redux.actions.setAvailableButtons(defaultButtons);
|
2019-05-01 18:56:41 +02:00
|
|
|
|
2019-05-29 14:39:54 +02:00
|
|
|
store.dispatch(buttonsAction);
|
2019-05-01 18:56:41 +02:00
|
|
|
|
2019-05-09 22:07:21 +02:00
|
|
|
if (this.props.oidc.length) {
|
2019-05-29 14:39:54 +02:00
|
|
|
const firstOpenIdClient = this.props.oidc[0];
|
2019-05-04 03:18:13 +02:00
|
|
|
|
2019-05-09 22:07:21 +02:00
|
|
|
this.userManager = getUserManagerForOpenIdConnectClient(
|
|
|
|
|
store,
|
|
|
|
|
firstOpenIdClient
|
2019-05-29 14:39:54 +02:00
|
|
|
);
|
2019-05-09 22:07:21 +02:00
|
|
|
}
|
2019-05-29 14:39:54 +02:00
|
|
|
handleServers(this.props.servers);
|
2019-04-29 21:39:09 +02:00
|
|
|
initWebWorkers(
|
2019-04-29 20:42:29 +02:00
|
|
|
this.props.routerBasename,
|
|
|
|
|
this.props.relativeWebWorkerScriptsPath
|
2019-05-29 14:39:54 +02:00
|
|
|
);
|
2019-01-17 17:39:08 +01:00
|
|
|
}
|
|
|
|
|
|
2019-01-17 17:00:21 +01:00
|
|
|
render() {
|
2019-05-29 14:39:54 +02:00
|
|
|
const userManager = this.userManager;
|
2019-01-24 10:22:40 +01:00
|
|
|
|
|
|
|
|
if (userManager) {
|
|
|
|
|
return (
|
|
|
|
|
<Provider store={store}>
|
|
|
|
|
<OidcProvider store={store} userManager={userManager}>
|
2019-04-28 21:54:56 +02:00
|
|
|
<Router basename={this.props.routerBasename}>
|
2019-01-24 14:00:01 +01:00
|
|
|
<WhiteLabellingContext.Provider value={this.props.whiteLabelling}>
|
|
|
|
|
<OHIFStandaloneViewer userManager={userManager} />
|
|
|
|
|
</WhiteLabellingContext.Provider>
|
2019-04-28 21:54:56 +02:00
|
|
|
</Router>
|
2019-01-24 10:22:40 +01:00
|
|
|
</OidcProvider>
|
|
|
|
|
</Provider>
|
2019-05-29 14:39:54 +02:00
|
|
|
);
|
2019-01-24 10:22:40 +01:00
|
|
|
}
|
|
|
|
|
|
2019-01-17 17:00:21 +01:00
|
|
|
return (
|
|
|
|
|
<Provider store={store}>
|
2019-04-28 21:54:56 +02:00
|
|
|
<Router basename={this.props.routerBasename}>
|
2019-01-24 14:00:01 +01:00
|
|
|
<WhiteLabellingContext.Provider value={this.props.whiteLabelling}>
|
|
|
|
|
<OHIFStandaloneViewer />
|
|
|
|
|
</WhiteLabellingContext.Provider>
|
2019-04-28 21:54:56 +02:00
|
|
|
</Router>
|
2019-01-17 17:00:21 +01:00
|
|
|
</Provider>
|
2019-05-29 14:39:54 +02:00
|
|
|
);
|
2019-01-17 17:00:21 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-29 14:39:54 +02:00
|
|
|
export default App;
|
2019-06-06 20:41:31 +02:00
|
|
|
|
|
|
|
|
export { commandsManager, hotkeysManager };
|