2019-08-13 21:36:46 +02:00
|
|
|
import OHIF from '@ohif/core';
|
2019-05-29 14:39:54 +02:00
|
|
|
import cornerstone from 'cornerstone-core';
|
|
|
|
|
import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader';
|
2019-06-18 20:49:45 +02:00
|
|
|
import dicomParser from 'dicom-parser';
|
2019-05-29 14:39:54 +02:00
|
|
|
import version from './version.js';
|
2019-01-17 17:00:21 +01:00
|
|
|
|
2019-07-29 08:20:07 +02:00
|
|
|
let homepage;
|
|
|
|
|
const { process } = window;
|
|
|
|
|
if (process && process.env && process.env.PUBLIC_URL) {
|
|
|
|
|
homepage = process.env.PUBLIC_URL;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-17 17:00:21 +01:00
|
|
|
window.info = {
|
2019-01-30 12:24:34 +01:00
|
|
|
version,
|
2019-07-29 08:20:07 +02:00
|
|
|
homepage,
|
2019-05-29 14:39:54 +02:00
|
|
|
};
|
2019-01-17 17:00:21 +01:00
|
|
|
|
|
|
|
|
// For debugging
|
2019-06-18 20:49:45 +02:00
|
|
|
//if (process.env.node_env === 'development') {
|
2019-05-29 14:39:54 +02:00
|
|
|
window.cornerstone = cornerstone;
|
|
|
|
|
window.cornerstoneWADOImageLoader = cornerstoneWADOImageLoader;
|
2019-06-18 20:49:45 +02:00
|
|
|
//}
|
2019-01-17 17:00:21 +01:00
|
|
|
|
2019-05-29 14:39:54 +02:00
|
|
|
cornerstoneWADOImageLoader.external.cornerstone = cornerstone;
|
|
|
|
|
cornerstoneWADOImageLoader.external.dicomParser = dicomParser;
|
2019-01-17 17:00:21 +01:00
|
|
|
|
2019-01-30 10:34:55 +01:00
|
|
|
OHIF.user.getAccessToken = () => {
|
2019-01-30 12:24:34 +01:00
|
|
|
// TODO: Get the Redux store from somewhere else
|
2019-05-29 14:39:54 +02:00
|
|
|
const state = window.store.getState();
|
2019-01-30 12:24:34 +01:00
|
|
|
if (!state.oidc || !state.oidc.user) {
|
2019-05-29 14:39:54 +02:00
|
|
|
return;
|
2019-01-30 12:24:34 +01:00
|
|
|
}
|
2019-01-17 17:00:21 +01:00
|
|
|
|
2019-05-29 14:39:54 +02:00
|
|
|
return state.oidc.user.access_token;
|
|
|
|
|
};
|
2019-01-17 17:00:21 +01:00
|
|
|
|
2019-01-30 10:34:55 +01:00
|
|
|
cornerstoneWADOImageLoader.configure({
|
2019-01-30 12:24:34 +01:00
|
|
|
beforeSend: function(xhr) {
|
2019-05-29 14:39:54 +02:00
|
|
|
const headers = OHIF.DICOMWeb.getAuthorizationHeader();
|
2019-01-17 17:00:21 +01:00
|
|
|
|
2019-01-30 12:24:34 +01:00
|
|
|
if (headers.Authorization) {
|
2019-05-29 14:39:54 +02:00
|
|
|
xhr.setRequestHeader('Authorization', headers.Authorization);
|
2019-01-30 10:34:55 +01:00
|
|
|
}
|
2019-04-28 21:14:20 +02:00
|
|
|
},
|
2019-05-29 14:39:54 +02:00
|
|
|
});
|