Merge pull request #2241 from OHIF/IDC-2223

feat(IDC-2223): Add error notification on microscopy viewport initialization errors
This commit is contained in:
Igor Octaviano 2021-01-21 11:54:51 -03:00 committed by GitHub
commit cb147dfc69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 17 deletions

View File

@ -62,11 +62,24 @@ class DicomMicroscopyViewport extends Component {
);
const microscopyViewer = api.VLWholeSlideMicroscopyImageViewer;
this.viewer = new microscopyViewer({
client: dicomWebClient,
metadata,
retrieveRendered: false,
});
try {
this.viewer = new microscopyViewer({
client: dicomWebClient,
metadata,
retrieveRendered: false,
});
} catch (error) {
console.error('[Microscopy Viewer] Failed to load:', error);
const { UINotificationService } = this.props.servicesManager.services;
if (UINotificationService) {
UINotificationService.show({
title: 'Microscopy Viewport',
message:
'Failed to load viewport. Please check that you have hardware acceleration enabled.',
type: 'error',
});
}
}
this.viewer.render({ container });
});
@ -92,8 +105,8 @@ class DicomMicroscopyViewport extends Component {
{this.state.error ? (
<h2>{JSON.stringify(this.state.error)}</h2>
) : (
<div style={style} ref={this.container} />
)}
<div style={style} ref={this.container} />
)}
</div>
);
}

View File

@ -6,14 +6,6 @@ const Component = React.lazy(() => {
return import('./DicomMicroscopyViewport');
});
const DicomMicroscopyViewport = props => {
return (
<React.Suspense fallback={<div>Loading...</div>}>
<Component {...props} />
</React.Suspense>
);
};
export default {
/**
* Only required property. Should be a unique value across all extensions.
@ -21,8 +13,14 @@ export default {
id: 'microscopy',
version,
getViewportModule() {
return DicomMicroscopyViewport;
getViewportModule({ servicesManager }) {
return props => {
return (
<React.Suspense fallback={<div>Loading...</div>}>
<Component {...props} servicesManager={servicesManager} />
</React.Suspense>
);
};
},
getSopClassHandlerModule() {
return DicomMicroscopySopClassHandler;