Shift initialization of OHIF classes to app.js

This commit is contained in:
dannyrb 2019-06-02 22:44:13 -04:00
parent c1f8984c1b
commit 6b0ef0904e

View File

@ -8,13 +8,20 @@ import {
} from './utils/index.js'; } from './utils/index.js';
import ConnectedToolContextMenu from './connectedComponents/ConnectedToolContextMenu'; import ConnectedToolContextMenu from './connectedComponents/ConnectedToolContextMenu';
import OHIF from 'ohif-core'; import {
CommandsManager,
HotkeysManager,
extensions,
redux,
utils,
} from 'ohif-core';
import OHIFCornerstoneExtension from '@ohif/extension-cornerstone'; import OHIFCornerstoneExtension from '@ohif/extension-cornerstone';
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 OHIFDicomPDFExtension from 'ohif-dicom-pdf-extension'; import OHIFDicomPDFExtension from 'ohif-dicom-pdf-extension';
import OHIFStandaloneViewer from './OHIFStandaloneViewer'; import OHIFStandaloneViewer from './OHIFStandaloneViewer';
import OHIFVTKExtension from '@ohif/extension-vtk'; import OHIFVTKExtension from '@ohif/extension-vtk';
import appCommands from './appCommands';
import { OidcProvider } from 'redux-oidc'; import { OidcProvider } from 'redux-oidc';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
@ -23,19 +30,21 @@ import WhiteLabellingContext from './WhiteLabellingContext';
import setupTools from './setupTools'; import setupTools from './setupTools';
import store from './store'; import store from './store';
// Register all of our commands and hotkeys // ~~~~ APP SETUP
import commands from './commands'; const _commandsManager = new CommandsManager();
const _hotkeysManager = new HotkeysManager(_commandsManager);
const { ExtensionManager } = OHIF.extensions; appCommands.init(_commandsManager);
commands.init();
// window.config.userPreferences // window.config.userPreferences
Object.keys(window.config.hotkeys).forEach(commandName => { Object.keys(window.config.hotkeys).forEach(commandName => {
const keys = window.config.hotkeys[commandName]; const keys = window.config.hotkeys[commandName];
// OHIF.HotkeysManager.set(); // HotkeysManager.set();
OHIF.HotkeysManager.registerHotkeys(commandName, keys); console.log(`registering hotkey: ${commandName} to binding: ${keys}`);
_hotkeysManager.registerHotkeys(commandName, keys);
}); });
// ~~~~ END EPP SETUP
setupTools(store); setupTools(store);
const children = { const children = {
@ -43,21 +52,20 @@ const children = {
}; };
/** 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 = [ extensions.ExtensionManager.registerExtensions(store, [
new OHIFCornerstoneExtension({ children }), new OHIFCornerstoneExtension({ children }),
new OHIFVTKExtension(), new OHIFVTKExtension(),
new OHIFDicomPDFExtension(), new OHIFDicomPDFExtension(),
new OHIFDicomHtmlExtension(), new OHIFDicomHtmlExtension(),
new OHIFDicomMicroscopyExtension(), new OHIFDicomMicroscopyExtension(),
]; ]);
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); utils.addServers(servers, store);
} }
} }
@ -80,9 +88,7 @@ class App extends Component {
// //
const defaultButtons = getDefaultToolbarButtons(this.props.routerBasename); const defaultButtons = getDefaultToolbarButtons(this.props.routerBasename);
const buttonsAction = OHIF.redux.actions.setAvailableButtons( const buttonsAction = redux.actions.setAvailableButtons(defaultButtons);
defaultButtons
);
store.dispatch(buttonsAction); store.dispatch(buttonsAction);