Nuke root url
This commit is contained in:
parent
1d7ddd5bf5
commit
319af9bde3
@ -1,6 +1,8 @@
|
||||
window.config = {
|
||||
// default: '/'
|
||||
routerBasename: '/',
|
||||
rootUrl: 'http://localhost:5000',
|
||||
// default: ''
|
||||
relativeWebWorkerScriptsPath: '',
|
||||
servers: {
|
||||
dicomWeb: [
|
||||
{
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
window.config = {
|
||||
// default: '/'
|
||||
routerBasename: '/demo',
|
||||
rootUrl: '/demo',
|
||||
// default: '/'
|
||||
relativeWebWorkerScriptsPath: '',
|
||||
servers: {
|
||||
dicomWeb: [
|
||||
{
|
||||
|
||||
31
src/App.js
31
src/App.js
@ -192,16 +192,22 @@ function handleOIDC(oidc) {
|
||||
return userManager
|
||||
}
|
||||
|
||||
function handleWebWorkerInit(basename) {
|
||||
/**
|
||||
*
|
||||
* @param {String} baseDirectory
|
||||
* @param {String} webWorkScriptsPath
|
||||
*/
|
||||
function handleWebWorkerInit(baseDirectory, webWorkScriptsPath) {
|
||||
const scriptsPath = `${baseDirectory}/${webWorkScriptsPath}`
|
||||
const config = {
|
||||
maxWebWorkers: Math.max(navigator.hardwareConcurrency - 1, 1),
|
||||
startWebWorkersOnDemand: true,
|
||||
webWorkerPath: basename + '/cornerstoneWADOImageLoaderWebWorker.min.js',
|
||||
webWorkerPath: `${scriptsPath}/cornerstoneWADOImageLoaderWebWorker.min.js`,
|
||||
taskConfiguration: {
|
||||
decodeTask: {
|
||||
loadCodecsOnStartup: true,
|
||||
initializeCodecsOnStartup: false,
|
||||
codecsPath: basename + '/cornerstoneWADOImageLoaderCodecs.min.js',
|
||||
codecsPath: `${scriptsPath}/cornerstoneWADOImageLoaderCodecs.min.js`,
|
||||
usePDFJS: false,
|
||||
strict: false,
|
||||
},
|
||||
@ -213,13 +219,14 @@ function handleWebWorkerInit(basename) {
|
||||
|
||||
/**
|
||||
* Set or update the HTML Base tag present on the document
|
||||
* to point to the provided ROOT Url.
|
||||
*
|
||||
* @param rootUrl
|
||||
*/
|
||||
function updateBaseTag(rootUrl) {
|
||||
function updateBaseTag(baseDirectory = '') {
|
||||
const bases = document.getElementsByTagName('base')
|
||||
let baseHref = rootUrl
|
||||
let baseHref = `${window.location.scheme}${
|
||||
window.location.host
|
||||
}${baseDirectory}`
|
||||
baseHref += baseHref.endsWith('/') ? '' : '/'
|
||||
|
||||
if (bases.length > 1) {
|
||||
@ -233,10 +240,11 @@ function updateBaseTag(rootUrl) {
|
||||
|
||||
class App extends Component {
|
||||
static propTypes = {
|
||||
routerBasename: PropTypes.string,
|
||||
relativeWebWorkerScriptsPath: PropTypes.string,
|
||||
//
|
||||
servers: PropTypes.object,
|
||||
oidc: PropTypes.array,
|
||||
routerBasename: PropTypes.string,
|
||||
rootUrl: PropTypes.string,
|
||||
userManager: PropTypes.object,
|
||||
location: PropTypes.object,
|
||||
}
|
||||
@ -250,8 +258,11 @@ class App extends Component {
|
||||
|
||||
this.userManager = handleOIDC(this.props.oidc)
|
||||
handleServers(this.props.servers)
|
||||
handleWebWorkerInit(this.props.rootUrl)
|
||||
updateBaseTag(this.props.rootUrl)
|
||||
handleWebWorkerInit(
|
||||
this.props.routerBasename,
|
||||
this.props.relativeWebWorkerScriptsPath
|
||||
)
|
||||
updateBaseTag(this.props.routerBasename)
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@ -8,7 +8,12 @@ import ReactDOM from 'react-dom'
|
||||
|
||||
export { App }
|
||||
|
||||
const applicationProps = window.config
|
||||
window.config = window.config || {}
|
||||
const applicationDefaults = {
|
||||
routerBasename: '/',
|
||||
relativeWebWorkerScriptsPath: '',
|
||||
}
|
||||
const applicationProps = Object.assign({}, applicationDefaults, window.config)
|
||||
const app = React.createElement(App, applicationProps, null)
|
||||
|
||||
ReactDOM.render(app, document.getElementById('root'))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user