Skip to content

Commit

Permalink
When we load with the ohif request coming from the server it may fail…
Browse files Browse the repository at this point in the history
… due to cors so we send the request again.
  • Loading branch information
ArturRod committed Jul 29, 2022
1 parent a1e3564 commit a9dea71
Showing 1 changed file with 36 additions and 20 deletions.
56 changes: 36 additions & 20 deletions src/OHIFDicomECGViewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,42 @@ class OHIFDicomECGViewport extends Component {
console.log('DicomECGViewport destroy()');
}

//Load byteArray:
componentDidMount() {
const { displaySet, studies } = this.props.viewportData;

DicomLoaderService.findDicomDataPromise(displaySet, studies).then(
data => {
const byteArray = new Uint8Array(data);
this.setState({
byteArray: byteArray,
});
},
error => {
this.setState({
error,
});

throw new Error(error);
}
);
}
//Load byteArray:
componentDidMount() {
const { displaySet, studies } = this.props.viewportData;

//Load local:
DicomLoaderService.findDicomDataPromise(displaySet, studies).then(
data => {
const byteArray = new Uint8Array(data);
this.setState({
byteArray: byteArray,
});
},
error => {
//Load from server request:
var oReq = new XMLHttpRequest();
oReq.open('get', this.props.viewportData.displaySet.wadoUri, true);
oReq.responseType = 'arraybuffer';
oReq.onreadystatechange = () => {
if (oReq.readyState === 4) {
if (oReq.status == 200) {
const byteArrayReq = new Uint8Array(oReq.response);
this.setState({
byteArray: byteArrayReq,
});
} else {
this.setState({
error: true,
});
throw new Error(error);
}
}
};
oReq.send();
}
);
}


render() {
Expand Down

0 comments on commit a9dea71

Please sign in to comment.