Updates to improve reactivity, session storage, logging
This commit is contained in:
1 parent
9fb5cc2953
commit
a10f149b4b
37 files changed
+370
-288
No files matched your search
@@ -1,43 +1,59 @@
|
||||
ViewerData = Session.get('ViewerData') || {};
|
||||
StudyMetaData = {};
|
||||
|
||||
Template.worklist.helpers({
|
||||
'tabs': function() {
|
||||
console.log('Updating tabs');
|
||||
return tabs.find();
|
||||
}
|
||||
});
|
||||
getStudyMetadata = function(studyInstanceUid, doneCallback) {
|
||||
log.info('worklistStudy getStudyMetadata');
|
||||
|
||||
Template.worklist.events({
|
||||
'click a[data-toggle="tab"]': function(e) {
|
||||
var contentId = $(e.currentTarget).data('target').replace("#", "");
|
||||
switchToTab(contentId);
|
||||
if (StudyMetaData.hasOwnProperty(studyInstanceUid) && StudyMetaData[studyInstanceUid]) {
|
||||
var study = StudyMetaData[studyInstanceUid];
|
||||
doneCallback(study);
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
Meteor.call('GetStudyMetadata', studyInstanceUid, function(error, study) {
|
||||
sortStudy(study);
|
||||
|
||||
StudyMetaData[studyInstanceUid] = study;
|
||||
|
||||
doneCallback(study);
|
||||
});
|
||||
};
|
||||
|
||||
switchToTab = function(contentId) {
|
||||
var data = ViewerData[contentId];
|
||||
|
||||
console.log("Switching to tab: " + contentId);
|
||||
|
||||
// Set active tab
|
||||
Session.set("activeContentId", contentId);
|
||||
log.info("Switching to tab: " + contentId);
|
||||
|
||||
$('.tabTitle a[data-target="#' + contentId + '"]').tab('show');
|
||||
|
||||
$("#viewer").remove();
|
||||
|
||||
var container = $('.tab-content').find("#" + contentId).get(0);
|
||||
if (!container) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (contentId === 'worklistTab') {
|
||||
console.log('Switching to worklist');
|
||||
document.body.style.overflow = null;
|
||||
document.body.style.height = null;
|
||||
document.body.style.minWidth = null;
|
||||
document.body.style.position = null;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set active tab
|
||||
Session.set("activeContentId", contentId);
|
||||
|
||||
// Get tab content container
|
||||
var container = $('.tab-content').find("#" + contentId).get(0);
|
||||
if (!container) {
|
||||
return;
|
||||
}
|
||||
|
||||
var studyInstanceUid = ViewerData[contentId].studyInstanceUid;
|
||||
getStudyMetadata(studyInstanceUid, function(study) {
|
||||
var data = {
|
||||
viewportRows: ViewerData[contentId].viewportRows,
|
||||
viewportColumns: ViewerData[contentId].viewportColumns,
|
||||
contentId: contentId,
|
||||
studies: [study],
|
||||
};
|
||||
|
||||
Session.set('studies', data.studies);
|
||||
|
||||
UI.renderWithData(Template.viewer, data, container);
|
||||
var imageViewer = $("#viewer");
|
||||
if (imageViewer) {
|
||||
@@ -47,34 +63,50 @@ switchToTab = function(contentId) {
|
||||
document.body.style.minWidth = 0;
|
||||
document.body.style.position = 'fixed'; // Prevent overscroll on mobile devices
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
openNewTab = function(studyInstanceUid) {
|
||||
getStudyMetadata(studyInstanceUid, function(study) {
|
||||
var title = study.seriesList[0].instances[0].patientName;
|
||||
var contentid = generateUUID();
|
||||
|
||||
var data = {
|
||||
title: title,
|
||||
contentid: contentid,
|
||||
};
|
||||
tabs.insert(data);
|
||||
|
||||
ViewerData[contentid] = {
|
||||
title: title,
|
||||
contentid: contentid,
|
||||
studyInstanceUid: studyInstanceUid
|
||||
};
|
||||
switchToTab(contentid);
|
||||
});
|
||||
};
|
||||
|
||||
Template.worklist.onRendered(function() {
|
||||
this.autorun(function() {
|
||||
var data = Session.get('OpenNewTabEvent');
|
||||
|
||||
// If we have no new tab data, stop here
|
||||
// (e.g. if we are rendering the worklist)
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
|
||||
var contentId = data.contentid;
|
||||
if (ViewerData.hasOwnProperty(contentId)) {
|
||||
console.warn('Contentid already exists?');
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the viewer data object
|
||||
ViewerData[contentId] = {
|
||||
contentId: contentId,
|
||||
studies: data.studies,
|
||||
title: data.title
|
||||
};
|
||||
Session.set('ViewerData', ViewerData);
|
||||
|
||||
|
||||
// If there is a tab set as active in the Session,
|
||||
// switch to that now.
|
||||
var contentId = Session.get("activeContentId");
|
||||
if (contentId) {
|
||||
switchToTab(contentId);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Template.worklist.helpers({
|
||||
'tabs': function() {
|
||||
log.info('Updating tabs');
|
||||
return tabs.find();
|
||||
}
|
||||
});
|
||||
|
||||
Template.worklist.events({
|
||||
'click a[data-toggle="tab"]': function(e) {
|
||||
var contentId = $(e.currentTarget).data('target').replace("#", "");
|
||||
switchToTab(contentId);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user