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';
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 OHIFDicomHtmlExtension from 'ohif-dicom-html-extension';
import OHIFDicomMicroscopyExtension from 'ohif-dicom-microscopy-extension';
import OHIFDicomPDFExtension from 'ohif-dicom-pdf-extension';
import OHIFStandaloneViewer from './OHIFStandaloneViewer';
import OHIFVTKExtension from '@ohif/extension-vtk';
import appCommands from './appCommands';
import { OidcProvider } from 'redux-oidc';
import PropTypes from 'prop-types';
import { Provider } from 'react-redux';
@ -23,19 +30,21 @@ import WhiteLabellingContext from './WhiteLabellingContext';
import setupTools from './setupTools';
import store from './store';
// Register all of our commands and hotkeys
import commands from './commands';
// ~~~~ APP SETUP
const _commandsManager = new CommandsManager();
const _hotkeysManager = new HotkeysManager(_commandsManager);
const { ExtensionManager } = OHIF.extensions;
commands.init();
appCommands.init(_commandsManager);
// window.config.userPreferences
Object.keys(window.config.hotkeys).forEach(commandName => {
const keys = window.config.hotkeys[commandName];
// OHIF.HotkeysManager.set();
OHIF.HotkeysManager.registerHotkeys(commandName, keys);
// HotkeysManager.set();
console.log(`registering hotkey: ${commandName} to binding: ${keys}`);
_hotkeysManager.registerHotkeys(commandName, keys);
});
// ~~~~ END EPP SETUP
setupTools(store);
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 */
const extensions = [
extensions.ExtensionManager.registerExtensions(store, [
new OHIFCornerstoneExtension({ children }),
new OHIFVTKExtension(),
new OHIFDicomPDFExtension(),
new OHIFDicomHtmlExtension(),
new OHIFDicomMicroscopyExtension(),
];
ExtensionManager.registerExtensions(store, extensions);
]);
// TODO[react] Use a provider when the whole tree is React
window.store = store;
function handleServers(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 buttonsAction = OHIF.redux.actions.setAvailableButtons(
defaultButtons
);
const buttonsAction = redux.actions.setAvailableButtons(defaultButtons);
store.dispatch(buttonsAction);