Skip to content

Commit

Permalink
Add GCP url support (#211)
Browse files Browse the repository at this point in the history
* Add gcp url support

* Fix pathname logic

* Lint
  • Loading branch information
igoroctaviano authored May 27, 2024
1 parent 92d6e06 commit c5a886a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
33 changes: 32 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ function ParametrizedCaseViewer ({ clients, user, app, config }: {
)
}

function _createClientMapping ({ baseUri, settings, onError }: {
function _createClientMapping ({ baseUri, gcpBaseUrl, settings, onError }: {
baseUri: string
gcpBaseUrl: string
settings: ServerSettings[]
onError: (
error: dwc.api.DICOMwebClientError,
Expand All @@ -82,6 +83,12 @@ function _createClientMapping ({ baseUri, settings, onError }: {
}
})
} else {
if (window.location.pathname.includes('/projects/')) {
const pathname = window.location.pathname.split('/study/')[0]
const pathUrl = `${gcpBaseUrl}${pathname}/dicomWeb`
serverSettings.url = pathUrl
}

storageClassMapping.default += 1
clientMapping.default = new DicomWebManager({
baseUri,
Expand Down Expand Up @@ -237,6 +244,7 @@ class App extends React.Component<AppProps, AppState> {
this.state = {
clients: _createClientMapping({
baseUri,
gcpBaseUrl: props.config.gcpBaseUrl ?? 'https://healthcare.googleapis.com/v1',
settings: props.config.servers,
onError: this.handleDICOMwebError
}),
Expand Down Expand Up @@ -495,6 +503,29 @@ class App extends React.Component<AppProps, AppState> {
</Layout>
}
/>
<Route
path='/projects/:project/locations/:location/datasets/:dataset/dicomStores/:dicomStore/study/:studyInstanceUID/*'
element={
<Layout style={layoutStyle}>
<Header
app={appInfo}
user={this.state.user}
showWorklistButton={enableWorklist}
onServerSelection={this.handleServerSelection}
onUserLogout={isLogoutPossible ? onLogout : undefined}
showServerSelectionButton={enableServerSelection}
/>
<Layout.Content style={layoutContentStyle}>
<ParametrizedCaseViewer
clients={this.state.clients}
user={this.state.user}
config={this.props.config}
app={appInfo}
/>
</Layout.Content>
</Layout>
}
/>
<Route
path='/logout'
element={
Expand Down
1 change: 1 addition & 0 deletions src/AppConfig.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default interface AppConfig {
path: string
annotations: AnnotationSettings[]
organization?: string
gcpBaseUrl?: string
oidc?: OidcSettings
disableWorklist?: boolean
disableAnnotationTools?: boolean
Expand Down
13 changes: 11 additions & 2 deletions src/components/CaseViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,21 @@ class Viewer extends React.Component<ViewerProps, ViewerState> {
`/studies/${this.props.studyInstanceUID}` +
`/series/${seriesInstanceUID}`
)

if (this.props.location.pathname.includes('/projects/')) {
urlPath = this.props.location.pathname
if (!this.props.location.pathname.includes('/series/')) {
urlPath += `/series/${seriesInstanceUID}`
}
}

if (
this.props.location.pathname.includes('/series/') &&
this.props.location.search != null
) {
urlPath += this.props.location.search
}

this.props.navigate(urlPath, { replace: true })
}

Expand All @@ -225,8 +234,8 @@ class Viewer extends React.Component<ViewerProps, ViewerState> {
*/
let selectedSeriesInstanceUID: string
if (this.props.location.pathname.includes('series/')) {
const fragments = this.props.location.pathname.split('/')
selectedSeriesInstanceUID = fragments[4]
const seriesFragment = this.props.location.pathname.split('series/')[1]
selectedSeriesInstanceUID = seriesFragment.includes('/') ? seriesFragment.split('/')[0] : seriesFragment
} else {
selectedSeriesInstanceUID = volumeInstances[0].SeriesInstanceUID
}
Expand Down

0 comments on commit c5a886a

Please sign in to comment.