Formatting; rename BrowserRouter to Router
This commit is contained in:
parent
c94c8003d7
commit
fbd75ed1e7
172
src/App.js
172
src/App.js
@ -1,42 +1,42 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react'
|
||||||
import { BrowserRouter } from 'react-router-dom';
|
import { BrowserRouter as Router } from 'react-router-dom'
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux'
|
||||||
import { createStore, combineReducers } from 'redux';
|
import { createStore, combineReducers } from 'redux'
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types'
|
||||||
import OHIF from 'ohif-core';
|
import OHIF from 'ohif-core'
|
||||||
import './config';
|
import './config'
|
||||||
import ui from './redux/ui.js';
|
import ui from './redux/ui.js'
|
||||||
import OHIFStandaloneViewer from './OHIFStandaloneViewer';
|
import OHIFStandaloneViewer from './OHIFStandaloneViewer'
|
||||||
import WhiteLabellingContext from './WhiteLabellingContext';
|
import WhiteLabellingContext from './WhiteLabellingContext'
|
||||||
import OHIFCornerstoneExtension from 'ohif-cornerstone-extension';
|
import OHIFCornerstoneExtension from 'ohif-cornerstone-extension'
|
||||||
import OHIFVTKExtension from 'ohif-vtk-extension';
|
import OHIFVTKExtension from 'ohif-vtk-extension'
|
||||||
import OHIFDicomPDFExtension from 'ohif-dicom-pdf-extension';
|
import OHIFDicomPDFExtension from 'ohif-dicom-pdf-extension'
|
||||||
import OHIFDicomHtmlExtension from 'ohif-dicom-html-extension';
|
import OHIFDicomHtmlExtension from 'ohif-dicom-html-extension'
|
||||||
import OHIFDicomMicroscopyExtension from 'ohif-dicom-microscopy-extension';
|
import OHIFDicomMicroscopyExtension from 'ohif-dicom-microscopy-extension'
|
||||||
import {
|
import {
|
||||||
loadUser,
|
loadUser,
|
||||||
OidcProvider,
|
OidcProvider,
|
||||||
createUserManager,
|
createUserManager,
|
||||||
reducer as oidcReducer
|
reducer as oidcReducer,
|
||||||
} from 'redux-oidc';
|
} from 'redux-oidc'
|
||||||
import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader';
|
import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader'
|
||||||
|
|
||||||
const { ExtensionManager } = OHIF.extensions;
|
const { ExtensionManager } = OHIF.extensions
|
||||||
|
|
||||||
const Icons = 'icons.svg';
|
const Icons = 'icons.svg'
|
||||||
|
|
||||||
const { reducers, localStorage } = OHIF.redux;
|
const { reducers, localStorage } = OHIF.redux
|
||||||
reducers.ui = ui;
|
reducers.ui = ui
|
||||||
reducers.oidc = oidcReducer;
|
reducers.oidc = oidcReducer
|
||||||
|
|
||||||
const combined = combineReducers(reducers);
|
const combined = combineReducers(reducers)
|
||||||
const store = createStore(combined, localStorage.loadState());
|
const store = createStore(combined, localStorage.loadState())
|
||||||
|
|
||||||
store.subscribe(() => {
|
store.subscribe(() => {
|
||||||
localStorage.saveState({
|
localStorage.saveState({
|
||||||
preferences: store.getState().preferences
|
preferences: store.getState().preferences,
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
const defaultButtons = [
|
const defaultButtons = [
|
||||||
{
|
{
|
||||||
@ -44,35 +44,35 @@ const defaultButtons = [
|
|||||||
type: 'tool',
|
type: 'tool',
|
||||||
text: 'Stack Scroll',
|
text: 'Stack Scroll',
|
||||||
svgUrl: `${Icons}#icon-tools-stack-scroll`,
|
svgUrl: `${Icons}#icon-tools-stack-scroll`,
|
||||||
active: false
|
active: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'Zoom',
|
command: 'Zoom',
|
||||||
type: 'tool',
|
type: 'tool',
|
||||||
text: 'Zoom',
|
text: 'Zoom',
|
||||||
svgUrl: `${Icons}#icon-tools-zoom`,
|
svgUrl: `${Icons}#icon-tools-zoom`,
|
||||||
active: false
|
active: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'Wwwc',
|
command: 'Wwwc',
|
||||||
type: 'tool',
|
type: 'tool',
|
||||||
text: 'Levels',
|
text: 'Levels',
|
||||||
svgUrl: `${Icons}#icon-tools-levels`,
|
svgUrl: `${Icons}#icon-tools-levels`,
|
||||||
active: true
|
active: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'Pan',
|
command: 'Pan',
|
||||||
type: 'tool',
|
type: 'tool',
|
||||||
text: 'Pan',
|
text: 'Pan',
|
||||||
svgUrl: `${Icons}#icon-tools-pan`,
|
svgUrl: `${Icons}#icon-tools-pan`,
|
||||||
active: false
|
active: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'Length',
|
command: 'Length',
|
||||||
type: 'tool',
|
type: 'tool',
|
||||||
text: 'Length',
|
text: 'Length',
|
||||||
svgUrl: `${Icons}#icon-tools-measure-temp`,
|
svgUrl: `${Icons}#icon-tools-measure-temp`,
|
||||||
active: false
|
active: false,
|
||||||
},
|
},
|
||||||
/*{
|
/*{
|
||||||
command: 'Annotate',
|
command: 'Annotate',
|
||||||
@ -86,41 +86,41 @@ const defaultButtons = [
|
|||||||
type: 'tool',
|
type: 'tool',
|
||||||
text: 'Angle',
|
text: 'Angle',
|
||||||
iconClasses: 'fa fa-angle-left',
|
iconClasses: 'fa fa-angle-left',
|
||||||
active: false
|
active: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'Bidirectional',
|
command: 'Bidirectional',
|
||||||
type: 'tool',
|
type: 'tool',
|
||||||
text: 'Bidirectional',
|
text: 'Bidirectional',
|
||||||
svgUrl: `${Icons}#icon-tools-measure-target`,
|
svgUrl: `${Icons}#icon-tools-measure-target`,
|
||||||
active: false
|
active: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'Brush',
|
command: 'Brush',
|
||||||
type: 'tool',
|
type: 'tool',
|
||||||
text: 'Brush',
|
text: 'Brush',
|
||||||
iconClasses: 'fa fa-circle',
|
iconClasses: 'fa fa-circle',
|
||||||
active: false
|
active: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'FreehandMouse',
|
command: 'FreehandMouse',
|
||||||
type: 'tool',
|
type: 'tool',
|
||||||
text: 'Freehand',
|
text: 'Freehand',
|
||||||
iconClasses: 'fa fa-star',
|
iconClasses: 'fa fa-star',
|
||||||
active: false
|
active: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: 'reset',
|
command: 'reset',
|
||||||
type: 'command',
|
type: 'command',
|
||||||
text: 'Reset',
|
text: 'Reset',
|
||||||
svgUrl: `${Icons}#icon-tools-reset`,
|
svgUrl: `${Icons}#icon-tools-reset`,
|
||||||
active: false
|
active: false,
|
||||||
}
|
},
|
||||||
];
|
]
|
||||||
|
|
||||||
const buttonsAction = OHIF.redux.actions.setAvailableButtons(defaultButtons);
|
const buttonsAction = OHIF.redux.actions.setAvailableButtons(defaultButtons)
|
||||||
|
|
||||||
store.dispatch(buttonsAction);
|
store.dispatch(buttonsAction)
|
||||||
|
|
||||||
const availableTools = [
|
const availableTools = [
|
||||||
{ name: 'Pan', mouseButtonMasks: [1, 4] },
|
{ name: 'Pan', mouseButtonMasks: [1, 4] },
|
||||||
@ -135,14 +135,14 @@ const availableTools = [
|
|||||||
{ name: 'PanMultiTouch' },
|
{ name: 'PanMultiTouch' },
|
||||||
{ name: 'ZoomTouchPinch' },
|
{ name: 'ZoomTouchPinch' },
|
||||||
{ name: 'StackScrollMouseWheel' },
|
{ name: 'StackScrollMouseWheel' },
|
||||||
{ name: 'StackScrollMultiTouch' }
|
{ name: 'StackScrollMultiTouch' },
|
||||||
];
|
]
|
||||||
|
|
||||||
const toolAction = OHIF.redux.actions.setExtensionData('cornerstone', {
|
const toolAction = OHIF.redux.actions.setExtensionData('cornerstone', {
|
||||||
availableTools
|
availableTools,
|
||||||
});
|
})
|
||||||
|
|
||||||
store.dispatch(toolAction);
|
store.dispatch(toolAction)
|
||||||
|
|
||||||
/** TODO: extensions should be passed in as prop as soon as we have the extensions as separate packages and then registered by ExtensionsManager */
|
/** TODO: extensions should be passed in as prop as soon as we have the extensions as separate packages and then registered by ExtensionsManager */
|
||||||
const extensions = [
|
const extensions = [
|
||||||
@ -150,25 +150,25 @@ const extensions = [
|
|||||||
new OHIFVTKExtension(),
|
new OHIFVTKExtension(),
|
||||||
new OHIFDicomPDFExtension(),
|
new OHIFDicomPDFExtension(),
|
||||||
new OHIFDicomHtmlExtension(),
|
new OHIFDicomHtmlExtension(),
|
||||||
new OHIFDicomMicroscopyExtension()
|
new OHIFDicomMicroscopyExtension(),
|
||||||
];
|
]
|
||||||
ExtensionManager.registerExtensions(store, extensions);
|
ExtensionManager.registerExtensions(store, extensions)
|
||||||
|
|
||||||
// TODO[react] Use a provider when the whole tree is React
|
// TODO[react] Use a provider when the whole tree is React
|
||||||
window.store = store;
|
window.store = store
|
||||||
|
|
||||||
function handleServers(servers) {
|
function handleServers(servers) {
|
||||||
if (servers) {
|
if (servers) {
|
||||||
OHIF.utils.addServers(servers, store);
|
OHIF.utils.addServers(servers, store)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleOIDC(oidc) {
|
function handleOIDC(oidc) {
|
||||||
if (!oidc) {
|
if (!oidc) {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const oidcClient = oidc[0];
|
const oidcClient = oidc[0]
|
||||||
|
|
||||||
const settings = {
|
const settings = {
|
||||||
authority: oidcClient.authServerUrl,
|
authority: oidcClient.authServerUrl,
|
||||||
@ -182,14 +182,14 @@ function handleOIDC(oidc) {
|
|||||||
revokeAccessTokenOnSignout: true,
|
revokeAccessTokenOnSignout: true,
|
||||||
filterProtocolClaims: true,
|
filterProtocolClaims: true,
|
||||||
loadUserInfo: true,
|
loadUserInfo: true,
|
||||||
extraQueryParams: oidcClient.extraQueryParams
|
extraQueryParams: oidcClient.extraQueryParams,
|
||||||
};
|
}
|
||||||
|
|
||||||
const userManager = createUserManager(settings);
|
const userManager = createUserManager(settings)
|
||||||
|
|
||||||
loadUser(store, userManager);
|
loadUser(store, userManager)
|
||||||
|
|
||||||
return userManager;
|
return userManager
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleWebWorkerInit(basename) {
|
function handleWebWorkerInit(basename) {
|
||||||
@ -203,12 +203,12 @@ function handleWebWorkerInit(basename) {
|
|||||||
initializeCodecsOnStartup: false,
|
initializeCodecsOnStartup: false,
|
||||||
codecsPath: basename + '/cornerstoneWADOImageLoaderCodecs.min.js',
|
codecsPath: basename + '/cornerstoneWADOImageLoaderCodecs.min.js',
|
||||||
usePDFJS: false,
|
usePDFJS: false,
|
||||||
strict: false
|
strict: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
cornerstoneWADOImageLoader.webWorkerManager.initialize(config);
|
cornerstoneWADOImageLoader.webWorkerManager.initialize(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -218,16 +218,16 @@ function handleWebWorkerInit(basename) {
|
|||||||
* @param rootUrl
|
* @param rootUrl
|
||||||
*/
|
*/
|
||||||
function updateBaseTag(rootUrl) {
|
function updateBaseTag(rootUrl) {
|
||||||
const bases = document.getElementsByTagName('base');
|
const bases = document.getElementsByTagName('base')
|
||||||
let baseHref = rootUrl;
|
let baseHref = rootUrl
|
||||||
baseHref += baseHref.endsWith('/') ? '' : '/';
|
baseHref += baseHref.endsWith('/') ? '' : '/'
|
||||||
|
|
||||||
if (bases.length > 1) {
|
if (bases.length > 1) {
|
||||||
throw new Error('For some reason there is more than one base tag present.');
|
throw new Error('For some reason there is more than one base tag present.')
|
||||||
} else if (bases.length === 1) {
|
} else if (bases.length === 1) {
|
||||||
bases[0].href = baseHref;
|
bases[0].href = baseHref
|
||||||
} else {
|
} else {
|
||||||
document.write(`<base href='${baseHref}'/>`);
|
document.write(`<base href='${baseHref}'/>`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,49 +238,49 @@ class App extends Component {
|
|||||||
routerBasename: PropTypes.string,
|
routerBasename: PropTypes.string,
|
||||||
rootUrl: PropTypes.string,
|
rootUrl: PropTypes.string,
|
||||||
userManager: PropTypes.object,
|
userManager: PropTypes.object,
|
||||||
location: PropTypes.object
|
location: PropTypes.object,
|
||||||
};
|
}
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
whiteLabelling: {}
|
whiteLabelling: {},
|
||||||
};
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props)
|
||||||
|
|
||||||
this.userManager = handleOIDC(this.props.oidc);
|
this.userManager = handleOIDC(this.props.oidc)
|
||||||
handleServers(this.props.servers);
|
handleServers(this.props.servers)
|
||||||
handleWebWorkerInit(this.props.rootUrl);
|
handleWebWorkerInit(this.props.rootUrl)
|
||||||
updateBaseTag(this.props.rootUrl);
|
updateBaseTag(this.props.rootUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const userManager = this.userManager;
|
const userManager = this.userManager
|
||||||
|
|
||||||
if (userManager) {
|
if (userManager) {
|
||||||
return (
|
return (
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<OidcProvider store={store} userManager={userManager}>
|
<OidcProvider store={store} userManager={userManager}>
|
||||||
<BrowserRouter basename={this.props.routerBasename}>
|
<Router basename={this.props.routerBasename}>
|
||||||
<WhiteLabellingContext.Provider value={this.props.whiteLabelling}>
|
<WhiteLabellingContext.Provider value={this.props.whiteLabelling}>
|
||||||
<OHIFStandaloneViewer userManager={userManager} />
|
<OHIFStandaloneViewer userManager={userManager} />
|
||||||
</WhiteLabellingContext.Provider>
|
</WhiteLabellingContext.Provider>
|
||||||
</BrowserRouter>
|
</Router>
|
||||||
</OidcProvider>
|
</OidcProvider>
|
||||||
</Provider>
|
</Provider>
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<BrowserRouter basename={this.props.routerBasename}>
|
<Router basename={this.props.routerBasename}>
|
||||||
<WhiteLabellingContext.Provider value={this.props.whiteLabelling}>
|
<WhiteLabellingContext.Provider value={this.props.whiteLabelling}>
|
||||||
<OHIFStandaloneViewer />
|
<OHIFStandaloneViewer />
|
||||||
</WhiteLabellingContext.Provider>
|
</WhiteLabellingContext.Provider>
|
||||||
</BrowserRouter>
|
</Router>
|
||||||
</Provider>
|
</Provider>
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default App;
|
export default App
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user