fix: make datasource selection work (#4944)
This commit is contained in:
parent
ffc7ab6845
commit
a9b180c5d4
@ -1,5 +1,5 @@
|
|||||||
import React, { useEffect, useMemo, useState } from 'react';
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { InputDialog, cn } from '@ohif/ui-next';
|
import { InputDialog } from '@ohif/ui-next';
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@ohif/ui-next';
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@ohif/ui-next';
|
||||||
import { useSystem } from '@ohif/core';
|
import { useSystem } from '@ohif/core';
|
||||||
|
|
||||||
@ -54,19 +54,19 @@ function ReportDialog({ dataSources, hide, onSave, onCancel }: ReportDialogProps
|
|||||||
setReportName(newReportName);
|
setReportName(newReportName);
|
||||||
}, [selectedSeries, seriesOptions]);
|
}, [selectedSeries, seriesOptions]);
|
||||||
|
|
||||||
const handleSave = () => {
|
const handleSave = useCallback(() => {
|
||||||
onSave({
|
onSave({
|
||||||
reportName,
|
reportName,
|
||||||
dataSource: selectedDataSource,
|
dataSource: selectedDataSource,
|
||||||
series: selectedSeries,
|
series: selectedSeries,
|
||||||
});
|
});
|
||||||
hide();
|
hide();
|
||||||
};
|
}, [selectedDataSource, selectedSeries, reportName, hide, onSave]);
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = useCallback(() => {
|
||||||
onCancel();
|
onCancel();
|
||||||
hide();
|
hide();
|
||||||
};
|
}, [onCancel, hide]);
|
||||||
|
|
||||||
const showDataSourceSelect = dataSources?.length > 1;
|
const showDataSourceSelect = dataSources?.length > 1;
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@ async function promptSaveReport({ servicesManager, commandsManager, extensionMan
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (promptResult.action === PROMPT_RESPONSES.CREATE_REPORT) {
|
if (promptResult.action === PROMPT_RESPONSES.CREATE_REPORT) {
|
||||||
const dataSources = extensionManager.getDataSources();
|
const dataSources = extensionManager.getDataSources(promptResult.dataSourceName);
|
||||||
const dataSource = dataSources[0];
|
const dataSource = dataSources[0];
|
||||||
const measurementData = measurementService.getMeasurements(measurementFilter);
|
const measurementData = measurementService.getMeasurements(measurementFilter);
|
||||||
|
|
||||||
|
|||||||
@ -87,9 +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 defaultDataSourceName: string;
|
private activeDataSourceName: string;
|
||||||
private activeDataSource: string;
|
|
||||||
private peerImport: (moduleId) => Promise<any>;
|
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
commandsManager,
|
commandsManager,
|
||||||
@ -117,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.activeDataSource = 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.activeDataSource === dataSource) {
|
if (this.activeDataSourceName === dataSource) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.activeDataSource = dataSource;
|
this.activeDataSourceName = dataSource;
|
||||||
|
|
||||||
this._broadcastEvent(
|
this._broadcastEvent(
|
||||||
ExtensionManager.EVENTS.ACTIVE_DATA_SOURCE_CHANGED,
|
ExtensionManager.EVENTS.ACTIVE_DATA_SOURCE_CHANGED,
|
||||||
this.dataSourceDefs[this.activeDataSource]
|
this.dataSourceDefs[this.activeDataSourceName]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,7 +373,7 @@ export default class ExtensionManager extends PubSubService {
|
|||||||
getDataSources = dataSourceName => {
|
getDataSources = dataSourceName => {
|
||||||
if (dataSourceName === undefined) {
|
if (dataSourceName === undefined) {
|
||||||
// Default to the activeDataSource
|
// Default to the activeDataSource
|
||||||
dataSourceName = this.activeDataSource;
|
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...
|
||||||
@ -387,7 +385,7 @@ export default class ExtensionManager extends PubSubService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
getActiveDataSource = () => {
|
getActiveDataSource = () => {
|
||||||
return this.dataSourceMap[this.activeDataSource];
|
return this.dataSourceMap[this.activeDataSourceName];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -400,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.activeDataSource;
|
dataSourceName = this.activeDataSourceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.dataSourceDefs[dataSourceName];
|
return this.dataSourceDefs[dataSourceName];
|
||||||
@ -410,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.activeDataSource);
|
return this.getDataSourceDefinition(this.activeDataSourceName);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -424,16 +422,21 @@ export default class ExtensionManager extends PubSubService {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Object.keys(this.dataSourceMap)
|
const inactiveDataSourceNames = Object.keys(this.dataSourceMap).filter(ds => {
|
||||||
.filter(ds => {
|
|
||||||
const configuration = this.dataSourceDefs[ds]?.configuration;
|
const configuration = this.dataSourceDefs[ds]?.configuration;
|
||||||
return configuration?.supportsStow ?? configuration?.wadoRoot;
|
const isNotActiveDataSource =
|
||||||
})
|
this.dataSourceDefs[ds].sourceName !== this.activeDataSourceName;
|
||||||
.map(ds => ({
|
const supportsStowOrWado = configuration?.supportsStow ?? configuration?.wadoRoot;
|
||||||
|
return supportsStowOrWado && isNotActiveDataSource;
|
||||||
|
});
|
||||||
|
|
||||||
|
const allDatasourcesForUI = [this.activeDataSourceName, ...inactiveDataSourceNames].map(ds => ({
|
||||||
value: ds,
|
value: ds,
|
||||||
label: ds,
|
label: ds,
|
||||||
placeHolder: ds,
|
placeHolder: ds,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
return allDatasourcesForUI;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -555,7 +558,7 @@ export default class ExtensionManager extends PubSubService {
|
|||||||
dataSourceDef.configuration = dataSourceConfiguration;
|
dataSourceDef.configuration = dataSourceConfiguration;
|
||||||
this._createDataSourceInstance(dataSourceDef);
|
this._createDataSourceInstance(dataSourceDef);
|
||||||
|
|
||||||
if (this.activeDataSource === 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);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user