2019-01-17 17:00:21 +01:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
import { BrowserRouter } from 'react-router-dom';
|
|
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
|
import { createStore, combineReducers } from 'redux';
|
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
import OHIF from 'ohif-core';
|
|
|
|
|
import './config';
|
2019-01-24 10:22:40 +01:00
|
|
|
import ui from './redux/ui.js';
|
2019-01-17 17:00:21 +01:00
|
|
|
import OHIFStandaloneViewer from './OHIFStandaloneViewer';
|
2019-01-24 14:00:01 +01:00
|
|
|
import WhiteLabellingContext from './WhiteLabellingContext';
|
2019-02-06 14:46:06 +01:00
|
|
|
import OHIFCornerstoneExtension from 'ohif-cornerstone-extension';
|
2019-02-02 12:10:56 +01:00
|
|
|
import OHIFDicomPDFExtension from 'ohif-dicom-pdf-extension';
|
|
|
|
|
import OHIFDicomMicroscopyExtension from 'ohif-dicom-microscopy-extension';
|
2019-01-31 08:55:05 +01:00
|
|
|
import { loadState, saveState } from './redux/localStorageState.js';
|
2019-01-24 10:22:40 +01:00
|
|
|
import {
|
|
|
|
|
loadUser,
|
|
|
|
|
OidcProvider,
|
|
|
|
|
createUserManager,
|
|
|
|
|
reducer as oidcReducer
|
|
|
|
|
} from 'redux-oidc';
|
|
|
|
|
import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader';
|
2019-02-02 12:10:56 +01:00
|
|
|
import ExtensionManager from './ExtensionManager';
|
2019-01-24 10:22:40 +01:00
|
|
|
|
2019-01-17 17:00:21 +01:00
|
|
|
//import Icons from "./images/icons.svg"
|
|
|
|
|
|
2019-01-24 10:22:40 +01:00
|
|
|
const Icons = '/icons.svg';
|
2019-01-17 17:00:21 +01:00
|
|
|
|
2019-01-31 08:55:05 +01:00
|
|
|
let reducers = OHIF.redux.reducers;
|
2019-01-17 17:00:21 +01:00
|
|
|
reducers.ui = ui;
|
2019-01-24 10:22:40 +01:00
|
|
|
reducers.oidc = oidcReducer;
|
2019-01-17 17:00:21 +01:00
|
|
|
|
2019-01-24 10:22:40 +01:00
|
|
|
const combined = combineReducers(reducers);
|
2019-01-31 08:55:05 +01:00
|
|
|
const store = createStore(combined, loadState());
|
2019-01-17 17:00:21 +01:00
|
|
|
|
2019-01-31 08:55:05 +01:00
|
|
|
store.subscribe(() => {
|
|
|
|
|
saveState({
|
|
|
|
|
preferences: store.getState().preferences
|
|
|
|
|
});
|
|
|
|
|
});
|
2019-01-17 17:00:21 +01:00
|
|
|
|
|
|
|
|
const defaultButtons = [
|
|
|
|
|
{
|
|
|
|
|
command: 'StackScroll',
|
|
|
|
|
type: 'tool',
|
|
|
|
|
text: 'Stack Scroll',
|
|
|
|
|
svgUrl: `${Icons}#icon-tools-stack-scroll`,
|
|
|
|
|
active: false
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
command: 'Zoom',
|
|
|
|
|
type: 'tool',
|
|
|
|
|
text: 'Zoom',
|
|
|
|
|
svgUrl: `${Icons}#icon-tools-zoom`,
|
|
|
|
|
active: false
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
command: 'Wwwc',
|
|
|
|
|
type: 'tool',
|
|
|
|
|
text: 'Levels',
|
|
|
|
|
svgUrl: `${Icons}#icon-tools-levels`,
|
|
|
|
|
active: true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
command: 'Pan',
|
|
|
|
|
type: 'tool',
|
|
|
|
|
text: 'Pan',
|
|
|
|
|
svgUrl: `${Icons}#icon-tools-pan`,
|
|
|
|
|
active: false
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
command: 'Length',
|
|
|
|
|
type: 'tool',
|
|
|
|
|
text: 'Length',
|
|
|
|
|
svgUrl: `${Icons}#icon-tools-measure-temp`,
|
|
|
|
|
active: false
|
|
|
|
|
},
|
|
|
|
|
/*{
|
|
|
|
|
command: 'Annotate',
|
|
|
|
|
type: 'tool',
|
|
|
|
|
text: 'Annotate',
|
|
|
|
|
svgUrl: `${Icons}#icon-tools-measure-non-target`,
|
|
|
|
|
active: false
|
|
|
|
|
},*/
|
|
|
|
|
{
|
|
|
|
|
command: 'Angle',
|
|
|
|
|
type: 'tool',
|
|
|
|
|
text: 'Angle',
|
|
|
|
|
iconClasses: 'fa fa-angle-left',
|
|
|
|
|
active: false
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
command: 'Bidirectional',
|
|
|
|
|
type: 'tool',
|
|
|
|
|
text: 'Bidirectional',
|
|
|
|
|
svgUrl: `${Icons}#icon-tools-measure-target`,
|
|
|
|
|
active: false
|
|
|
|
|
},
|
2019-01-30 17:51:54 +01:00
|
|
|
{
|
|
|
|
|
command: 'Brush',
|
|
|
|
|
type: 'tool',
|
|
|
|
|
text: 'Brush',
|
|
|
|
|
iconClasses: 'fa fa-circle',
|
|
|
|
|
active: false
|
|
|
|
|
},
|
2019-01-17 17:00:21 +01:00
|
|
|
{
|
|
|
|
|
command: 'reset',
|
|
|
|
|
type: 'command',
|
|
|
|
|
text: 'Reset',
|
|
|
|
|
svgUrl: `${Icons}#icon-tools-reset`,
|
|
|
|
|
active: false
|
2019-01-24 10:22:40 +01:00
|
|
|
}
|
2019-01-17 17:00:21 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const buttonsAction = OHIF.redux.actions.setAvailableButtons(defaultButtons);
|
|
|
|
|
|
|
|
|
|
store.dispatch(buttonsAction);
|
|
|
|
|
|
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 */
|
|
|
|
|
let extensions = [
|
2019-02-06 14:46:06 +01:00
|
|
|
new OHIFCornerstoneExtension(),
|
2019-02-02 12:10:56 +01:00
|
|
|
new OHIFDicomPDFExtension(),
|
|
|
|
|
new OHIFDicomMicroscopyExtension()
|
|
|
|
|
];
|
|
|
|
|
ExtensionManager.registerExtensions(store, extensions);
|
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
|
|
|
|
|
window.store = store;
|
|
|
|
|
|
|
|
|
|
function handleServers(servers) {
|
|
|
|
|
if (servers) {
|
|
|
|
|
OHIF.utils.addServers(servers, store);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleOIDC(oidc) {
|
|
|
|
|
if (!oidc) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const oidcClient = oidc[0];
|
|
|
|
|
|
|
|
|
|
const settings = {
|
|
|
|
|
authority: oidcClient.authServerUrl,
|
|
|
|
|
client_id: oidcClient.clientId,
|
|
|
|
|
redirect_uri: oidcClient.authRedirectUri,
|
|
|
|
|
silent_redirect_uri: '/silent-refresh.html',
|
|
|
|
|
post_logout_redirect_uri: oidcClient.postLogoutRedirectUri,
|
|
|
|
|
response_type: oidcClient.responseType,
|
|
|
|
|
scope: 'email profile openid', // Note: Request must have scope 'openid' to be considered an OpenID Connect request
|
|
|
|
|
automaticSilentRenew: true,
|
|
|
|
|
revokeAccessTokenOnSignout: true,
|
|
|
|
|
filterProtocolClaims: true,
|
|
|
|
|
loadUserInfo: true,
|
|
|
|
|
extraQueryParams: oidcClient.extraQueryParams
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const userManager = createUserManager(settings);
|
|
|
|
|
|
|
|
|
|
loadUser(store, userManager);
|
|
|
|
|
|
|
|
|
|
return userManager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleWebWorkerInit(basename) {
|
|
|
|
|
const config = {
|
|
|
|
|
maxWebWorkers: Math.max(navigator.hardwareConcurrency - 1, 1),
|
|
|
|
|
startWebWorkersOnDemand: true,
|
|
|
|
|
webWorkerPath: basename + '/cornerstoneWADOImageLoaderWebWorker.min.js',
|
|
|
|
|
taskConfiguration: {
|
|
|
|
|
decodeTask: {
|
|
|
|
|
loadCodecsOnStartup: true,
|
|
|
|
|
initializeCodecsOnStartup: false,
|
|
|
|
|
codecsPath: basename + '/cornerstoneWADOImageLoaderCodecs.min.js',
|
|
|
|
|
usePDFJS: false,
|
|
|
|
|
strict: false
|
2019-01-17 17:00:21 +01:00
|
|
|
}
|
|
|
|
|
}
|
2019-01-24 10:22:40 +01:00
|
|
|
};
|
2019-01-17 17:00:21 +01:00
|
|
|
|
2019-01-24 10:22:40 +01:00
|
|
|
cornerstoneWADOImageLoader.webWorkerManager.initialize(config);
|
|
|
|
|
}
|
2019-01-17 17:00:21 +01:00
|
|
|
|
|
|
|
|
class App extends Component {
|
2019-01-17 17:39:08 +01:00
|
|
|
static propTypes = {
|
2019-01-30 10:34:55 +01:00
|
|
|
servers: PropTypes.object,
|
2019-01-24 10:22:40 +01:00
|
|
|
oidc: PropTypes.array,
|
2019-01-31 08:55:05 +01:00
|
|
|
routerBasename: PropTypes.string,
|
2019-02-02 12:10:56 +01:00
|
|
|
rootUrl: PropTypes.string,
|
2019-01-31 08:55:05 +01:00
|
|
|
userManager: PropTypes.object,
|
|
|
|
|
location: PropTypes.object
|
2019-01-24 10:22:40 +01:00
|
|
|
};
|
|
|
|
|
|
2019-01-30 12:24:34 +01:00
|
|
|
static defaultProps = {
|
|
|
|
|
whiteLabelling: {}
|
|
|
|
|
};
|
|
|
|
|
|
2019-01-24 10:22:40 +01:00
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
|
|
this.userManager = handleOIDC(this.props.oidc);
|
|
|
|
|
handleServers(this.props.servers);
|
2019-02-02 12:10:56 +01:00
|
|
|
handleWebWorkerInit(this.props.rootUrl);
|
2019-01-17 17:39:08 +01:00
|
|
|
}
|
|
|
|
|
|
2019-01-17 17:00:21 +01:00
|
|
|
render() {
|
2019-01-24 10:22:40 +01:00
|
|
|
const userManager = this.userManager;
|
|
|
|
|
|
|
|
|
|
if (userManager) {
|
|
|
|
|
return (
|
|
|
|
|
<Provider store={store}>
|
|
|
|
|
<OidcProvider store={store} userManager={userManager}>
|
2019-02-02 12:10:56 +01:00
|
|
|
<BrowserRouter basename={this.props.routerBasename}>
|
2019-01-24 14:00:01 +01:00
|
|
|
<WhiteLabellingContext.Provider value={this.props.whiteLabelling}>
|
|
|
|
|
<OHIFStandaloneViewer userManager={userManager} />
|
|
|
|
|
</WhiteLabellingContext.Provider>
|
2019-01-24 10:22:40 +01:00
|
|
|
</BrowserRouter>
|
|
|
|
|
</OidcProvider>
|
|
|
|
|
</Provider>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-17 17:00:21 +01:00
|
|
|
return (
|
|
|
|
|
<Provider store={store}>
|
2019-02-02 12:10:56 +01:00
|
|
|
<BrowserRouter basename={this.props.routerBasename}>
|
2019-01-24 14:00:01 +01:00
|
|
|
<WhiteLabellingContext.Provider value={this.props.whiteLabelling}>
|
|
|
|
|
<OHIFStandaloneViewer />
|
|
|
|
|
</WhiteLabellingContext.Provider>
|
2019-01-24 10:22:40 +01:00
|
|
|
</BrowserRouter>
|
2019-01-17 17:00:21 +01:00
|
|
|
</Provider>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default App;
|