Building the viewer data inside routes

This commit is contained in:
Bruno Alves de Faria committed 2017-03-21 10:16:47 -03:00
1 parent 7718d31a77
commit 9ccebb76bd
9 files changed
+193 -94

No files matched your search

+26 -72
View File
@@ -5,9 +5,6 @@ import { OHIF } from 'meteor/ohif:core';
// 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;
Router.configure({
layoutTemplate: 'layout',
loadingTemplate: 'layout'
@@ -15,80 +12,37 @@ Router.configure({
Router.onBeforeAction('loading');
const data = {};
const routerOptions = { data };
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 {
this.render('app', routerOptions);
}
}
});
Router.route('/viewer/timepoints/:_id', {
layoutTemplate: 'layout',
name: 'viewerTimepoint',
onBeforeAction: function() {
const timepointId = this.params._id;
this.render('app', routerOptions);
OHIF.lesiontracker.openNewTabWithTimepoint(timepointId);
}
});
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() {
// verifyEmail controls whether emailVerification template will be rendered or not
const publicSettings = Meteor.settings && Meteor.settings.public;
const verifyEmail = publicSettings && publicSettings.verifyEmail || false;
// Check if user is signed in or needs an email verification
if (!Meteor.userId() && !Meteor.loggingIn()) {
this.render('entrySignIn');
} else if (verifyEmail && Meteor.user().emails && !Meteor.user().emails[0].verified) {
this.render('emailVerification');
} else {
this.next();
}
}, {
except: ['entrySignIn', 'entrySignUp', 'forgotPassword', 'resetPassword']
except: ['entrySignIn', 'entrySignUp', 'forgotPassword', 'resetPassword', 'emailVerification']
});
Router.route('/', function() {
this.redirect('/studylist');
}, { name: 'home' });
Router.route('/studylist', function() {
this.render('app', { data: { template: 'studylist' } });
}, { name: 'studylist' });
Router.route('/viewer/timepoints/:timepointId', function() {
const timepointId = this.params.timepointId;
OHIF.viewerbase.renderViewer(this, { timepointId });
}, { name: 'viewerTimepoint' });
Router.route('/viewer/studies/:studyInstanceUids', function() {
const studyInstanceUids = this.params.studyInstanceUids.split(';');
OHIF.viewerbase.renderViewer(this, { studyInstanceUids });
}, { name: 'viewerStudies' });