Skip to content

Commit

Permalink
#10 Add loader to DicomViewer example
Browse files Browse the repository at this point in the history
  • Loading branch information
afonsobspinto committed Mar 25, 2021
1 parent 1c7c495 commit a287b1d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
10 changes: 10 additions & 0 deletions geppetto.js/geppetto-ui/src/dicom-viewer/DicomViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ class DicomViewer extends Component {

_this.configureEvents();
_this.ready = true;
_this.props.onLoad()
})
.catch(function (error) {
window.console.log('oops... something went wrong...');
Expand Down Expand Up @@ -812,6 +813,11 @@ class DicomViewer extends Component {
}
}

DicomViewer.defaultProps = {
onLoad: () => {},
};


DicomViewer.propTypes = {
/**
* Component identifier
Expand Down Expand Up @@ -849,6 +855,10 @@ DicomViewer.propTypes = {
* Bool that defines the showing or not of the download button
*/
showDownloadButton: PropTypes.bool,
/**
* Callback function to be called after load is complete
*/
onLoad: PropTypes.func,
};

export default withStyles(styles)(DicomViewer);
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
import React, { Component } from 'react';
import DicomViewer from '../../DicomViewer';
import Loader from "@geppettoengine/geppetto-ui/loader/Loader";

export default class DicomViewerExample extends Component {
constructor (props) {
super(props);
super(props);
this.state = {ready: true};
this.onLoad = this.onLoad.bind(this)

}

componentDidMount() {
this.setState({
ready: false
});
}

onLoad(){
this.setState({
ready: true
});
}

render () {
const data
= 'https://s3.amazonaws.com/patient-hm-august-2017/MRI/IN+SITU+2008+MPRAGE+1MM-ISO/IN-SITU-2008-MPRAGE-1MM-ISO-ALT2.nii.gz';

return (
const {ready} = this.state

return ready? (
<div
style={{
position: 'relative',
Expand All @@ -27,8 +45,9 @@ export default class DicomViewerExample extends Component {
onShiftClick="goToPoint"
onCtrlClick="togglMode"
showDownloadButton={true}
onLoad={this.onLoad}
/>
</div>
);
): <Loader/>
}
}

0 comments on commit a287b1d

Please sign in to comment.