ohif-viewer/src/config.js

40 lines
1.0 KiB
JavaScript
Raw Normal View History

2019-06-18 20:49:45 +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';
window.info = {
2019-01-30 12:24:34 +01:00
version,
homepage: `${process.env.PUBLIC_URL}`,
2019-05-29 14:39:54 +02: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-05-29 14:39:54 +02:00
cornerstoneWADOImageLoader.external.cornerstone = cornerstone;
cornerstoneWADOImageLoader.external.dicomParser = dicomParser;
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-05-29 14:39:54 +02:00
return state.oidc.user.access_token;
};
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-30 12:24:34 +01:00
if (headers.Authorization) {
2019-05-29 14:39:54 +02:00
xhr.setRequestHeader('Authorization', headers.Authorization);
}
},
2019-05-29 14:39:54 +02:00
});