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