fix: 🐛 Fail gracefully on an MPR load error (#1992)

* feat: 🎸 Update react-vtkjs-viewport usage to use requestPool

* Fix import of react-vtkjs-viewport to cornerstone-tools path.

* Increase maximum load time of MPR test now we are throttling requests.

* fix: 🐛 Fail gracefully on an MPR load error

* Respond to reviewer comments.
This commit is contained in:
James Petts 2020-08-24 10:44:09 +01:00 committed by GitHub
parent 7f3ca1fc23
commit 779a7e0976
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 20 deletions

View File

@ -50,7 +50,7 @@
"dependencies": { "dependencies": {
"@babel/runtime": "^7.5.5", "@babel/runtime": "^7.5.5",
"lodash.throttle": "^4.1.1", "lodash.throttle": "^4.1.1",
"react-vtkjs-viewport": "^0.10.3" "react-vtkjs-viewport": "^0.10.4"
}, },
"devDependencies": { "devDependencies": {
"@ohif/core": "^2.10.0", "@ohif/core": "^2.10.0",

View File

@ -32,16 +32,16 @@ class LoadingIndicator extends PureComponent {
</div> </div>
</div> </div>
) : ( ) : (
<div className="imageViewerLoadingIndicator loadingIndicator"> <div className="imageViewerLoadingIndicator loadingIndicator">
<div className="indicatorContents"> <div className="indicatorContents">
<p> <p>
{this.props.t('Loading...')} {this.props.t('Loading...')}
<i className="fa fa-spin fa-circle-o-notch fa-fw" /> <i className="fa fa-spin fa-circle-o-notch fa-fw" />
{percComplete} {percComplete}
</p> </p>
</div>
</div> </div>
)} </div>
)}
</React.Fragment> </React.Fragment>
); );
} }

View File

@ -50,22 +50,25 @@ class OHIFVTKViewport extends Component {
volumes: null, volumes: null,
paintFilterLabelMapImageData: null, paintFilterLabelMapImageData: null,
paintFilterBackgroundImageData: null, paintFilterBackgroundImageData: null,
percentComplete: 0,
isLoaded: false,
}; };
static propTypes = { static propTypes = {
viewportData: PropTypes.shape({ viewportData: PropTypes.shape({
studies: PropTypes.array, studies: PropTypes.array.isRequired,
displaySet: PropTypes.shape({ displaySet: PropTypes.shape({
StudyInstanceUID: PropTypes.string, StudyInstanceUID: PropTypes.string.isRequired,
displaySetInstanceUID: PropTypes.string, displaySetInstanceUID: PropTypes.string.isRequired,
sopClassUIDs: PropTypes.arrayOf(PropTypes.string), sopClassUIDs: PropTypes.arrayOf(PropTypes.string),
SOPInstanceUID: PropTypes.string, SOPInstanceUID: PropTypes.string,
frameIndex: PropTypes.number, frameIndex: PropTypes.number,
}), }),
}), }),
viewportIndex: PropTypes.number, viewportIndex: PropTypes.number.isRequired,
children: PropTypes.node, children: PropTypes.node,
onScroll: PropTypes.func, onScroll: PropTypes.func,
servicesManager: PropTypes.object.isRequired,
}; };
static defaultProps = { static defaultProps = {
@ -383,6 +386,24 @@ class OHIFVTKViewport extends Component {
} }
}; };
const onPixelDataInsertedErrorCallback = error => {
const { UINotificationService } = this.props.servicesManager.services;
if (!this.hasError) {
if (this.props.viewportIndex === 0) {
// Only show the notification from one viewport 1 in MPR2D.
UINotificationService.show({
title: 'MPR Load Error',
message: error.message,
type: 'error',
autoClose: false,
});
}
this.hasError = true;
}
};
const onAllPixelDataInsertedCallback = () => { const onAllPixelDataInsertedCallback = () => {
this.setState({ this.setState({
isLoaded: true, isLoaded: true,
@ -391,6 +412,7 @@ class OHIFVTKViewport extends Component {
imageDataObject.onPixelDataInserted(onPixelDataInsertedCallback); imageDataObject.onPixelDataInserted(onPixelDataInsertedCallback);
imageDataObject.onAllPixelDataInserted(onAllPixelDataInsertedCallback); imageDataObject.onAllPixelDataInserted(onAllPixelDataInsertedCallback);
imageDataObject.onPixelDataInsertedError(onPixelDataInsertedErrorCallback);
} }
render() { render() {

View File

@ -16,8 +16,10 @@ const vtkExtension = {
*/ */
id: 'vtk', id: 'vtk',
getViewportModule({ commandsManager }) { getViewportModule({ commandsManager, servicesManager }) {
const ExtendedVTKViewport = props => <OHIFVTKViewport {...props} />; const ExtendedVTKViewport = props => (
<OHIFVTKViewport {...props} servicesManager={servicesManager} />
);
return withCommandsManager(ExtendedVTKViewport, commandsManager); return withCommandsManager(ExtendedVTKViewport, commandsManager);
}, },
getToolbarModule() { getToolbarModule() {

View File

@ -16047,10 +16047,10 @@ react-transition-group@^4.1.1:
loose-envify "^1.4.0" loose-envify "^1.4.0"
prop-types "^15.6.2" prop-types "^15.6.2"
react-vtkjs-viewport@^0.10.3: react-vtkjs-viewport@^0.10.4:
version "0.10.3" version "0.10.4"
resolved "https://registry.yarnpkg.com/react-vtkjs-viewport/-/react-vtkjs-viewport-0.10.3.tgz#8eaa8bc558057215b648ad6ce17092d68cf5354b" resolved "https://registry.yarnpkg.com/react-vtkjs-viewport/-/react-vtkjs-viewport-0.10.4.tgz#eb038b0bf5c384bd3b45f2a0a57f52c682607fea"
integrity sha512-9aXuBrAlKa79Q1qPSWmPflSgpG2sm5jyKresdqUUvqYVJQJx83Xkkh4XfgOfLHY/nEwpTI8dr3FwtH2dzrBkoA== integrity sha512-J1WxwHbjlttEWvdkM33DJx8QxHr3J7HR6wFSDVBDKY7McK2lwDAdRN8wSqy2BVNILlyurUUVwg2tK2txiJ+tuw==
dependencies: dependencies:
date-fns "^2.2.1" date-fns "^2.2.1"
gl-matrix "^3.1.0" gl-matrix "^3.1.0"