Files
ohif-viewer/platform/viewer/src/connectedComponents/ConnectedStudyBrowser.js
T

55 lines
1.7 KiB
JavaScript
Raw Normal View History

import OHIF from '@ohif/core';
2019-01-10 13:30:39 +01:00
import { connect } from 'react-redux';
2019-08-13 15:36:46 -04:00
import { StudyBrowser } from '@ohif/ui';
2019-01-10 13:30:39 +01:00
import cloneDeep from 'lodash.clonedeep';
const { setActiveViewportSpecificData } = OHIF.redux.actions;
2019-01-10 13:30:39 +01:00
// 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 08:39:54 -04: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-01-10 13:30:39 +01:00
2019-05-29 08:39:54 -04:00
studiesWithLoadingData.forEach(study => {
study.thumbnails.forEach(data => {
const { displaySetInstanceUID } = data;
const stackId = `StackProgress:${displaySetInstanceUID}`;
2019-05-29 08:39:54 -04:00
const stackProgressData = stackLoadingProgressMap[stackId];
2019-01-10 13:30:39 +01:00
2019-05-29 08:39:54 -04:00
let stackPercentComplete = 0;
if (stackProgressData) {
stackPercentComplete = stackProgressData.percentComplete;
}
2019-01-10 13:30:39 +01:00
2019-05-29 08:39:54 -04:00
data.stackPercentComplete = stackPercentComplete;
2019-01-10 13:30:39 +01:00
});
2019-05-29 08:39:54 -04:00
});
2019-01-10 13:30:39 +01:00
2019-05-29 08:39:54 -04:00
return {
studies: studiesWithLoadingData,
};
2019-01-10 13:30:39 +01:00
};
const mapDispatchToProps = (dispatch, ownProps) => {
return {
onThumbnailClick: displaySetInstanceUID => {
const displaySet = ownProps.studyMetadata[0].displaySets.find(
ds => ds.displaySetInstanceUID === displaySetInstanceUID
);
dispatch(setActiveViewportSpecificData(displaySet));
},
};
};
2019-01-10 13:30:39 +01:00
const ConnectedStudyBrowser = connect(
2019-05-29 08:39:54 -04:00
mapStateToProps,
mapDispatchToProps
2019-01-10 13:30:39 +01:00
)(StudyBrowser);
export default ConnectedStudyBrowser;