Replacing switchToTab with routes

This commit is contained in:
Bruno Alves de Faria committed 2017-03-21 10:16:47 -03:00
1 parent 0cf4dbf13f
commit 7718d31a77
46 files changed
+358 -753

No files matched your search

+48 -13
View File
@@ -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');