ohif-viewer/src/connectedComponents/ConnectedStudyBrowser.js

41 lines
1.3 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
import { StudyBrowser } from 'react-viewerbase';
import cloneDeep from 'lodash.clonedeep';
// TODO
// - Determine in which display set is active from Redux (activeViewportIndex and layout viewportData)
// - Pass in errors and stack loading progress from Redux
const mapStateToProps = (state, ownProps) => {
2019-05-29 14:39:54 +02:00
// If we know that the stack loading progress details have changed,
// we can try to update the component state so that the thumbnail
// progress bar is updated
const stackLoadingProgressMap = state.loading.progress;
const studiesWithLoadingData = cloneDeep(ownProps.studies);
2019-05-29 14:39:54 +02:00
studiesWithLoadingData.forEach(study => {
study.thumbnails.forEach(data => {
const { displaySetInstanceUid } = data;
const stackId = `StackProgress:${displaySetInstanceUid}`;
const stackProgressData = stackLoadingProgressMap[stackId];
2019-05-29 14:39:54 +02:00
let stackPercentComplete = 0;
if (stackProgressData) {
stackPercentComplete = stackProgressData.percentComplete;
}
2019-05-29 14:39:54 +02:00
data.stackPercentComplete = stackPercentComplete;
});
2019-05-29 14:39:54 +02:00
});
2019-05-29 14:39:54 +02:00
return {
studies: studiesWithLoadingData,
};
};
const ConnectedStudyBrowser = connect(
2019-05-29 14:39:54 +02:00
mapStateToProps,
null
)(StudyBrowser);
export default ConnectedStudyBrowser;