fix: various type issues and error handlings (#2831)
* fix(error):Fix a few error conditions, mostly around seriesNumber * apply few fixes
This commit is contained in:
parent
71f5fa8e2f
commit
0090605cf7
@ -419,7 +419,7 @@ OHIFCornerstoneViewport.propTypes = {
|
|||||||
displaySets: PropTypes.array.isRequired,
|
displaySets: PropTypes.array.isRequired,
|
||||||
dataSource: PropTypes.object.isRequired,
|
dataSource: PropTypes.object.isRequired,
|
||||||
viewportOptions: PropTypes.object,
|
viewportOptions: PropTypes.object,
|
||||||
displaySetOptions: PropTypes.arrayOf(PropTypes.object),
|
displaySetOptions: PropTypes.arrayOf(PropTypes.any),
|
||||||
servicesManager: PropTypes.object.isRequired,
|
servicesManager: PropTypes.object.isRequired,
|
||||||
onElementEnabled: PropTypes.func,
|
onElementEnabled: PropTypes.func,
|
||||||
// Note: you SHOULD NOT use the initialImageIdOrIndex for manipulation
|
// Note: you SHOULD NOT use the initialImageIdOrIndex for manipulation
|
||||||
|
|||||||
@ -3,6 +3,10 @@ import toolbarButtons from './toolbarButtons.js';
|
|||||||
import { id } from './id.js';
|
import { id } from './id.js';
|
||||||
import initToolGroups from './initToolGroups.js';
|
import initToolGroups from './initToolGroups.js';
|
||||||
|
|
||||||
|
// Allow this mode by excluding non-imaging modalities such as SR, SEG
|
||||||
|
// Also, SM is not a simple imaging modalities, so exclude it.
|
||||||
|
const NON_IMAGE_MODALITIES = ['SM', 'ECG', 'SR', 'SEG'];
|
||||||
|
|
||||||
const ohif = {
|
const ohif = {
|
||||||
layout: '@ohif/extension-default.layoutTemplateModule.viewerLayout',
|
layout: '@ohif/extension-default.layoutTemplateModule.viewerLayout',
|
||||||
sopClassHandler: '@ohif/extension-default.sopClassHandlerModule.stack',
|
sopClassHandler: '@ohif/extension-default.sopClassHandlerModule.stack',
|
||||||
@ -44,7 +48,7 @@ const extensionDependencies = {
|
|||||||
'@ohif/extension-dicom-video': '^3.0.1',
|
'@ohif/extension-dicom-video': '^3.0.1',
|
||||||
};
|
};
|
||||||
|
|
||||||
function modeFactory({ modeConfiguration }) {
|
function modeFactory() {
|
||||||
return {
|
return {
|
||||||
// TODO: We're using this as a route segment
|
// TODO: We're using this as a route segment
|
||||||
// We should not be.
|
// We should not be.
|
||||||
@ -119,11 +123,14 @@ function modeFactory({ modeConfiguration }) {
|
|||||||
study: [],
|
study: [],
|
||||||
series: [],
|
series: [],
|
||||||
},
|
},
|
||||||
isValidMode: ({ modalities }) => {
|
|
||||||
|
isValidMode: function({ modalities }) {
|
||||||
const modalities_list = modalities.split('\\');
|
const modalities_list = modalities.split('\\');
|
||||||
|
|
||||||
// Slide Microscopy modality not supported by basic mode yet
|
// Exclude non-image modalities
|
||||||
return !modalities_list.includes('SM');
|
return !!modalities_list.filter(
|
||||||
|
modality => NON_IMAGE_MODALITIES.indexOf(modality) === -1
|
||||||
|
).length;
|
||||||
},
|
},
|
||||||
routes: [
|
routes: [
|
||||||
{
|
{
|
||||||
@ -131,7 +138,7 @@ function modeFactory({ modeConfiguration }) {
|
|||||||
/*init: ({ servicesManager, extensionManager }) => {
|
/*init: ({ servicesManager, extensionManager }) => {
|
||||||
//defaultViewerRouteInit
|
//defaultViewerRouteInit
|
||||||
},*/
|
},*/
|
||||||
layoutTemplate: ({ location, servicesManager }) => {
|
layoutTemplate: () => {
|
||||||
return {
|
return {
|
||||||
id: ohif.layout,
|
id: ohif.layout,
|
||||||
props: {
|
props: {
|
||||||
|
|||||||
20
platform/ui/src/Types.ts
Normal file
20
platform/ui/src/Types.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* StringNumber often comes back from DICOMweb for integer valued items.
|
||||||
|
*/
|
||||||
|
const StringNumber = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* StringArray often comes back from dcmjs for single valued strings that
|
||||||
|
* might have multiple values such as window level descriptions.
|
||||||
|
*/
|
||||||
|
const StringArray = PropTypes.oneOfType([PropTypes.string, PropTypes.array]);
|
||||||
|
|
||||||
|
const ThumbnailType = PropTypes.oneOf([
|
||||||
|
'thumbnail',
|
||||||
|
'thumbnailTracked',
|
||||||
|
'thumbnailNoImage',
|
||||||
|
]);
|
||||||
|
|
||||||
|
export { StringNumber, StringArray, ThumbnailType };
|
||||||
@ -4,6 +4,7 @@ import classnames from 'classnames';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import { ButtonGroup, Button, StudyItem, ThumbnailList } from '../';
|
import { ButtonGroup, Button, StudyItem, ThumbnailList } from '../';
|
||||||
|
import { StringNumber } from '../../Types';
|
||||||
|
|
||||||
const buttonClasses = 'text-white text-base border-none bg-black p-2 min-w-18';
|
const buttonClasses = 'text-white text-base border-none bg-black p-2 min-w-18';
|
||||||
const activeButtonClasses = 'bg-primary-main';
|
const activeButtonClasses = 'bg-primary-main';
|
||||||
@ -140,7 +141,7 @@ StudyBrowser.propTypes = {
|
|||||||
imageSrc: PropTypes.string,
|
imageSrc: PropTypes.string,
|
||||||
imageAltText: PropTypes.string,
|
imageAltText: PropTypes.string,
|
||||||
seriesDate: PropTypes.string,
|
seriesDate: PropTypes.string,
|
||||||
seriesNumber: PropTypes.string,
|
seriesNumber: StringNumber,
|
||||||
numInstances: PropTypes.number,
|
numInstances: PropTypes.number,
|
||||||
description: PropTypes.string,
|
description: PropTypes.string,
|
||||||
componentType: PropTypes.oneOf([
|
componentType: PropTypes.oneOf([
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
|
|||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { useDrag } from 'react-dnd';
|
import { useDrag } from 'react-dnd';
|
||||||
import { Icon } from '../';
|
import { Icon } from '../';
|
||||||
|
import { StringNumber } from '../../Types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -98,7 +99,7 @@ Thumbnail.propTypes = {
|
|||||||
}),
|
}),
|
||||||
imageAltText: PropTypes.string,
|
imageAltText: PropTypes.string,
|
||||||
description: PropTypes.string.isRequired,
|
description: PropTypes.string.isRequired,
|
||||||
seriesNumber: PropTypes.string.isRequired,
|
seriesNumber: StringNumber.isRequired,
|
||||||
numInstances: PropTypes.number.isRequired,
|
numInstances: PropTypes.number.isRequired,
|
||||||
isActive: PropTypes.bool.isRequired,
|
isActive: PropTypes.bool.isRequired,
|
||||||
onClick: PropTypes.func.isRequired,
|
onClick: PropTypes.func.isRequired,
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import React from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import { Thumbnail, ThumbnailNoImage, ThumbnailTracked } from '../';
|
import { Thumbnail, ThumbnailNoImage, ThumbnailTracked } from '../';
|
||||||
|
import * as Types from '../../Types';
|
||||||
|
|
||||||
const ThumbnailList = ({
|
const ThumbnailList = ({
|
||||||
thumbnails,
|
thumbnails,
|
||||||
@ -110,18 +111,11 @@ ThumbnailList.propTypes = {
|
|||||||
imageSrc: PropTypes.string,
|
imageSrc: PropTypes.string,
|
||||||
imageAltText: PropTypes.string,
|
imageAltText: PropTypes.string,
|
||||||
seriesDate: PropTypes.string,
|
seriesDate: PropTypes.string,
|
||||||
seriesNumber: PropTypes.string,
|
seriesNumber: Types.StringNumber,
|
||||||
numInstances: PropTypes.number,
|
numInstances: PropTypes.number,
|
||||||
description: PropTypes.string,
|
description: PropTypes.string,
|
||||||
componentType: PropTypes.oneOf([
|
componentType: Types.ThumbnailType.isRequired,
|
||||||
'thumbnail',
|
viewportIdentificator: Types.StringArray,
|
||||||
'thumbnailTracked',
|
|
||||||
'thumbnailNoImage',
|
|
||||||
]).isRequired,
|
|
||||||
viewportIdentificator: PropTypes.oneOfType([
|
|
||||||
PropTypes.string,
|
|
||||||
PropTypes.array,
|
|
||||||
]),
|
|
||||||
isTracked: PropTypes.bool,
|
isTracked: PropTypes.bool,
|
||||||
/**
|
/**
|
||||||
* Data the thumbnail should expose to a receiving drop target. Use a matching
|
* Data the thumbnail should expose to a receiving drop target. Use a matching
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
|
|||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
|
||||||
import { Icon, Thumbnail, Tooltip } from '../';
|
import { Icon, Thumbnail, Tooltip } from '../';
|
||||||
|
import { StringNumber } from '../../Types';
|
||||||
|
|
||||||
const ThumbnailTracked = ({
|
const ThumbnailTracked = ({
|
||||||
displaySetInstanceUID,
|
displaySetInstanceUID,
|
||||||
@ -137,7 +138,7 @@ ThumbnailTracked.propTypes = {
|
|||||||
imageSrc: PropTypes.string,
|
imageSrc: PropTypes.string,
|
||||||
imageAltText: PropTypes.string,
|
imageAltText: PropTypes.string,
|
||||||
description: PropTypes.string.isRequired,
|
description: PropTypes.string.isRequired,
|
||||||
seriesNumber: PropTypes.string.isRequired,
|
seriesNumber: StringNumber.isRequired,
|
||||||
numInstances: PropTypes.number.isRequired,
|
numInstances: PropTypes.number.isRequired,
|
||||||
onClick: PropTypes.func.isRequired,
|
onClick: PropTypes.func.isRequired,
|
||||||
onDoubleClick: PropTypes.func.isRequired,
|
onDoubleClick: PropTypes.func.isRequired,
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import classnames from 'classnames';
|
|||||||
import { Icon, ButtonGroup, Button, Tooltip, CinePlayer } from '../';
|
import { Icon, ButtonGroup, Button, Tooltip, CinePlayer } from '../';
|
||||||
import useOnClickOutside from '../../utils/useOnClickOutside';
|
import useOnClickOutside from '../../utils/useOnClickOutside';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { StringNumber } from '../../Types';
|
||||||
|
|
||||||
const classes = {
|
const classes = {
|
||||||
infoHeader: 'text-base text-primary-light',
|
infoHeader: 'text-base text-primary-light',
|
||||||
@ -336,7 +337,7 @@ ViewportActionBar.propTypes = {
|
|||||||
isTracked: PropTypes.bool.isRequired,
|
isTracked: PropTypes.bool.isRequired,
|
||||||
isRehydratable: PropTypes.bool.isRequired,
|
isRehydratable: PropTypes.bool.isRequired,
|
||||||
studyDate: PropTypes.string.isRequired,
|
studyDate: PropTypes.string.isRequired,
|
||||||
currentSeries: PropTypes.string.isRequired,
|
currentSeries: StringNumber.isRequired,
|
||||||
seriesDescription: PropTypes.string.isRequired,
|
seriesDescription: PropTypes.string.isRequired,
|
||||||
modality: PropTypes.string.isRequired,
|
modality: PropTypes.string.isRequired,
|
||||||
patientInformation: PropTypes.shape({
|
patientInformation: PropTypes.shape({
|
||||||
|
|||||||
@ -3,6 +3,9 @@
|
|||||||
//export { utils };
|
//export { utils };
|
||||||
|
|
||||||
/** CONTEXT/HOOKS */
|
/** CONTEXT/HOOKS */
|
||||||
|
// Export types - need to do as two lines due to a bug in babel
|
||||||
|
import * as Types from './Types';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
useCine,
|
useCine,
|
||||||
CineProvider,
|
CineProvider,
|
||||||
@ -104,3 +107,4 @@ export {
|
|||||||
export { getIcon, ICONS } from './components/Icon/getIcon';
|
export { getIcon, ICONS } from './components/Icon/getIcon';
|
||||||
export { BackgroundColor } from './pages/Colors/BackgroundColor';
|
export { BackgroundColor } from './pages/Colors/BackgroundColor';
|
||||||
export { ModalComponent } from './contextProviders/ModalComponent';
|
export { ModalComponent } from './contextProviders/ModalComponent';
|
||||||
|
export { Types };
|
||||||
|
|||||||
@ -370,8 +370,9 @@ function _getViewportComponent(displaySets, viewportComponents) {
|
|||||||
const SOPClassHandlerId = displaySets[0].SOPClassHandlerId;
|
const SOPClassHandlerId = displaySets[0].SOPClassHandlerId;
|
||||||
|
|
||||||
for (let i = 0; i < viewportComponents.length; i++) {
|
for (let i = 0; i < viewportComponents.length; i++) {
|
||||||
if (!viewportComponents[i])
|
if (!viewportComponents[i]) {
|
||||||
throw new Error('viewport components not defined');
|
throw new Error('viewport components not defined');
|
||||||
|
}
|
||||||
if (!viewportComponents[i].displaySetsToDisplay) {
|
if (!viewportComponents[i].displaySetsToDisplay) {
|
||||||
throw new Error('displaySetsToDisplay is null');
|
throw new Error('displaySetsToDisplay is null');
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user