feat(datasourcename):Allow specifying the datasourcename as a parameter (#3029)
This commit is contained in:
1 parent
bbfdda7fe7
commit
abd75b0ba1
6 files changed
+237
-27
No files matched your search
@@ -19,29 +19,38 @@ function DataSourceWrapper(props) {
|
||||
const params = useParams();
|
||||
const location = useLocation();
|
||||
|
||||
// TODO: Fetch by type, name, etc?
|
||||
const dataSourceModules = extensionManager.modules[MODULE_TYPES.DATA_SOURCE];
|
||||
// TODO: Good usecase for flatmap?
|
||||
const webApiDataSources = dataSourceModules.reduce((acc, curr) => {
|
||||
const mods = [];
|
||||
curr.module.forEach(mod => {
|
||||
if (mod.type === 'webApi') {
|
||||
mods.push(mod);
|
||||
}
|
||||
});
|
||||
return acc.concat(mods);
|
||||
}, []);
|
||||
// TODO - get the variable from the props all the time...
|
||||
let dataSourceName = new URLSearchParams(location.search).get(
|
||||
'datasourcename'
|
||||
);
|
||||
const dataPath = dataSourceName ? `/${dataSourceName}` : '';
|
||||
|
||||
// Grabbing first defined for now - should get active
|
||||
// TODO: Why does this return an array?
|
||||
const dataSource = webApiDataSources
|
||||
.map(ds => extensionManager.getDataSources(ds.name)?.[0])
|
||||
.find(it => it !== undefined);
|
||||
if (!dataSource) {
|
||||
throw new Error(
|
||||
`No data source found for any of ${webApiDataSources.map(it => it.name)}`
|
||||
);
|
||||
if (!dataSourceName && window.config.defaultDataSourceName) {
|
||||
dataSourceName = window.config.defaultDataSourceName;
|
||||
} else if (!dataSourceName) {
|
||||
// Gets the first defined datasource with the right name
|
||||
// Mostly for historical reasons - new configs should use the defaultDataSourceName
|
||||
const dataSourceModules =
|
||||
extensionManager.modules[MODULE_TYPES.DATA_SOURCE];
|
||||
// TODO: Good usecase for flatmap?
|
||||
const webApiDataSources = dataSourceModules.reduce((acc, curr) => {
|
||||
const mods = [];
|
||||
curr.module.forEach(mod => {
|
||||
if (mod.type === 'webApi') {
|
||||
mods.push(mod);
|
||||
}
|
||||
});
|
||||
return acc.concat(mods);
|
||||
}, []);
|
||||
dataSourceName = webApiDataSources
|
||||
.map(ds => ds.name)
|
||||
.find(it => extensionManager.getDataSources(it)?.[0] !== undefined);
|
||||
}
|
||||
const dataSource = extensionManager.getDataSources(dataSourceName)?.[0];
|
||||
if (!dataSource) {
|
||||
throw new Error(`No data source found for ${dataSourceName}`);
|
||||
}
|
||||
|
||||
// Route props --> studies.mapParams
|
||||
// mapParams --> studies.search
|
||||
// studies.search --> studies.processResults
|
||||
@@ -114,6 +123,7 @@ function DataSourceWrapper(props) {
|
||||
<LayoutTemplate
|
||||
{...rest}
|
||||
data={data.studies}
|
||||
dataPath={dataPath}
|
||||
dataTotal={data.total}
|
||||
dataSource={dataSource}
|
||||
isLoadingData={isLoading}
|
||||
|
||||
@@ -46,6 +46,7 @@ function WorkList({
|
||||
isLoadingData,
|
||||
dataSource,
|
||||
hotkeysManager,
|
||||
dataPath,
|
||||
}) {
|
||||
const { hotkeyDefinitions, hotkeyDefaults } = hotkeysManager;
|
||||
const { show, hide } = useModal();
|
||||
@@ -346,7 +347,8 @@ function WorkList({
|
||||
return (
|
||||
<Link
|
||||
key={i}
|
||||
to={`${mode.routeName}?StudyInstanceUIDs=${studyInstanceUid}`}
|
||||
to={`${dataPath ? '../../' : ''}${mode.routeName}${dataPath ||
|
||||
''}?StudyInstanceUIDs=${studyInstanceUid}`}
|
||||
// to={`${mode.routeName}/dicomweb?StudyInstanceUIDs=${studyInstanceUid}`}
|
||||
>
|
||||
<Button
|
||||
@@ -496,6 +498,7 @@ const defaultFilterValues = {
|
||||
sortDirection: 'none',
|
||||
pageNumber: 1,
|
||||
resultsPerPage: 25,
|
||||
datasourcename: '',
|
||||
};
|
||||
|
||||
function _tryParseInt(str, defaultValue) {
|
||||
@@ -527,6 +530,7 @@ function _getQueryFilterValues(query) {
|
||||
sortDirection: query.get('sortDirection'),
|
||||
pageNumber: _tryParseInt(query.get('pageNumber'), undefined),
|
||||
resultsPerPage: _tryParseInt(query.get('resultsPerPage'), undefined),
|
||||
datasourcename: query.get('datasourcename'),
|
||||
};
|
||||
|
||||
// Delete null/undefined keys
|
||||
|
||||
Reference in new issue
Block a user