Allowing lazy-loading on viewer
This commit is contained in:
1 parent
ed0bde0404
commit
bde625a961
15 files changed
+167
-36
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import './item.html';
|
||||
import './item.js';
|
||||
import './list.html';
|
||||
import './list.js';
|
||||
import './list.styl';
|
||||
import './quickSwitch.html';
|
||||
import './quickSwitch.js';
|
||||
|
||||
@@ -4,18 +4,20 @@
|
||||
{{#if isLoading}}
|
||||
{{>loadingText}}
|
||||
{{/if}}
|
||||
<div class="study-item-box">
|
||||
<div class="study-modality">
|
||||
<div class="study-modality-text" style="{{modalityStyle}}">{{instance.modalities}}</div>
|
||||
{{#let studyData=instance.studyData.get}}
|
||||
<div class="study-item-box">
|
||||
<div class="study-modality">
|
||||
<div class="study-modality-text" style="{{modalityStyle studyData.modalities}}">{{studyData.modalities}}</div>
|
||||
</div>
|
||||
<div class="study-text">
|
||||
<div class="study-date">{{formatDA studyData.studyDate 'D-MMM-YYYY'}}</div>
|
||||
<div class="study-description">{{studyData.studyDescription}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="study-text">
|
||||
<div class="study-date">{{formatDA this.studyInformation.studyDate 'D-MMM-YYYY'}}</div>
|
||||
<div class="study-description">{{this.studyInformation.studyDescription}}</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/let}}
|
||||
</div>
|
||||
{{#if this.studyChildTemplate}}
|
||||
{{#if and (not isLoading) instance.loaded}}
|
||||
{{#if and (not isLoading) instance.studyData.get instance.loaded}}
|
||||
{{>Template.dynamic template=this.studyChildTemplate data=(clone this)}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
@@ -7,12 +7,42 @@ import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
Template.studyBrowserItem.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
const { studyInformation } = instance.data;
|
||||
const { studyInstanceUid } = studyInformation;
|
||||
|
||||
instance.loaded = false;
|
||||
instance.loading = new ReactiveVar(false);
|
||||
|
||||
const modalities = instance.data.studyInformation.modalities || 'UN';
|
||||
instance.modalities = _.uniq(modalities.split(/[^A-Za-z]+/g)).join(' ');
|
||||
instance.studyData = new ReactiveVar(studyInformation);
|
||||
|
||||
instance.studyMetadata = null;
|
||||
instance.getStudyMetadata = () => {
|
||||
instance.loading.dep.depend();
|
||||
|
||||
if (!instance.studyMetadata) {
|
||||
instance.studyMetadata = OHIF.viewer.Studies.findBy({ studyInstanceUid }) || null;
|
||||
}
|
||||
|
||||
return instance.studyMetadata;
|
||||
};
|
||||
|
||||
instance.autorun(() => {
|
||||
const instance = Template.instance();
|
||||
|
||||
OHIF.studies.loadedDict.get(studyInstanceUid);
|
||||
const studyMetadata = instance.getStudyMetadata();
|
||||
if (studyMetadata) {
|
||||
const firstInstance = studyMetadata.getFirstInstance();
|
||||
instance.studyData.set({
|
||||
studyDate: firstInstance.getRawValue('x00080020') || '',
|
||||
studyDescription: firstInstance.getRawValue('x00081030') || '',
|
||||
modalities: firstInstance.getRawValue('x00080060') || '',
|
||||
});
|
||||
|
||||
instance.loaded = true;
|
||||
instance.loading.set(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Template.studyBrowserItem.events({
|
||||
@@ -49,10 +79,14 @@ Template.studyBrowserItem.helpers({
|
||||
return Template.instance().loading.get();
|
||||
},
|
||||
|
||||
modalityStyle() {
|
||||
modalitiesText(modalities) {
|
||||
const text = modalities || 'UN';
|
||||
return _.uniq(text.split(/[^A-Za-z]+/g)).join(' ');
|
||||
},
|
||||
|
||||
modalityStyle(modalities) {
|
||||
// Responsively styles the Modality Acronyms for studies with more than one modality
|
||||
const instance = Template.instance();
|
||||
const numModalities = instance.modalities.split(/\s/g).length;
|
||||
const numModalities = modalities.split(/\s/g).length;
|
||||
|
||||
if (numModalities === 1) {
|
||||
// If we have only one modality, it should take up the whole div
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template name="studyBrowserList">
|
||||
<div class="study-browser-list {{this.class}}">
|
||||
{{#each studyInformation in studiesInformation}}
|
||||
{{#each studyInformation in getStudiesInformation}}
|
||||
{{>studyBrowserItem (clone this studyInformation=studyInformation)}}
|
||||
{{/each}}
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import { Template } from 'meteor/templating';
|
||||
|
||||
Template.studyBrowserList.helpers({
|
||||
getStudiesInformation() {
|
||||
const instance = Template.instance();
|
||||
const { studiesInformation } = instance.data;
|
||||
const result = new Map();
|
||||
studiesInformation.forEach(item => result.set(item.studyInstanceUid, item));
|
||||
return Array.from(result.values());
|
||||
}
|
||||
});
|
||||
@@ -33,7 +33,8 @@ $spacerY = 12px
|
||||
height: 100%
|
||||
left: 0
|
||||
opacity: 0.75
|
||||
right: 16px
|
||||
top: 0
|
||||
width: 100%
|
||||
|
||||
.study-item-box
|
||||
opacity: 0.2
|
||||
@@ -72,7 +73,7 @@ $spacerY = 12px
|
||||
padding: $spacerY $spacerX ($spacerY - 1)
|
||||
position: relative
|
||||
transition($sidebarTransition)
|
||||
z-index: 1
|
||||
z-index: 0
|
||||
|
||||
&:hover
|
||||
background-color: $boxHoverBackgroundColor
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="study-browser-series">
|
||||
<div class="study-series-container">
|
||||
{{#each thumbnail in instance.thumbnails.get}}
|
||||
{{>thumbnailEntry (clone '' thumbnail=thumbnail)}}
|
||||
{{>thumbnailEntry (clone this thumbnail=thumbnail)}}
|
||||
{{/each}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -5,18 +5,43 @@ import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
Template.studyBrowserSeries.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
const { studyInformation } = instance.data;
|
||||
const { studyInstanceUid } = studyInformation;
|
||||
const { studyInformation, studyMetadata } = instance.data;
|
||||
const studyInstanceUid = (studyMetadata && studyMetadata.studyInstanceUid) || (studyInformation && studyInformation.studyInstanceUid);
|
||||
|
||||
instance.thumbnails = new ReactiveVar([]);
|
||||
|
||||
// Get the study metadata and update the study thumbnails
|
||||
instance.autorun(() => {
|
||||
const studyMetadata = OHIF.viewer.Studies.findBy({ studyInstanceUid });
|
||||
let metadata = studyMetadata;
|
||||
|
||||
// Check for reactivity
|
||||
if (metadata instanceof ReactiveVar) {
|
||||
metadata = metadata.get();
|
||||
}
|
||||
|
||||
// Retrieve the study metadata
|
||||
if (!metadata) {
|
||||
metadata = OHIF.viewer.Studies.findBy({ studyInstanceUid });
|
||||
}
|
||||
|
||||
// Stop here if there's no study metadata
|
||||
if (!metadata) return;
|
||||
|
||||
// Get the study display sets
|
||||
let displaySets = metadata.getDisplaySets();
|
||||
if (!displaySets.length) {
|
||||
displaySets = OHIF.viewerbase.sortingManager.getDisplaySets(metadata);
|
||||
metadata.displaySets = displaySets;
|
||||
metadata.setDisplaySets(displaySets);
|
||||
|
||||
metadata.forEachDisplaySet(displaySet => {
|
||||
OHIF.viewerbase.stackManager.makeAndAddStack(metadata, displaySet);
|
||||
});
|
||||
}
|
||||
|
||||
// Defines the resulting thumbnails list
|
||||
const thumbnails = [];
|
||||
studyMetadata.displaySets.forEach((stack, thumbnailIndex) => {
|
||||
displaySets.forEach((stack, thumbnailIndex) => {
|
||||
thumbnails.push({
|
||||
thumbnailIndex,
|
||||
stack
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { ReactiveDict } from 'meteor/reactive-dict';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
// Create a studies loaded state dictionary to enable reactivity
|
||||
OHIF.studies.loadedDict = new ReactiveDict();
|
||||
|
||||
/**
|
||||
* Load the study metadata and store its information locally
|
||||
*
|
||||
@@ -8,6 +12,16 @@ import { OHIF } from 'meteor/ohif:core';
|
||||
*/
|
||||
OHIF.studies.loadStudy = studyInstanceUid => new Promise((resolve, reject) => {
|
||||
OHIF.studies.retrieveStudyMetadata(studyInstanceUid).then(study => {
|
||||
// Add the display sets to the study if not present
|
||||
if (!study.displaySets) {
|
||||
const displaySets = OHIF.viewerbase.sortingManager.getDisplaySets(study);
|
||||
study.displaySets = displaySets;
|
||||
study.setDisplaySets(displaySets);
|
||||
study.forEachDisplaySet(displaySet => {
|
||||
OHIF.viewerbase.stackManager.makeAndAddStack(study, displaySet);
|
||||
});
|
||||
}
|
||||
|
||||
// Double check to make sure this study wasn't already inserted into OHIF.viewer.Studies
|
||||
// so we don't cause duplicate entry errors
|
||||
const loaded = OHIF.viewer.Studies.findBy({ studyInstanceUid: study.studyInstanceUid });
|
||||
@@ -15,6 +29,9 @@ OHIF.studies.loadStudy = studyInstanceUid => new Promise((resolve, reject) => {
|
||||
OHIF.viewer.Studies.insert(study);
|
||||
}
|
||||
|
||||
// Add the studyInstanceUid to the loaded state dictionary
|
||||
OHIF.studies.loadedDict.set(study.studyInstanceUid, true);
|
||||
|
||||
resolve(study);
|
||||
}).catch(reject);
|
||||
});
|
||||
Reference in new issue
Block a user