@@ -158,6 +158,7 @@ interface AppProps {
158158
159159interface AppState {
160160 clients : { [ sopClassUID : string ] : DicomWebManager }
161+ defaultClients : { [ sopClassUID : string ] : DicomWebManager }
161162 user ?: User
162163 isLoading : boolean
163164 redirectTo ?: string
@@ -249,13 +250,16 @@ class App extends React.Component<AppProps, AppState> {
249250 message . config ( { duration : 5 } )
250251 this . addGcpSecondaryAnnotationServer ( props . config )
251252
253+ const defaultClients = _createClientMapping ( {
254+ baseUri,
255+ gcpBaseUrl : props . config . gcpBaseUrl ?? 'https://healthcare.googleapis.com/v1' ,
256+ settings : props . config . servers ,
257+ onError : this . handleDICOMwebError
258+ } )
259+
252260 this . state = {
253- clients : _createClientMapping ( {
254- baseUri,
255- gcpBaseUrl : props . config . gcpBaseUrl ?? 'https://healthcare.googleapis.com/v1' ,
256- settings : props . config . servers ,
257- onError : this . handleDICOMwebError
258- } ) ,
261+ clients : defaultClients ,
262+ defaultClients,
259263 isLoading : true ,
260264 wasAuthSuccessful : false
261265 }
@@ -290,6 +294,11 @@ class App extends React.Component<AppProps, AppState> {
290294
291295 handleServerSelection ( { url } : { url : string } ) : void {
292296 console . info ( 'select DICOMweb server: ' , url )
297+ if ( url === '' || window . localStorage . getItem ( 'slim_server_selection_mode' ) === 'default' ) {
298+ this . setState ( { clients : this . state . defaultClients } )
299+ return
300+ }
301+ window . localStorage . setItem ( 'slim_selected_server' , url )
293302 const tmpClient = new DicomWebManager ( {
294303 baseUri : '' ,
295304 settings : [ {
@@ -334,11 +343,11 @@ class App extends React.Component<AppProps, AppState> {
334343 }
335344 const storedPath = window . localStorage . getItem ( 'slim_path' )
336345 const storedSearch = window . localStorage . getItem ( 'slim_search' )
337- if ( storedPath != null ) {
346+ if ( storedPath !== null && storedPath !== '' ) {
338347 const currentPath = window . location . pathname
339348 if ( storedPath !== currentPath ) {
340349 let path = storedPath
341- if ( storedSearch != null ) {
350+ if ( storedSearch !== null && storedSearch !== '' ) {
342351 path += storedSearch
343352 }
344353 window . location . href = path
@@ -384,10 +393,17 @@ class App extends React.Component<AppProps, AppState> {
384393
385394 componentDidMount ( ) : void {
386395 const path = window . localStorage . getItem ( 'slim_path' )
387- if ( path == null ) {
396+ if ( path === null || path === '' ) {
388397 window . localStorage . setItem ( 'slim_path' , window . location . pathname )
389398 window . localStorage . setItem ( 'slim_search' , window . location . search )
390399 }
400+
401+ // Restore cached server selection if it exists
402+ const cachedServerUrl = window . localStorage . getItem ( 'slim_selected_server' )
403+ if ( cachedServerUrl !== null && cachedServerUrl !== '' ) {
404+ this . handleServerSelection ( { url : cachedServerUrl } )
405+ }
406+
391407 this . signIn ( )
392408 }
393409
@@ -454,6 +470,7 @@ class App extends React.Component<AppProps, AppState> {
454470 showServerSelectionButton = { false }
455471 appConfig = { this . props . config }
456472 clients = { this . state . clients }
473+ defaultClients = { this . state . defaultClients }
457474 />
458475 < Layout . Content style = { layoutContentStyle } >
459476 < FaSpinner />
@@ -485,6 +502,8 @@ class App extends React.Component<AppProps, AppState> {
485502 onUserLogout = { isLogoutPossible ? onLogout : undefined }
486503 showServerSelectionButton = { enableServerSelection }
487504 appConfig = { this . props . config }
505+ clients = { this . state . clients }
506+ defaultClients = { this . state . defaultClients }
488507 />
489508 < Layout . Content style = { layoutContentStyle } >
490509 { worklist }
@@ -504,6 +523,8 @@ class App extends React.Component<AppProps, AppState> {
504523 onUserLogout = { isLogoutPossible ? onLogout : undefined }
505524 showServerSelectionButton = { enableServerSelection }
506525 appConfig = { this . props . config }
526+ clients = { this . state . clients }
527+ defaultClients = { this . state . defaultClients }
507528 />
508529 < Layout . Content style = { layoutContentStyle } >
509530 < ParametrizedCaseViewer
@@ -528,6 +549,8 @@ class App extends React.Component<AppProps, AppState> {
528549 onUserLogout = { isLogoutPossible ? onLogout : undefined }
529550 showServerSelectionButton = { enableServerSelection }
530551 appConfig = { this . props . config }
552+ clients = { this . state . clients }
553+ defaultClients = { this . state . defaultClients }
531554 />
532555 < Layout . Content style = { layoutContentStyle } >
533556 < ParametrizedCaseViewer
@@ -552,6 +575,8 @@ class App extends React.Component<AppProps, AppState> {
552575 onUserLogout = { isLogoutPossible ? onLogout : undefined }
553576 showServerSelectionButton = { enableServerSelection }
554577 appConfig = { this . props . config }
578+ clients = { this . state . clients }
579+ defaultClients = { this . state . defaultClients }
555580 />
556581 Logged out
557582 </ Layout >
0 commit comments