LT-240: Add studyListFunctionsEnabled property (false as default) in public.ui object in settings file to enable/disable import / export / anonymize functions

LT-239: Error handling on the import process (WIP)
This commit is contained in:
Aysel Afsar 2016-04-21 22:42:06 -04:00
parent 1e1c4033a6
commit 2a17760ff8
15 changed files with 267 additions and 179 deletions

View File

@ -31,7 +31,10 @@ Meteor.startup(function() {
}],
"defaultServiceType": 'dicomWeb',
"public": {
"verifyEmail": false
"verifyEmail": false,
"ui": {
"studyListFunctionsEnabled": false
}
}
//defaultServiceType: 'dimse'
};

View File

@ -28,7 +28,12 @@ Meteor.startup(function() {
port: 4242,
hostAE: 'ORTHANC'
},
defaultServiceType: 'dicomWeb'
defaultServiceType: 'dicomWeb',
public: {
ui: {
studyListFunctionsEnabled: false
}
}
//defaultServiceType: 'dimse'
};

View File

@ -24,16 +24,20 @@
title="Remove Timepoint Association">
<i class="fa fa-eraser fa-lg"></i> Remove Association
</a>
{{#if studyListFunctionsEnabled}}
<a class="disabled"><span class="fa-stack fa-lg">
<i class="fa fa-user fa-stack-1x"></i>
<i class="fa fa-ban fa-stack-2x text-danger"></i>
</span> Anonymize
</a>
<a class="disabled"><i class="fa fa-trash fa-lg"></i> Delete</a>
<a class="disabled"><i class="fa fa-send-o fa-lg"></i> Send</a>
<a id="exportSelectedStudies" type="button"
title="Export Selected Studies">
<i class="fa fa-exchange fa-lg"></i> Export</a>
<i class="fa fa-exchange fa-lg"></i> Export
</a>
{{/if}}
<a class="disabled"><i class="fa fa-trash fa-lg"></i> Delete</a>
<a class="disabled"><i class="fa fa-send-o fa-lg"></i> Send</a>
<a class="disabled"><i class="fa fa-download fa-lg"></i> Download</a>
<a class="disabled"><i class="fa fa-photo fa-lg"></i> View Series Details</a>
</li>

View File

@ -172,3 +172,11 @@ function viewStudies() {
// Switch to the new tab
switchToTab(contentid);
}
Template.studyContextMenu.helpers({
'studyListFunctionsEnabled': function() {
var studyListFunctionsEnabled = Meteor.settings && Meteor.settings.public && Meteor.settings.public.ui &&
Meteor.settings.public.ui.studyListFunctionsEnabled || false;
return studyListFunctionsEnabled;
}
});

View File

@ -9,6 +9,7 @@
{{progressStatus}}
</div>
</div>
<div class="message">{{progressMessage}}</div>
</div>
</div>
</template>

View File

@ -18,6 +18,11 @@ progressDialog = {
Session.set("progressDialogSettings", { title: "", numberOfCompleted: 0, numberOfTotal: 1 });
$('#progressDialog').css('display', 'none');
},
'setMessage': function(message) {
var progressDialogSettings = Session.get("progressDialogSettings");
progressDialogSettings.message = message;
Session.set("progressDialogSettings", progressDialogSettings);
}
};
Template.progressDialog.helpers({
@ -40,5 +45,12 @@ Template.progressDialog.helpers({
}
return parseInt((numberOfCompleted / numberofTotal) * 100) + "%";
},
'progressMessage': function() {
var progressDialogSettings = Session.get("progressDialogSettings");
if (progressDialogSettings && progressDialogSettings.message) {
return progressDialogSettings.message;
}
return;
}
});

View File

@ -6,7 +6,10 @@ importStudies = function(filesToImport, importCallback) {
if (filesToImport.length < 1) {
return;
}
var fileUploadStatus = { numberOfFilesUploaded: 0, numberOfFilesFailed: 0 };
var fileUploadStatus = {
numberOfFilesUploaded: 0,
numberOfFilesFailed: 0
};
var numberOfFilesToUpload = filesToImport.length;
var studiesToImport = [];
@ -60,8 +63,11 @@ function updateFileUploadStatus(fileUploadStatus, isSuccess) {
fileUploadStatus.numberOfFilesUploaded++;
}
}
function importStudiesInternal(studiesToImport, importCallback) {
if (!studiesToImport) {
return;
}
var numberOfStudiesToImport = studiesToImport.length;
progressDialog.show("Importing Studies...", numberOfStudiesToImport);
@ -69,7 +75,9 @@ function importStudiesInternal(studiesToImport, importCallback) {
// Create/Insert a new study import status item
Meteor.call("createStudyImportStatus", function(err, studyImportStatusId) {
if (err) {
console.log(err);
// Hide dialog
progressDialog.close();
console.log(err.message);
return;
}
@ -82,6 +90,12 @@ function importStudiesInternal(studiesToImport, importCallback) {
var numberOfStudiesProcessedToImport = studyImportStatus.numberOfStudiesImported + studyImportStatus.numberOfStudiesFailed;
// Show failed message in the dialog
if (studyImportStatus.numberOfStudiesFailed > 0) {
var failMessage = "Failed to import " + studyImportStatus.numberOfStudiesFailed + " of " + numberOfStudiesToImport + " files";
progressDialog.setMessage(failMessage);
}
progressDialog.update(numberOfStudiesProcessedToImport);
if (numberOfStudiesProcessedToImport == numberOfStudiesToImport) {
@ -90,7 +104,10 @@ function importStudiesInternal(studiesToImport, importCallback) {
if (studyImportStatus.numberOfStudiesFailed > 0) {
//TODO: Some files failed to import, so let user know
console.log("Failed to import " + studyImportStatus.numberOfStudiesFailed + " of " + numberOfStudiesToImport + " files");
// Update progress dialog message
var failMessage = "Failed to import " + studyImportStatus.numberOfStudiesFailed + " of " + numberOfStudiesToImport + " files";
progressDialog.setMessage(failMessage);
console.log(failMessage);
}
// Let the caller know that import operation is completed

View File

@ -49,6 +49,10 @@ Meteor.methods({
* @param studyImportStatusId Study import status collection id to track import status
*/
importStudies: function(studiesToImport, studyImportStatusId) {
if (!studiesToImport || !studyImportStatusId) {
return;
}
if (Meteor.settings.dicomWeb && Meteor.settings.defaultServiceType === 'dicomWeb') {
//TODO: Support importing studies into dicomWeb
console.log('Importing studies into dicomWeb is currently not supported.');
@ -76,10 +80,15 @@ Meteor.methods({
});
function importStudiesDIMSE(studiesToImport, studyImportStatusId) {
if (!studiesToImport || !studyImportStatusId) {
return;
}
// Perform C-Store to import studies and handle the callbacks to update import status
DIMSE.storeInstances(studiesToImport, function(err, file) {
try {
// Use fiber to be able to modify meteor collection in callback
fiber(function() {
try {
// Update the import status
if (err) {
StudyImportStatus.update({_id: studyImportStatusId}, {$inc: {'numberOfStudiesFailed': 1}});
@ -89,11 +98,23 @@ function importStudiesDIMSE(studiesToImport, studyImportStatusId) {
console.log("Study successfully imported via DIMSE: ", file);
}
} catch(error) {
StudyImportStatus.update({_id: studyImportStatusId}, {$inc: {'numberOfStudiesFailed': 1}});
console.log("Failed to import study via DIMSE: ", file, error);
} finally {
// The import operation of this file is completed, so delete it if still exists
if (fileExists(file)) {
fs.unlink(file);
}
}
}).run();
} catch(error) {
StudyImportStatus.update({_id: studyImportStatusId}, {$inc: {'numberOfStudiesFailed': 1}});
console.log("Failed to import study via DIMSE: ", file, error);
}
});
}

View File

@ -5,16 +5,18 @@
onselectstart='return false;'>
<ul>
<li>
{{#if studyListFunctionsEnabled}}
<a class="disabled"><span class="fa-stack fa-lg">
<i class="fa fa-user fa-stack-1x"></i>
<i class="fa fa-ban fa-stack-2x text-danger"></i>
</span> Anonymize
</a>
<a id="exportSelectedStudies" type="button" title="Export Selected Studies">
<i class="fa fa-exchange fa-lg"></i> Export
</a>
{{/if}}
<a class="disabled"><i class="fa fa-trash fa-lg"></i> Delete</a>
<a class="disabled"><i class="fa fa-send-o fa-lg"></i> Send</a>
<a id="exportSelectedStudies" type="button"
title="Export Selected Studies">
<i class="fa fa-exchange fa-lg"></i> Export</a>
<a class="disabled"><i class="fa fa-download fa-lg"></i> Download</a>
<a class="disabled"><i class="fa fa-photo fa-lg"></i> View Series Details</a>
</li>

View File

@ -82,3 +82,10 @@ Template.studyContextMenu.events({
closeHandler(dialog);
}
});
Template.studyContextMenu.helpers({
'studyListFunctionsEnabled': function() {
var studyListFunctionsEnabled = Meteor.settings && Meteor.settings.public && Meteor.settings.public.ui &&
Meteor.settings.public.ui.studyListFunctionsEnabled || false; return studyListFunctionsEnabled;
}
});

View File

@ -1,4 +1,5 @@
<template name="worklistResult">
<div id="studyListContainer">
{{>worklistToolbar}}
<table id="tblStudyList" class="worklistResult table noselect">
<thead>
@ -95,4 +96,6 @@
{{#if showNotFoundMessage}}
{{>studyNotFound}}
{{/if}}
</div>
</template>

View File

@ -1,3 +1,5 @@
#studyListContainer
position: relative
table#tblStudyList
color: #888888
border-collapse: collapse

View File

@ -4,7 +4,7 @@
{{#if importSupported }}
<span class="btn btn-default btn-file">
<i class="fa fa-upload"></i>
<input id="btnImport" title="Import" type="file" webkitdirectory directory multiple>
<input id="btnImport" title="Import Study" type="file" webkitdirectory directory multiple>
</span>
{{/if }}
</div>

View File

@ -12,7 +12,10 @@ Template.worklistToolbar.events({
Template.worklistToolbar.helpers({
importSupported: function() {
var importSupported = Session.get('importSupported');
if (importSupported) {
var studyListFunctionsEnabled = Meteor.settings && Meteor.settings.public && Meteor.settings.public.ui &&
Meteor.settings.public.ui.studyListFunctionsEnabled || false;
if (importSupported && studyListFunctionsEnabled) {
return true;
}
return false;

View File

@ -1,8 +1,8 @@
#worklistToolbar
background-color: black
text-align: right
width: 100%
height: auto
position: absolute
top: 0
right: 0
.btn-file
position: relative