reorganize packages, start converting overall app to react (very broken at the moment)
This commit is contained in:
1 parent
024fe1a448
commit
5f30f7bd35
479 files changed
+5364
-11611
No files matched your search
@@ -1,126 +0,0 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
/**
|
||||
* Imports selected studies from local into studylist
|
||||
* @param filesToImport Files located in the client machine to import
|
||||
*/
|
||||
OHIF.studylist.importStudies = filesToImport => {
|
||||
const numberOfFiles = filesToImport && filesToImport.length;
|
||||
if (!numberOfFiles) {
|
||||
return new Promise((resolve, reject) => reject('No files to upload'));
|
||||
}
|
||||
|
||||
const uploadMessage = msg => (typeof msg === 'undefined') ? '' : `Uploaded files: ${msg.processed} / ${msg.total}`;
|
||||
|
||||
const taskRunHandler = dialog => {
|
||||
const uploadErrorHandler = fileNames => {
|
||||
const names = fileNames.join('; ');
|
||||
dialog.setMessage(`Failed to upload files: ${names}`);
|
||||
};
|
||||
|
||||
const uploadSuccessHandler = studiesToImport => {
|
||||
importStudiesInternal(studiesToImport, dialog).then(() => {
|
||||
dialog.done();
|
||||
}).catch(errorMessage => {
|
||||
dialog.setMessage(errorMessage);
|
||||
});
|
||||
};
|
||||
|
||||
uploadFiles(filesToImport, dialog).then(uploadSuccessHandler).catch(uploadErrorHandler);
|
||||
};
|
||||
|
||||
return OHIF.ui.showDialog('dialogProgress', {
|
||||
title: 'Importing Studies...',
|
||||
message: uploadMessage,
|
||||
total: numberOfFiles,
|
||||
task: { run: taskRunHandler }
|
||||
});
|
||||
};
|
||||
|
||||
const uploadFiles = (files, dialog) => {
|
||||
let processed = 0;
|
||||
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
const promises = [];
|
||||
|
||||
// Upload files to the server
|
||||
files.forEach(file => {
|
||||
const filePromise = uploadFile(file, dialog);
|
||||
filePromise.then(() => dialog.update(++processed));
|
||||
promises.push(filePromise);
|
||||
});
|
||||
|
||||
Promise.all(promises).then(resolve).catch(reject);
|
||||
});
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
const uploadFile = file => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', '/uploadFilesToImport', true);
|
||||
xhr.setRequestHeader('filename', file.name);
|
||||
|
||||
xhr.onload = () => {
|
||||
if (xhr.readyState === 4 && xhr.status !== 200) {
|
||||
// Failed to upload the file
|
||||
reject(file.name);
|
||||
} else {
|
||||
// Success uploading the file
|
||||
resolve(xhr.responseText);
|
||||
}
|
||||
};
|
||||
|
||||
// Failed to upload the file
|
||||
xhr.onerror = () => reject(file.name);
|
||||
|
||||
xhr.send(file);
|
||||
});
|
||||
};
|
||||
|
||||
const importStudiesInternal = (studiesToImport, dialog) => {
|
||||
const numberOfStudies = studiesToImport && studiesToImport.length;
|
||||
if (!numberOfStudies) {
|
||||
return new Promise((resolve, reject) => reject('No studies to import'));
|
||||
}
|
||||
|
||||
let processed = 0;
|
||||
dialog.update(processed);
|
||||
dialog.setTotal(numberOfStudies);
|
||||
dialog.setMessage(({ processed, total }) => `Imported: ${processed} / ${total}`);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
// Create/Insert a new study import status item
|
||||
Meteor.call('createStudyImportStatus', (error, studyImportStatusId) => {
|
||||
if (error) {
|
||||
return reject(error.message);
|
||||
}
|
||||
|
||||
// Handle when StudyImportStatus collection is updated
|
||||
OHIF.studylist.collections.StudyImportStatus.find(studyImportStatusId).observe({
|
||||
changed(studyImportStatus) {
|
||||
const { numberOfStudiesImported, numberOfStudiesFailed } = studyImportStatus;
|
||||
dialog.update(numberOfStudiesImported);
|
||||
|
||||
if ((numberOfStudiesImported + numberOfStudiesFailed) === numberOfStudies) {
|
||||
// The entire import operation is completed, so remove the study import status item
|
||||
Meteor.call('removeStudyImportStatus', studyImportStatus._id);
|
||||
|
||||
// Show number of failed files if there is at least one failed file
|
||||
if (studyImportStatus.numberOfStudiesFailed > 0) {
|
||||
const failed = numberOfStudiesFailed;
|
||||
reject(`Failed to import ${failed} of ${numberOfStudies} studies`);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Import studies with study import status id to get callbacks
|
||||
Meteor.call('importStudies', studiesToImport, studyImportStatusId);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -1,7 +1,6 @@
|
||||
import './exportSelectedStudies.js';
|
||||
import './exportStudies.js';
|
||||
//import './exportSelectedStudies.js';
|
||||
//import './exportStudies.js';
|
||||
import './getSelectedStudies.js';
|
||||
import './importStudies.js';
|
||||
import './queryStudies.js';
|
||||
import './studylist.js';
|
||||
import './viewSeriesDetails.js';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import { Router } from 'meteor/clinical:router';
|
||||
|
||||
// Functions
|
||||
import { getStudyPriors } from './getStudyPriors';
|
||||
@@ -11,7 +10,8 @@ OHIF.studylist.functions = {
|
||||
};
|
||||
|
||||
const dblClickOnStudy = data => {
|
||||
Router.go('viewerStudies', { studyInstanceUids: data.studyInstanceUid });
|
||||
//Router.go('viewerStudies', { studyInstanceUids: data.studyInstanceUid });
|
||||
console.log('dblClickOnStudy');
|
||||
};
|
||||
|
||||
OHIF.studylist.callbacks.dblClickOnStudy = dblClickOnStudy;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import { Router } from 'meteor/clinical:router';
|
||||
|
||||
/**
|
||||
* Loads multiple unassociated studies in the Viewer
|
||||
@@ -14,5 +13,6 @@ OHIF.studylist.viewStudies = () => {
|
||||
|
||||
const studyInstanceUids = selectedStudies.map(study => study.studyInstanceUid).join(';');
|
||||
|
||||
Router.go('viewerStudies', { studyInstanceUids });
|
||||
//Router.go('viewerStudies', { studyInstanceUids });
|
||||
console.log('OHIF.studylist.viewStudies');
|
||||
};
|
||||
Reference in new issue
Block a user