fix(dicomWebClient): use public getter for activeDataSourceName instead of accessing private property (#4973)

This commit is contained in:
Pedro Köhler 2025-04-18 12:33:42 -03:00 committed by GitHub
parent f02ce22ae3
commit 5688a2b4b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 18 deletions

View File

@ -11,7 +11,7 @@ import { StaticWadoClient } from '@ohif/extension-default';
*/ */
export default function getDicomWebClient({ extensionManager, servicesManager }: withAppTypes) { export default function getDicomWebClient({ extensionManager, servicesManager }: withAppTypes) {
const dataSourceConfig = window.config.dataSources.find( const dataSourceConfig = window.config.dataSources.find(
ds => ds.sourceName === extensionManager.activeDataSource ds => ds.sourceName === extensionManager.activeDataSourceName
); );
const { userAuthenticationService } = servicesManager.services; const { userAuthenticationService } = servicesManager.services;
@ -28,7 +28,7 @@ export default function getDicomWebClient({ extensionManager, servicesManager }:
const client = new StaticWadoClient(wadoConfig); const client = new StaticWadoClient(wadoConfig);
client.wadoURL = wadoConfig.url; client.wadoURL = wadoConfig.url;
if (extensionManager.activeDataSource === 'dicomlocal') { if (extensionManager.activeDataSourceName === 'dicomlocal') {
/** /**
* For local data source, override the retrieveInstanceFrames() method of the * For local data source, override the retrieveInstanceFrames() method of the
* dicomweb-client to retrieve image data from memory cached metadata. * dicomweb-client to retrieve image data from memory cached metadata.

View File

@ -87,7 +87,7 @@ export default class ExtensionManager extends PubSubService {
}; };
private dataSourceMap: Record<string, any>; private dataSourceMap: Record<string, any>;
private dataSourceDefs: Record<string, any>; private dataSourceDefs: Record<string, any>;
private activeDataSourceName: string; private _activeDataSourceName: string;
constructor({ constructor({
commandsManager, commandsManager,
@ -115,20 +115,20 @@ export default class ExtensionManager extends PubSubService {
this.dataSourceMap = {}; this.dataSourceMap = {};
this.dataSourceDefs = {}; this.dataSourceDefs = {};
this.defaultDataSourceName = appConfig.defaultDataSourceName; this.defaultDataSourceName = appConfig.defaultDataSourceName;
this.activeDataSourceName = appConfig.defaultDataSourceName; this._activeDataSourceName = appConfig.defaultDataSourceName;
this.peerImport = appConfig.peerImport; this.peerImport = appConfig.peerImport;
} }
public setActiveDataSource(dataSource: string): void { public setActiveDataSource(dataSource: string): void {
if (this.activeDataSourceName === dataSource) { if (this._activeDataSourceName === dataSource) {
return; return;
} }
this.activeDataSourceName = dataSource; this._activeDataSourceName = dataSource;
this._broadcastEvent( this._broadcastEvent(
ExtensionManager.EVENTS.ACTIVE_DATA_SOURCE_CHANGED, ExtensionManager.EVENTS.ACTIVE_DATA_SOURCE_CHANGED,
this.dataSourceDefs[this.activeDataSourceName] this.dataSourceDefs[this._activeDataSourceName]
); );
} }
@ -373,7 +373,7 @@ export default class ExtensionManager extends PubSubService {
getDataSources = dataSourceName => { getDataSources = dataSourceName => {
if (!dataSourceName) { if (!dataSourceName) {
// Default to the activeDataSource // Default to the activeDataSource
dataSourceName = this.activeDataSourceName; dataSourceName = this._activeDataSourceName;
} }
// Note: this currently uses the data source name, which feels weird... // Note: this currently uses the data source name, which feels weird...
@ -385,7 +385,7 @@ export default class ExtensionManager extends PubSubService {
}; };
getActiveDataSource = () => { getActiveDataSource = () => {
return this.dataSourceMap[this.activeDataSourceName]; return this.dataSourceMap[this._activeDataSourceName];
}; };
/** /**
@ -398,7 +398,7 @@ export default class ExtensionManager extends PubSubService {
getDataSourceDefinition = dataSourceName => { getDataSourceDefinition = dataSourceName => {
if (dataSourceName === undefined) { if (dataSourceName === undefined) {
// Default to the activeDataSource // Default to the activeDataSource
dataSourceName = this.activeDataSourceName; dataSourceName = this._activeDataSourceName;
} }
return this.dataSourceDefs[dataSourceName]; return this.dataSourceDefs[dataSourceName];
@ -408,7 +408,7 @@ export default class ExtensionManager extends PubSubService {
* Gets the data source definition for the active data source. * Gets the data source definition for the active data source.
*/ */
getActiveDataSourceDefinition = () => { getActiveDataSourceDefinition = () => {
return this.getDataSourceDefinition(this.activeDataSourceName); return this.getDataSourceDefinition(this._activeDataSourceName);
}; };
/** /**
@ -425,16 +425,18 @@ export default class ExtensionManager extends PubSubService {
const inactiveDataSourceNames = Object.keys(this.dataSourceMap).filter(ds => { const inactiveDataSourceNames = Object.keys(this.dataSourceMap).filter(ds => {
const configuration = this.dataSourceDefs[ds]?.configuration; const configuration = this.dataSourceDefs[ds]?.configuration;
const isNotActiveDataSource = const isNotActiveDataSource =
this.dataSourceDefs[ds].sourceName !== this.activeDataSourceName; this.dataSourceDefs[ds].sourceName !== this._activeDataSourceName;
const supportsStowOrWado = configuration?.supportsStow ?? configuration?.wadoRoot; const supportsStowOrWado = configuration?.supportsStow ?? configuration?.wadoRoot;
return supportsStowOrWado && isNotActiveDataSource; return supportsStowOrWado && isNotActiveDataSource;
}); });
const allDatasourcesForUI = [this.activeDataSourceName, ...inactiveDataSourceNames].map(ds => ({ const allDatasourcesForUI = [this._activeDataSourceName, ...inactiveDataSourceNames].map(
value: ds, ds => ({
label: ds, value: ds,
placeHolder: ds, label: ds,
})); placeHolder: ds,
})
);
return allDatasourcesForUI; return allDatasourcesForUI;
}; };
@ -558,7 +560,7 @@ export default class ExtensionManager extends PubSubService {
dataSourceDef.configuration = dataSourceConfiguration; dataSourceDef.configuration = dataSourceConfiguration;
this._createDataSourceInstance(dataSourceDef); this._createDataSourceInstance(dataSourceDef);
if (this.activeDataSourceName === dataSourceName) { if (this._activeDataSourceName === dataSourceName) {
// When the active data source is changed/set, fire an event to indicate that its configuration has changed. // When the active data source is changed/set, fire an event to indicate that its configuration has changed.
this._broadcastEvent(ExtensionManager.EVENTS.ACTIVE_DATA_SOURCE_CHANGED, dataSourceDef); this._broadcastEvent(ExtensionManager.EVENTS.ACTIVE_DATA_SOURCE_CHANGED, dataSourceDef);
} }
@ -649,6 +651,10 @@ export default class ExtensionManager extends PubSubService {
public get appConfig() { public get appConfig() {
return this._appConfig; return this._appConfig;
} }
public get activeDataSourceName() {
return this._activeDataSourceName;
}
} }
/** /**