Replacing switchToTab with routes
This commit is contained in:
1 parent
0cf4dbf13f
commit
7718d31a77
46 files changed
+358
-753
No files matched your search
@@ -21,13 +21,6 @@
|
||||
</div>
|
||||
{{/section}}
|
||||
{{/header}}
|
||||
<div id="studylistTabs" class="tab-content">
|
||||
<div class="tab-pane active" id="studylistTab">
|
||||
<div class="studylistContainer">
|
||||
{{>studylistResult}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="viewerTab">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{>Template.dynamic template=(choose this.template 'studylist') data=this}}
|
||||
</template>
|
||||
@@ -1,19 +1,18 @@
|
||||
import { Template } from 'meteor/templating';
|
||||
import { Session } from 'meteor/session';
|
||||
import { Router } from 'meteor/iron:router';
|
||||
import { ReactiveVar } from 'meteor/reactive-var';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
const studylistContentId = 'studylistTab';
|
||||
const viewerContentId = 'viewerTab';
|
||||
|
||||
// Define the ViewerData global object
|
||||
// If there is currently any Session data for this object,
|
||||
// use this to repopulate the variable
|
||||
// Define the OHIF.viewer.data global object
|
||||
Template.app.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
instance.headerClasses = new ReactiveVar('');
|
||||
|
||||
ViewerData = Session.get('ViewerData') || {};
|
||||
OHIF.viewer.data = instance.data.viewerData || {};
|
||||
|
||||
OHIF.header.dropdown.setItems([{
|
||||
action: OHIF.user.audit,
|
||||
@@ -46,24 +45,25 @@ Template.app.onCreated(() => {
|
||||
}]);
|
||||
|
||||
instance.autorun(() => {
|
||||
const contentId = Session.get('activeContentId');
|
||||
instance.headerClasses.set(contentId === viewerContentId ? '' : 'header-big');
|
||||
});
|
||||
});
|
||||
const currentRoute = Router.current();
|
||||
if (!currentRoute) return;
|
||||
const routeName = currentRoute.route.getName();
|
||||
const isViewer = routeName.indexOf('viewer') === 0;
|
||||
|
||||
Template.app.onRendered(() => {
|
||||
const contentId = Session.get('activeContentId');
|
||||
if (contentId === viewerContentId) {
|
||||
switchToTab(contentId);
|
||||
}
|
||||
// Add or remove the strech class from body
|
||||
$(document.body)[isViewer ? 'addClass' : 'removeClass']('stretch');
|
||||
|
||||
// Set the header on its bigger version if the viewer is not opened
|
||||
instance.headerClasses.set(isViewer ? '' : 'header-big');
|
||||
|
||||
// Set the viewer open state on session
|
||||
Session.set('ViewerOpened', isViewer);
|
||||
});
|
||||
});
|
||||
|
||||
Template.app.events({
|
||||
'click .js-toggle-studyList'(event) {
|
||||
const contentId = Session.get('activeContentId');
|
||||
|
||||
OHIF.ui.unsavedChanges.presentProactiveDialog('viewer.*', (hasChanges, userChoice) => {
|
||||
|
||||
if (hasChanges) {
|
||||
|
||||
switch (userChoice) {
|
||||
@@ -79,20 +79,12 @@ Template.app.events({
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (contentId !== studylistContentId) {
|
||||
switchToTab(studylistContentId);
|
||||
} else {
|
||||
switchToTab(viewerContentId);
|
||||
}
|
||||
|
||||
}, {
|
||||
position: {
|
||||
x: event.clientX + 15,
|
||||
y: event.clientY + 15
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -104,7 +96,7 @@ Template.app.helpers({
|
||||
|
||||
// If the Viewer has not been opened yet, 'Back to viewer' should
|
||||
// not be displayed
|
||||
const viewerContentExists = !!Object.keys(ViewerData).length;
|
||||
const viewerContentExists = !!Object.keys(OHIF.viewer.data).length;
|
||||
if (!viewerContentExists) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -31,12 +31,8 @@ Meteor.startup(() => {
|
||||
});
|
||||
|
||||
Template.viewer.onCreated(() => {
|
||||
|
||||
Session.set('ViewerReady', false);
|
||||
|
||||
const toolManager = OHIF.viewerbase.toolManager;
|
||||
ViewerData = window.ViewerData || ViewerData;
|
||||
|
||||
const instance = Template.instance();
|
||||
|
||||
const { TimepointApi, MeasurementApi, ConformanceCriteria } = OHIF.measurements;
|
||||
@@ -59,7 +55,6 @@ Template.viewer.onCreated(() => {
|
||||
instance.data.state.set('leftSidebar', Session.get('leftSidebar'));
|
||||
instance.data.state.set('rightSidebar', Session.get('rightSidebar'));
|
||||
|
||||
const contentId = instance.data.contentId;
|
||||
const viewportUtils = OHIF.viewerbase.viewportUtils;
|
||||
|
||||
OHIF.viewer.functionList = $.extend(OHIF.viewer.functionList, {
|
||||
@@ -84,18 +79,16 @@ Template.viewer.onCreated(() => {
|
||||
linkStackScroll: viewportUtils.linkStackScroll
|
||||
});
|
||||
|
||||
if (ViewerData[contentId].loadedSeriesData) {
|
||||
if (OHIF.viewer.data.loadedSeriesData) {
|
||||
OHIF.log.info('Reloading previous loadedSeriesData');
|
||||
OHIF.viewer.loadedSeriesData = ViewerData[contentId].loadedSeriesData;
|
||||
|
||||
OHIF.viewer.loadedSeriesData = OHIF.viewer.data.loadedSeriesData;
|
||||
} else {
|
||||
OHIF.log.info('Setting default ViewerData');
|
||||
OHIF.log.info('Setting default viewer data');
|
||||
OHIF.viewer.loadedSeriesData = {};
|
||||
ViewerData[contentId].loadedSeriesData = {};
|
||||
Session.setPersistent('ViewerData', ViewerData);
|
||||
OHIF.viewer.data.loadedSeriesData = {};
|
||||
}
|
||||
|
||||
Session.set('activeViewport', ViewerData[contentId].activeViewport || false);
|
||||
Session.set('activeViewport', OHIF.viewer.data.activeViewport || false);
|
||||
|
||||
// Set lesion tool buttons as disabled if pixel spacing is not available for active element
|
||||
instance.autorun(OHIF.lesiontracker.pixelSpacingAutorunCheck);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { Session } from 'meteor/session';
|
||||
import { Router } from 'meteor/iron:router';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
Session.setDefault('ViewerData', {});
|
||||
// TODO: remove the line below
|
||||
window.Router = Router;
|
||||
|
||||
// verifyEmail controls whether emailVerification template will be rendered or not
|
||||
const verifyEmail = Meteor.settings && Meteor.settings.public && Meteor.settings.public.verifyEmail || false;
|
||||
@@ -19,27 +19,21 @@ const data = {};
|
||||
|
||||
const routerOptions = { data };
|
||||
|
||||
Router.route('/', function() {
|
||||
// Check user is logged in
|
||||
if (Meteor.user() && Meteor.userId()) {
|
||||
Router.route('/', {
|
||||
name: 'home',
|
||||
onBeforeAction: function() {
|
||||
// Check if user needs to verify its email
|
||||
if (verifyEmail && Meteor.user().emails && !Meteor.user().emails[0].verified) {
|
||||
this.render('emailVerification', routerOptions);
|
||||
} else {
|
||||
const contentId = Session.get('activeContentId');
|
||||
if (!contentId) {
|
||||
Session.setPersistent('activeContentId', 'studylistTab');
|
||||
}
|
||||
|
||||
this.render('app', routerOptions);
|
||||
}
|
||||
} else {
|
||||
this.render('entrySignIn', routerOptions);
|
||||
}
|
||||
});
|
||||
|
||||
Router.route('/viewer/timepoints/:_id', {
|
||||
layoutTemplate: 'layout',
|
||||
name: 'viewer',
|
||||
name: 'viewerTimepoint',
|
||||
onBeforeAction: function() {
|
||||
const timepointId = this.params._id;
|
||||
|
||||
@@ -48,6 +42,47 @@ Router.route('/viewer/timepoints/:_id', {
|
||||
}
|
||||
});
|
||||
|
||||
OHIF.viewer.prepare = ({ studyInstanceUids, timepointId }) => {
|
||||
// Clear the cornerstone tool data to sync the measurements with the measurements API
|
||||
cornerstoneTools.globalImageIdSpecificToolStateManager = cornerstoneTools.newImageIdSpecificToolStateManager();
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
OHIF.studylist.retrieveStudiesMetadata(studyInstanceUids).then(studies => {
|
||||
// Add additional metadata to our study from the studylist
|
||||
studies.forEach(study => {
|
||||
const studylistStudy = OHIF.studylist.collections.Studies.findOne({
|
||||
studyInstanceUid: study.studyInstanceUid
|
||||
});
|
||||
|
||||
if (!studylistStudy) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object.assign(study, studylistStudy);
|
||||
});
|
||||
|
||||
resolve(studies);
|
||||
}).catch(reject);
|
||||
});
|
||||
};
|
||||
|
||||
Router.route('/viewer/studies/:studyInstanceUids', {
|
||||
name: 'viewerStudies',
|
||||
onBeforeAction: function() {
|
||||
this.render('app', { data: { template: 'loadingText' } });
|
||||
|
||||
const studyInstanceUids = this.params.studyInstanceUids.split(';');
|
||||
OHIF.viewer.prepare({ studyInstanceUids }).then(studies => {
|
||||
this.render('app', {
|
||||
data: {
|
||||
template: 'viewer',
|
||||
studies
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Router.onBeforeAction(function() {
|
||||
if (!Meteor.userId() && !Meteor.loggingIn()) {
|
||||
this.render('entrySignIn');
|
||||
|
||||
Reference in new issue
Block a user